/* ================================================================
   Time Zone Meeting Planner — Dark Default Design System
   Palette: Teal primary + Amber accent + Dark Slate neutrals
   Typography: Inter (Google Fonts) — 400/500/600/700/800/900
   Theme: Dark by default; [data-theme="light"] for light mode
   ================================================================ */

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Dark theme (default) */
  --primary: #0d9488;
  --primary-light: #14b8a6;
  --primary-dark: #0f766e;
  --primary-bg: #042f2e;

  --accent: #f59e0b;
  --accent-light: #fbbf24;
  --accent-bg: #451a03;

  /* Neutrals */
  --bg: #0f172a;
  --card-bg: #1e293b;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --border-light: #1e293b;

  /* Spacing & Shape */
  --radius: 10px;
  --radius-lg: 16px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -4px rgba(0,0,0,0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.5), 0 8px 10px -6px rgba(0,0,0,0.3);

  /* Success / Warning / Error */
  --success: #34d399;
  --success-bg: #064e3b;
  --warning: #fbbf24;
  --warning-bg: #451a03;
  --error: #f87171;
  --error-bg: #450a0a;

  /* Ad */
  --ad-bg: #1e293b;

  /* Input disabled */
  --input-disabled-bg: #0f172a;

  /* Font */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  color-scheme: dark;
}

/* Light theme override */
[data-theme="light"] {
  --primary: #0d9488;
  --primary-light: #14b8a6;
  --primary-dark: #0f766e;
  --primary-bg: #f0fdfa;

  --accent: #f59e0b;
  --accent-light: #fbbf24;
  --accent-bg: #fffbeb;

  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);

  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --error: #dc2626;
  --error-bg: #fef2f2;

  --ad-bg: #f1f5f9;
  --input-disabled-bg: #f8fafc;

  color-scheme: light;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== HEADER ===== */
header {
  text-align: center;
  padding: 3rem 1.5rem 2rem;
  background: linear-gradient(180deg, var(--primary-bg) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  position: relative;
}

header h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  color: var(--primary-light);
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* Theme toggle */
.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  /* Hide emoji text for screen readers */
  line-height: 1;
}
.theme-toggle:hover {
  background: var(--primary-bg);
  border-color: var(--primary);
  transform: scale(1.05);
}

/* ===== MAIN CONTENT ===== */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ===== INTRO SECTION ===== */
.intro {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.intro h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-light);
  margin-bottom: 1rem;
}

.intro p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.intro p:last-of-type { margin-bottom: 0; }

/* ===== PLANNER SECTION ===== */
#planner {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-top: 2.5rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow);
}

/* ===== LOCATION SLOTS ===== */
#location-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.location-card {
  flex: 1 1 280px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  transition: border-color 0.2s var(--ease);
  min-width: 240px;
}

.location-card:hover {
  border-color: var(--primary);
}

.location-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.location-card .city-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

.location-card .country-name {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
}

.location-card .timezone-label {
  font-size: 0.8rem;
  color: var(--primary-light);
  font-weight: 500;
}

.location-card .current-time {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
  margin-bottom: 0.75rem;
}

.location-card .remove-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s var(--ease);
  line-height: 1;
}

.location-card .remove-btn:hover {
  color: var(--error);
  background: var(--error-bg);
}

.location-card .working-hours {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.location-card .working-hours select {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
  font-family: var(--font);
}

/* Location colors — applied via data attribute */
[data-location-color="0"] { --location-color: #6366f1; }
[data-location-color="1"] { --location-color: #14b8a6; }
[data-location-color="2"] { --location-color: #f59e0b; }
[data-location-color="3"] { --location-color: #ec4899; }
[data-location-color="4"] { --location-color: #8b5cf6; }
[data-location-color="5"] { --location-color: #06b6d4; }

.location-card .color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--location-color);
  display: inline-block;
  margin-right: 0.4rem;
}

/* ===== ADD LOCATION BUTTON ===== */
#add-location {
  margin-bottom: 1.5rem;
}

/* ===== AUTOCOMPLETE ===== */
.autocomplete-wrapper {
  position: relative;
  margin-bottom: 0;
  display: none;
}

.autocomplete-wrapper.active {
  display: block;
}

.autocomplete-wrapper input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s var(--ease);
}

.autocomplete-wrapper input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 240px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: var(--shadow-lg);
  display: none;
}

.autocomplete-dropdown.visible {
  display: block;
}

.autocomplete-item {
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border-light);
}

.autocomplete-item:last-child { border-bottom: none; }

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: var(--primary-bg);
  color: var(--primary-light);
}

.autocomplete-item .item-city {
  font-weight: 600;
}

.autocomplete-item .item-country {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-left: 0.5rem;
}

.autocomplete-item .item-tz {
  color: var(--text-muted);
  font-size: 0.75rem;
  float: right;
}

/* ===== BUTTONS ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  padding: 0.5rem 1rem;
  background: var(--card-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

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

/* ===== TIMELINE ===== */
#timeline-container {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

#timeline-canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* ===== AD CONTAINER ===== */
.ad-container {
  margin: 1.5rem 0;
  text-align: center;
}

.ad-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.ad-slot {
  background: var(--ad-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-slot ins {
  display: block;
  min-height: 90px;
}

/* ===== RESULTS ===== */
#results {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

#results h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
}

.meeting-times-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.meeting-times-table th,
.meeting-times-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.meeting-times-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.meeting-times-table td {
  font-family: var(--font-mono);
  color: var(--text);
}

.meeting-times-table tr:last-child td {
  border-bottom: none;
}

.meeting-times-table .overlap-badge {
  display: inline-block;
  background: var(--success-bg);
  color: var(--success);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-family: var(--font);
}

.copy-btn {
  margin-top: 1rem;
}

.copied-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: #fff;
  padding: 0.6rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: fadeSlideIn 0.3s var(--ease);
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== DST WARNING ===== */
.dst-warning {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--warning);
}

.dst-warning .warning-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ===== NO OVERLAP ===== */
.no-overlap {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.no-overlap .icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

/* ===== BLOG ===== */
.blog-card {
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  transition: border-color 0.2s var(--ease);
}

.blog-card:hover {
  border-color: var(--primary);
}

.blog-card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.blog-card h2 a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s var(--ease);
}

.blog-card h2 a:hover {
  color: var(--primary-light);
}

.blog-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* ===== FOOTER ===== */
footer {
  text-align: center;
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s var(--ease);
}

footer a:hover {
  color: var(--primary-light);
}

footer .last-updated {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  header { padding: 2rem 1rem 1.5rem; }
  header h1 { font-size: 1.5rem; }
  .subtitle { font-size: 0.9rem; }

  main { padding: 1rem; }

  .intro { padding: 1.25rem; }
  .intro h2 { font-size: 1.25rem; }

  #planner { padding: 1.25rem; }

  #location-slots { flex-direction: column; }
  .location-card { flex: 1 1 auto; min-width: 0; }

  #timeline-container { padding: 0.5rem; }

  .meeting-times-table { font-size: 0.8rem; }
  .meeting-times-table th,
  .meeting-times-table td { padding: 0.4rem 0.5rem; }
}

@media (max-width: 480px) {
  header h1 { font-size: 1.3rem; }
  .theme-toggle { top: 0.5rem; right: 0.5rem; font-size: 1rem; }
}