/*
 * ZenPoll (v2) - Visual Skin & Design System
 * 
 * Embraces a premium, minimalist, "Zen-like" visual identity.
 * Features:
 * - Fluid mobile-responsive styling
 * - Seamless Light/Dark theme switching with smooth transitions
 * - Curated desaturated color palette
 * - Beautiful modern typography (Outfit & Inter)
 * - Glassmorphism, card-shadows, and micro-animations
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Outfit:wght@400;500;600;700&display=swap');

/* --- Design Tokens & CSS Variables --- */
:root {
  /* Light Theme Spec (Zen White) */
  --global-bg: #F9F9FB;
  --card-bg: #FFFFFF;
  --text-primary: #1A1A1E;
  --text-secondary: #71717A;
  --border-color: #E4E4E7;
  
  /* Status: YES / Available */
  --status-yes-bg: #E6F4EA;
  --status-yes-text: #137333;
  
  /* Status: NO / Unavailable */
  --status-no-bg: #FCE8E6;
  --status-no-text: #C5221F;
  
  /* Status: MAYBE / Tentative */
  --status-maybe-bg: #FEF7E0;
  --status-maybe-text: #B06000;

  /* Accent Colors */
  --accent: #5F61E6;
  --accent-hover: #4749BF;
  --accent-light: #EEEDFD;
  
  /* Layout & Shadows */
  --font-title: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --card-shadow: 0 4px 20px -2px rgba(17, 12, 46, 0.04);
  --header-shadow: 0 1px 0px 0px rgba(0, 0, 0, 0.05);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --max-width: 800px;
}

[data-theme="dark"] {
  /* Dark Theme Spec (Ink Black) */
  --global-bg: #121214;
  --card-bg: #1E1E22;
  --text-primary: #E4E4E6;
  --text-secondary: #A1A1AA;
  --border-color: #27272A;
  
  /* Status: YES / Available */
  --status-yes-bg: #132D1B;
  --status-yes-text: #81C995;
  
  /* Status: NO / Unavailable */
  --status-no-bg: #3C1615;
  --status-no-text: #F28B82;
  
  /* Status: MAYBE / Tentative */
  --status-maybe-bg: #3E2B00;
  --status-maybe-text: #FDD663;

  /* Accent Colors */
  --accent: #8A8DF0;
  --accent-hover: #AAADF7;
  --accent-light: #252538;
  
  /* Layout & Shadows */
  --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --header-shadow: 0 1px 0px 0px rgba(255, 255, 255, 0.05);
}

/* --- Base Reset --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background-color: var(--global-bg);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 16px; /* Base 16px */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.4s ease, color 0.4s ease;
  overflow-x: hidden;
}

button:focus-visible, a.btn:focus-visible, .form-input:focus-visible, .cal-day-cell:focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-light) !important;
}

button, a.btn {
  outline: none;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--global-bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* --- Layout Elements --- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(249, 249, 251, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

[data-theme="dark"] header {
  background-color: rgba(18, 18, 20, 0.8);
}

.header-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent), #B3B5FA);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.9rem;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

main {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
}

footer {
  border-top: 1px solid var(--border-color);
  background-color: var(--global-bg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  transition: border-color 0.4s ease;
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: center;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: var(--text-primary);
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* --- UI Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-title);
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hero-title {
  font-size: 2.5rem;
}

@media (max-width: 600px) {
  .hero-title {
    font-size: 1.5rem;
  }
}

p {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* --- Interactive Components --- */
.card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--card-shadow);
  transition: background-color 0.4s ease, border-color 0.4s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: 0 10px 25px -5px rgba(17, 12, 46, 0.1); /* Increased elevation */
}

.card:has(input:focus) {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), 
              background-color 0.15s cubic-bezier(0.4, 0, 0.2, 1), 
              box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.15s ease;
  border: none;
  text-decoration: none;
  user-select: none;
}

.btn-primary {
  background-color: var(--accent);
  color: white;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  background-color: var(--accent);
  opacity: 0.9;
}

