:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --bg-input: rgba(31, 41, 55, 0.9);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-active: rgba(59, 130, 246, 0.5);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.3);
  --accent-gold: #f59e0b;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --clock-face: #1e293b;
  --clock-rim: #334155;
  --clock-hour-hand: #f8fafc;
  --clock-min-hand: #94a3b8;
  --clock-sec-hand: #ef4444;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.15);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-input: #e2e8f0;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-color-active: rgba(59, 130, 246, 0.6);
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --clock-face: #ffffff;
  --clock-rim: #cbd5e1;
  --clock-hour-hand: #0f172a;
  --clock-min-hand: #475569;
  --clock-sec-hand: #ef4444;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.07);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.07) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(245, 158, 11, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--clock-rim);
  border-radius: 4px;
}

.container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

/* Header */
header {
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 12px 0;
  transition: all 0.3s ease;
}

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

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, var(--text-main), var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text span {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  color: var(--text-main);
  border-color: var(--border-color-active);
  transform: translateY(-1px);
}

.btn-primary {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: white;
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  gap: 8px;
  margin: 24px 0 16px;
  background: var(--bg-card);
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  width: fit-content;
}

.tab-btn {
  padding: 8px 18px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: var(--accent-blue);
  color: white;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

.tab-btn:hover:not(.active) {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

/* Madrid Spotlight Section */
.hero-madrid {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.hero-madrid::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -20%;
  width: 70%;
  height: 200%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.madrid-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  align-items: center;
}

@media (max-width: 860px) {
  .madrid-grid {
    grid-template-columns: 1fr;
    text-align: center;
  }
}

.madrid-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.city-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.25);
  font-size: 0.85rem;
  font-weight: 600;
  width: fit-content;
}

@media (max-width: 860px) {
  .city-badge {
    margin: 0 auto;
  }
}

.madrid-title {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
}

.madrid-digital-time {
  font-family: var(--font-mono);
  font-size: 3.8rem;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
  color: var(--text-main);
  text-shadow: 0 0 30px rgba(59, 130, 246, 0.25);
  margin: 6px 0;
}

.madrid-digital-time .seconds {
  font-size: 2.2rem;
  color: var(--accent-blue);
  font-weight: 600;
}

.madrid-digital-time .ampm {
  font-size: 1.2rem;
  color: var(--text-dim);
  margin-left: 8px;
}

.madrid-date {
  font-size: 1.15rem;
  color: var(--text-muted);
  font-weight: 500;
}

.madrid-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 10px;
}

@media (max-width: 860px) {
  .madrid-meta-row {
    justify-content: center;
  }
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.meta-item b {
  color: var(--text-main);
}

/* Analog Clock Container */
.analog-clock-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
}

.clock-canvas {
  width: 220px;
  height: 220px;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3));
}

/* World Clocks Section */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box-wrapper {
  position: relative;
  min-width: 280px;
}

.search-input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 1rem;
  pointer-events: none;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.search-dropdown.active {
  display: block;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.15s ease;
}

.search-result-item:hover {
  background: rgba(59, 130, 246, 0.15);
}

.search-result-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-result-flag {
  font-size: 1.4rem;
}

.search-result-names {
  display: flex;
  flex-direction: column;
}

.search-result-city {
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.9rem;
}

.search-result-country {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.search-result-time {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-blue);
  font-weight: 600;
}

/* City Cards Grid */
.clocks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.clock-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.clock-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.4);
  border-color: var(--border-color-active);
}

/* Day/Night ambient card glow */
.clock-card.day-time {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(245, 158, 11, 0.05) 100%);
}

.clock-card.night-time {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(30, 58, 138, 0.12) 100%);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.card-city-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-flag {
  font-size: 2rem;
  line-height: 1;
}

.card-city-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-country-title {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card-actions {
  display: flex;
  gap: 6px;
}

.btn-card-action {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.btn-card-action:hover {
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.1);
}

.card-center {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.card-mini-clock {
  width: 90px;
  height: 90px;
  flex-shrink: 0;
}

.card-time-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.card-digital-time {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
  color: var(--text-main);
}

.card-digital-time .sec {
  font-size: 1.3rem;
  color: var(--accent-blue);
  font-weight: 500;
}

.card-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: right;
}

.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
}

.offset-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-weight: 500;
}

.offset-badge.same {
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.3);
}

.day-status {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-dim);
}

/* Time Planner / Slider Section */
.planner-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 40px;
}

.planner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.planner-slider-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.time-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(to right, #1e3a8a 0%, #f59e0b 25%, #3b82f6 50%, #f59e0b 75%, #1e3a8a 100%);
  outline: none;
  cursor: pointer;
}

.time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--accent-blue);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  transition: transform 0.1s ease;
}

.time-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.planner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.planner-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.planner-city {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

.planner-time {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-blue);
}

/* Tools Views (Stopwatch & Timer) */
.tool-view {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  margin-bottom: 40px;
  text-align: center;
}

.tool-view.active {
  display: block;
}

.tool-display {
  font-family: var(--font-mono);
  font-size: 4.5rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -2px;
  margin: 20px 0 30px;
  text-shadow: 0 0 30px rgba(59, 130, 246, 0.2);
}

@media (max-width: 600px) {
  .tool-display {
    font-size: 3rem;
  }
}

.tool-display .millis {
  font-size: 2.5rem;
  color: var(--accent-blue);
}

.tool-controls {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.btn-tool {
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-start {
  background: var(--accent-emerald);
  color: white;
}
.btn-stop {
  background: var(--accent-rose);
  color: white;
}
.btn-lap {
  background: var(--accent-blue);
  color: white;
}
.btn-reset {
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.laps-list {
  max-width: 400px;
  margin: 0 auto;
  text-align: left;
  max-height: 200px;
  overflow-y: auto;
}

.lap-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
}

.modal-city-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 16px;
}

.modal-city-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-city-item:hover {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.1);
}

.modal-city-item.added {
  opacity: 0.6;
  cursor: not-allowed;
  border-color: transparent;
}

/* Footer */
footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  padding: 24px 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 8px;
}

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

.footer-links a:hover {
  color: var(--accent-blue);
}
