/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --bg-base: #0d0f1a;
  --bg-surface: #13172b;
  --bg-raised: #1a1f36;
  --bg-card: #1e2440;

  --accent-primary: #6c63ff;
  --accent-glow: rgba(108, 99, 255, 0.35);
  --accent-light: #a59dff;
  --accent-warm: #ff6b9d;
  --accent-teal: #00d4aa;
  --accent-gold: #ffd166;

  --text-primary: #f0f2ff;
  --text-secondary: #8b90c1;
  --text-muted: #4a5080;

  --border-subtle: rgba(108, 99, 255, 0.18);
  --border-glass: rgba(255, 255, 255, 0.07);

  --nav-h: 72px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --shadow-glow: 0 0 40px rgba(108, 99, 255, 0.2);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Subtle gradient background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(108, 99, 255, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 85% 100%, rgba(0, 212, 170, 0.08) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0 2rem;
  background: rgba(13, 15, 26, 0.7);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--border-glass);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3), var(--shadow-glow);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.navbar-icon {
  font-size: 2rem;
  filter: drop-shadow(0 0 8px rgba(108, 99, 255, 0.6));
  animation: pulse-icon 3s ease-in-out infinite;
}

@keyframes pulse-icon {

  0%,
  100% {
    filter: drop-shadow(0 0 8px rgba(108, 99, 255, 0.6));
  }

  50% {
    filter: drop-shadow(0 0 16px rgba(108, 99, 255, 0.9));
  }
}

.navbar-title-group {
  display: flex;
  flex-direction: column;
}

.navbar-title {
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.navbar-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.navbar-controls {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

/* ============================================================
   CONTROL GROUPS
   ============================================================ */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.control-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ============================================================
   SELECT DROPDOWN
   ============================================================ */
.select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

#country-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.45rem 2.2rem 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 200px;
  max-width: 260px;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
}

#country-select:hover,
#country-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-card);
}

#country-select option {
  background: var(--bg-raised);
  color: var(--text-primary);
}

.select-arrow {
  position: absolute;
  right: 0.7rem;
  color: var(--accent-primary);
  font-size: 0.85rem;
  pointer-events: none;
  transition: transform var(--transition);
}

.select-wrapper:focus-within .select-arrow {
  transform: rotate(180deg);
}

/* ============================================================
   YEAR NAVIGATOR
   ============================================================ */
.year-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.5rem;
}

.year-btn {
  background: transparent;
  border: none;
  color: var(--accent-light);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition), transform var(--transition);
  line-height: 1;
}

.year-btn:hover {
  background: var(--accent-glow);
  color: var(--accent-primary);
  transform: scale(1.15);
}

.year-btn:active {
  transform: scale(0.95);
}

.year-display {
  font-size: 1rem;
  font-weight: 700;
  min-width: 52px;
  text-align: center;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

/* ============================================================
   SPINNER
   ============================================================ */
.spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.spinner[hidden] {
  display: none;
}

.spinner-ring {
  width: 22px;
  height: 22px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   ERROR BANNER
   ============================================================ */
.error-banner {
  position: relative;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.5rem;
  background: rgba(255, 80, 80, 0.15);
  border-bottom: 1px solid rgba(255, 80, 80, 0.4);
  color: #ff9090;
  font-size: 0.875rem;
  animation: slide-down 0.25s var(--transition);
}

.error-banner[hidden] {
  display: none;
}

@keyframes slide-down {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

#error-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition);
}

#error-close:hover {
  opacity: 1;
}

/* ============================================================
   CALENDAR WRAPPER & GRID
   ============================================================ */
.calendar-wrapper {
  position: relative;
  z-index: 1;
  padding: 0.4rem 0.75rem 0.25rem;
  max-width: 1800px;
  margin: 0 auto;
  width: 100%;
  height: calc(100vh - var(--nav-h) - 28px);
  overflow: hidden;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 0.4rem;
  height: 100%;
  animation: fade-in 0.4s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   MONTH CARD
   ============================================================ */
.month-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.month-header {
  background: linear-gradient(135deg, var(--bg-raised) 0%, var(--bg-card) 100%);
  border-bottom: 1px solid rgba(108, 99, 255, 0.2);
  padding: 0.25rem 0;
  flex-shrink: 0;
  text-align: center;
}

.month-header h3 {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--accent-light);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0;
}

/* Day-of-week header row */
.dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dow-cell {
  text-align: center;
  font-size: 0.5rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.15rem 0;
}

/* Day grid */
.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  flex: 1;
  min-height: 0;
}

.day-cell {
  position: relative;
  min-height: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.035);
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
  padding: 1px 2px;
  transition: background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.day-cell:nth-child(7n) {
  border-right: none;
}

.day-cell:hover {
  background: rgba(108, 99, 255, 0.06);
}

.day-cell.empty {
  background: transparent;
  pointer-events: none;
}

.day-cell.today {
  background: rgba(108, 99, 255, 0.12);
}

.day-cell.weekend {
  background: rgba(255, 255, 255, 0.06);
}

.day-cell.weekend .day-num {
  color: var(--text-muted);
}

/* Day number */
.day-num {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1;
}

.day-cell.today .day-num {
  color: var(--accent-primary);
  font-weight: 800;
}

.day-cell.holiday {
  background: color-mix(in srgb, var(--holiday-color, #e05555) 35%, transparent);
  cursor: pointer;
}

.day-cell.holiday:hover {
  background: color-mix(in srgb, var(--holiday-color, #e05555) 50%, transparent);
}

.day-cell.holiday .day-num {
  color: var(--text-primary);
  font-weight: 700;
}


/* ============================================================
   HOLIDAY FLOATING TOOLTIP
   ============================================================ */
.holiday-tooltip {
  position: fixed;
  z-index: 9999;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  box-shadow: var(--shadow-card), var(--shadow-glow);
  max-width: 280px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.holiday-tooltip[hidden] {
  display: none;
}

.holiday-tooltip.visible {
  opacity: 1;
}

.tooltip-date {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.tooltip-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.tooltip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tooltip-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

.tooltip-type {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-left: auto;
  font-weight: 500;
}

/* ============================================================
   STATUS BAR
   ============================================================ */
.status-bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1.75rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-glass);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-bar a {
  color: var(--accent-light);
  text-decoration: none;
  transition: color var(--transition);
}

.status-bar a:hover {
  color: var(--accent-primary);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .calendar-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .navbar {
    height: auto;
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .navbar-controls {
    width: 100%;
    justify-content: flex-start;
  }

  #country-select {
    min-width: 160px;
  }

  .calendar-wrapper {
    padding: 1rem;
  }
}

@media (max-width: 680px) {
  .calendar-grid {
    grid-template-columns: 1fr;
  }

  .navbar-subtitle {
    display: none;
  }

  .navbar-controls {
    gap: 0.75rem;
  }

  #country-select {
    min-width: 130px;
    max-width: 200px;
  }

  .status-powered {
    display: none;
  }

  .calendar-wrapper {
    padding: 0.5rem;
  }
}

/* Loading shimmer overlay */
.calendar-wrapper.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(13, 15, 26, 0.25);
  backdrop-filter: blur(2px);
  border-radius: var(--radius-lg);
  pointer-events: none;
  z-index: 10;
  animation: fade-in 0.15s ease;
}