.btn-secondary {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:active {
  background-color: var(--accent-light);
  opacity: 0.8;
}

.btn-icon {
  width: 44px; /* Increased from 40px */
  height: 44px; /* Increased from 40px */
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  user-select: none;
}

.btn-icon:hover {
  background-color: var(--border-color);
}

.btn-icon:active {
  transform: scale(0.95);
  background-color: var(--accent-light);
}

.btn-sm {
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
}

/* Form Elements */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.form-group label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.form-input {
  width: 100%;
  padding: 0.85rem 1rem; /* Increased padding */
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: transparent;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px; /* Explicit 16px to prevent auto-zoom on iOS */
  transition: all 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

/* --- View Routing Animations --- */
.view-route {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.view-route.active {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Unified Modern Calendar Component --- */
.calendar-widget {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.calendar-month-name {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.25rem;
}

.calendar-grid-container {
  position: relative;
  overflow: hidden;
  min-height: 290px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: 2.5rem repeat(7, 1fr);
  gap: 6px;
  animation: slideMonth 0.25s ease-in-out;
}

@keyframes slideMonth {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

.cal-header-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700; /* Bolder */
  font-size: 0.75rem;
  color: var(--text-primary); /* Darker text */
  padding: 0.5rem 0;
  text-transform: uppercase;
  background-color: var(--global-bg); /* Distinct background */
  border-bottom: 1px solid var(--border-color); /* Separator */
}

.cal-week-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  opacity: 0.5;
  border-right: 1px solid var(--border-color);
}

/* Subtly distinguish weekends */
.cal-day-cell.weekend {
  background-color: rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .cal-day-cell.weekend {
  background-color: rgba(255, 255, 255, 0.03);
}

.cal-day-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  position: relative;
  will-change: background-color, color, border-color, transform;
}

.cal-day-cell:active {
  transform: scale(0.92); /* Micro-feedback animation */
}

.cal-day-empty {
  cursor: default;
  pointer-events: none;
  opacity: 0.15;
}

@media (hover: hover) {
  .cal-day-cell:not(.cal-day-empty):not(.selected):not(.proposed):not(.vote-yes):not(.vote-no):not(.vote-maybe):not(.vote-suggested):hover {
    background-color: var(--accent-light);
    color: var(--accent);
  }
}

.cal-day-cell:not(.cal-day-empty):active {
  background-color: var(--accent);
  color: white;
}

/* Date States (Organizer Picker) */
.cal-day-cell.selected {
  background-color: var(--accent) !important;
  color: white !important;
}

/* Date States (Participant Voter) */
.cal-day-cell.proposed {
  border: 2px dashed var(--accent);
}

.cal-day-cell.vote-yes {
  background-color: var(--status-yes-bg) !important;
  color: var(--status-yes-text) !important;
  border-style: solid;
}

.cal-day-cell.vote-no {
  background-color: var(--status-no-bg) !important;
  color: var(--status-no-text) !important;
  border-style: solid;
}

.cal-day-cell.vote-maybe {
  background-color: var(--status-maybe-bg) !important;
  color: var(--status-maybe-text) !important;
  border-style: solid;
}

.cal-day-cell.vote-suggested {
  background-color: var(--status-yes-bg) !important;
  color: var(--status-yes-text) !important;
  border: 2px dashed var(--status-yes-text) !important;
}

.cal-day-legend {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  font-size: 0.8rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-indicator {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

/* --- Results Matrix Grid (Management View) --- */
.results-matrix-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--card-bg);
}

.results-matrix {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.results-matrix th, 
.results-matrix td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.results-matrix th {
  background-color: var(--global-bg);
  font-family: var(--font-title);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.matrix-header-date {
  text-align: center;
}

.matrix-header-date .date-sub {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-secondary);
  display: block;
}

.matrix-cell-vote {
  text-align: center;
}

.matrix-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 600;
}

.matrix-pill.yes { background-color: var(--status-yes-bg); color: var(--status-yes-text); }
.matrix-pill.no { background-color: var(--status-no-bg); color: var(--status-no-text); }
.matrix-pill.maybe { background-color: var(--status-maybe-bg); color: var(--status-maybe-text); }

.best-dates-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.best-date-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  background: linear-gradient(to right, var(--status-yes-bg), var(--card-bg));
  border: 1px solid var(--status-yes-text);
}

/* --- Compliance Layers (Simulated CMP & Ad Placements) --- */
/* Native Ad Placements */
.ad-slot-rail {
  display: none;
}

@media (min-width: 1200px) {
  .ad-slot-rail {
    display: flex;
    position: fixed;
    top: 150px;
    width: 140px;
    height: 600px;
    background-color: var(--card-bg);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
  }
  .ad-slot-rail.left { left: 40px; }
  .ad-slot-rail.right { right: 40px; }
}

.ad-slot-footer {
  width: 100%;
  max-width: var(--max-width);
  margin: 1.5rem auto 0;
  padding: 1rem;
  background-color: var(--card-bg);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
  gap: 0.25rem;
}

/* Google Certified CMP Popover (Cookie Banner) */
.cmp-banner {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  width: 90%;
  max-width: 580px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px -10px rgba(17, 12, 46, 0.15);
  padding: 1.75rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.cmp-banner.visible {
  transform: translateX(-50%) translateY(0);
}

.cmp-title {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cmp-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.cmp-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* --- Clipboard Copy Animation Overlay --- */
.copy-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: var(--text-primary);
  color: var(--global-bg);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 1100;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.copy-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Responsive Adaptations --- */
@media (max-width: 600px) {
  main {
    padding: 1.5rem 0.75rem; /* Reduced padding */
  }
  
  .card {
    padding: 1.25rem 1rem; /* Reduced padding */
  }

  .calendar-grid {
    grid-template-columns: 1.5rem repeat(7, 1fr); /* Responsive grid width */
    gap: 4px;
  }

  .cal-day-cell {
    font-size: 0.8rem;
  }

  .cal-header-cell {
    font-size: 0.65rem;
  }

  .results-matrix th, 
  .results-matrix td {
    padding: 0.6rem 0.75rem;
    font-size: 0.8rem;
  }
  
  .cmp-buttons {
    flex-direction: column-reverse;
  }
  
  .cmp-buttons .btn {
    width: 100%;
  }
}
