/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font-ui: 'Outfit', system-ui, sans-serif;
  --font-mono: 'Space Mono', 'Courier New', monospace;

  /* Dark theme (default) */
  --bg-base:        #0d0e12;
  --bg-surface:     #13151c;
  --bg-elevated:    #1a1d28;
  --bg-glass:       rgba(255,255,255,0.04);
  --bg-glass-hover: rgba(255,255,255,0.07);
  --bg-input:       rgba(255,255,255,0.06);

  --text-primary:   #f0f5f1;
  --text-secondary: #8b8fa8;
  --text-muted:     #4d5168;

  --border-subtle:  rgba(255,255,255,0.07);
  --border-medium:  rgba(255,255,255,0.12);
  --border-strong:  rgba(255,255,255,0.2);

  --accent:         #f59e0b;
  --accent-dim:     rgba(245,158,11,0.15);
  --accent-glow:    rgba(245,158,11,0.3);

  --success:        #10b981;
  --success-dim:    rgba(16,185,129,0.15);
  --danger:         #ef4444;
  --danger-dim:     rgba(239,68,68,0.15);

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  22px;

  --shadow-card: 0 4px 24px rgba(0,0,0,0.4), 0 1px 4px rgba(0,0,0,0.3);
  --shadow-modal: 0 24px 64px rgba(0,0,0,0.6);

  --transition: 0.18s cubic-bezier(0.4,0,0.2,1);
  --transition-slow: 0.35s cubic-bezier(0.4,0,0.2,1);
}

[data-theme="light"] {
  --bg-base:        #f8f6f4;
  --bg-surface:     #ffffff;
  --bg-elevated:    #f9f9fc;
  --bg-glass:       rgba(0,0,0,0.03);
  --bg-glass-hover: rgba(0,0,0,0.05);
  --bg-input:       rgba(0,0,0,0.05);

  --text-primary:   #111218;
  --text-secondary: #5c5f7a;
  --text-muted:     #9498b2;

  --border-subtle:  rgba(0,0,0,0.06);
  --border-medium:  rgba(0,0,0,0.1);
  --border-strong:  rgba(0,0,0,0.18);

  --accent-dim:     rgba(245,158,11,0.1);
  --accent-glow:    rgba(245,158,11,0.25);

  --success-dim:    rgba(16,185,129,0.1);
  --danger-dim:     rgba(239,68,68,0.1);

  --shadow-card: 0 4px 20px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-modal: 0 24px 64px rgba(0,0,0,0.2);
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-ui);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  transition: background var(--transition-slow), color var(--transition-slow);
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ─── Header ─── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(13,14,18,0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
}
[data-theme="light"] .site-header {
  background: rgba(255,255,255,0.88);
}
.header-inner {
  max-width: 1400px; margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex; align-items: center; gap: 16px;
}

/* Brand */
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-ui); font-weight: 700;
  font-size: 1.2rem; color: var(--text-primary);
  white-space: nowrap;
}
.brand-icon { width: 28px; height: 28px; color: var(--accent); }
.brand-name { letter-spacing: -0.02em; }
.brand-name .accent { color: var(--accent); }

/* Header Nav */
.header-nav { display: flex; gap: 4px; margin-left: auto; }
.nav-filter {
  background: none; border: none; cursor: pointer;
  padding: 6px 14px; border-radius: 99px;
  font-family: var(--font-ui); font-size: 0.85rem; font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.nav-filter:hover { color: var(--text-primary); background: var(--bg-glass); }
.nav-filter.active {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-glow);
}

/* Header Actions */
.header-actions { display: flex; align-items: center; gap: 10px; }

/* Search */
.search-wrap {
  position: relative; display: flex; align-items: center;
}
.search-icon {
  position: absolute; left: 10px;
  width: 16px; height: 16px; color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 99px;
  padding: 7px 14px 7px 34px;
  font-family: var(--font-ui); font-size: 0.85rem;
  color: var(--text-primary);
  width: 220px;
  transition: all var(--transition);
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  outline: none; width: 260px;
  border-color: var(--accent); background: var(--bg-input);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Theme Toggle */
.theme-toggle {
  background: var(--bg-glass); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); padding: 7px;
  cursor: pointer; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  width: 36px; height: 36px;
}
.theme-toggle:hover { color: var(--text-primary); border-color: var(--border-medium); }
.icon-sun, .icon-moon { width: 18px; height: 18px; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius-md);
  font-family: var(--font-ui); font-size: 0.875rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #111;
}
.btn-primary:hover { background: #fbbf24; box-shadow: 0 4px 16px var(--accent-glow); }

.btn-ghost {
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-medium); }

.btn-danger {
  background: var(--danger); color: white;
}
.btn-danger:hover { background: #dc2626; }

/* ─── Stats Bar ─── */
.stats-bar {
  max-width: 1400px; margin: 0 auto;
  padding: 12px 24px;
  display: flex; align-items: center; gap: 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.stat-item { display: flex; align-items: center; gap: 8px; }
.stat-num {
  font-family: var(--font-mono); font-size: 1.1rem; font-weight: 700;
  color: var(--text-primary);
}
.stat-num.upcoming { color: var(--success); }
.stat-num.expired { color: var(--text-muted); }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); }
.stat-divider { width: 1px; height: 20px; background: var(--border-subtle); }

.sort-item { margin-left: auto; gap: 8px; }
.sort-select {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-family: var(--font-ui); font-size: 0.82rem;
  color: var(--text-primary); cursor: pointer;
  transition: border-color var(--transition);
}
.sort-select:focus { outline: none; border-color: var(--accent); }
.sort-select option { background: var(--bg-surface); }

/* ─── Main Content & Grid ─── */
.main-content {
  max-width: 1400px; margin: 0 auto;
  padding: 28px 24px 80px;
}
.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

/* ─── Event Card ─── */
.event-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 22px 22px 18px;
  position: relative; overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  animation: cardIn 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
  cursor: default;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.event-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
  border-color: var(--border-medium);
}
.event-card.expired { opacity: 0.75; }
.event-card.expired:hover { opacity: 1; }

/* Card accent strip */
.card-accent-strip {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

/* Card Header */
.card-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.card-meta { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.card-category {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.72rem; font-weight: 600;
  padding: 3px 9px; border-radius: 99px;
  background: var(--bg-glass);
  color: var(--text-secondary);
  letter-spacing: 0.04em; text-transform: uppercase;
  width: fit-content;
}
.card-title {
  font-size: 1.05rem; font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.card-btn {
  background: none; border: none; cursor: pointer;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
}
.card-btn:hover { background: var(--bg-glass-hover); color: var(--text-primary); }
.card-btn.delete:hover { background: var(--danger-dim); color: var(--danger); }
.card-btn svg { width: 15px; height: 15px; }

/* Countdown Display */
.countdown-display {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; margin-bottom: 14px;
}
.countdown-unit {
  display: flex; flex-direction: column; align-items: center;
  background: var(--bg-glass);
  border-radius: var(--radius-md);
  padding: 10px 4px 8px;
  border: 1px solid var(--border-subtle);
  position: relative; overflow: hidden;
}
.countdown-unit::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--unit-color, var(--accent)), transparent);
}
.countdown-num {
  font-family: var(--font-mono);
  font-size: 1.65rem; font-weight: 700;
  color: var(--unit-color, var(--accent));
  line-height: 1;
  letter-spacing: -0.03em;
  transition: color var(--transition);
  min-height: 1.65rem;
}
.countdown-label {
  font-size: 0.62rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); margin-top: 4px;
}

/* Expired State */
.expired-badge {
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
  font-size: 0.9rem; font-weight: 600;
  color: var(--text-secondary);
}
.expired-badge .badge-icon { font-size: 1.1rem; }

/* Progress Bar */
.progress-wrap { margin-bottom: 12px; }
.progress-header {
  display: flex; justify-content: space-between;
  font-size: 0.72rem; color: var(--text-muted);
  margin-bottom: 5px;
}
.progress-track {
  height: 4px; background: var(--bg-glass);
  border-radius: 99px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 99px;
  background: var(--accent);
  transition: width 1s linear;
}

/* Card Footer */
.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}
.card-date {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.78rem; color: var(--text-secondary);
}
.card-date svg { width: 12px; height: 12px; opacity: 0.6; }
.card-desc {
  font-size: 0.8rem; color: var(--text-secondary); line-height: 1.5;
  margin-bottom: 10px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Notification pill */
.notify-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.7rem; color: var(--text-muted);
  background: var(--bg-glass);
  padding: 2px 8px; border-radius: 99px;
}

/* ─── Empty State ─── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 80px 20px; text-align: center; gap: 12px;
}
.empty-icon {
  width: 80px; height: 80px; color: var(--text-muted);
  margin-bottom: 8px;
  animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.05); }
}
.empty-state h3 { font-size: 1.2rem; font-weight: 600; color: var(--text-primary); }
.empty-state p { font-size: 0.9rem; color: var(--text-secondary); max-width: 300px; }

.hidden { display: none !important; }

/* ─── Modal ─── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.modal {
  position: fixed; z-index: 201;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(1);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  animation: modalIn 0.3s cubic-bezier(0.34,1.4,0.64,1);
}
@keyframes modalIn {
  from { opacity:0; transform: translate(-50%,-52%) scale(0.94); }
  to   { opacity:1; transform: translate(-50%,-50%) scale(1); }
}
.modal-sm { width: min(420px, calc(100vw - 32px)); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.modal-title { font-size: 1.15rem; font-weight: 700; }
.modal-close {
  background: var(--bg-glass); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary);
  transition: all var(--transition);
}
.modal-close:hover { color: var(--text-primary); border-color: var(--border-medium); }

/* Form */
.form-row { margin-bottom: 16px; }
.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-label {
  font-size: 0.82rem; font-weight: 600;
  color: var(--text-secondary); letter-spacing: 0.02em;
}
.req { color: var(--accent); }
.optional { color: var(--text-muted); font-weight: 400; }
.form-input {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-family: var(--font-ui); font-size: 0.9rem;
  color: var(--text-primary);
  transition: all var(--transition);
  width: 100%;
}
.form-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-error { font-size: 0.78rem; color: var(--danger); min-height: 1.1em; }
.char-count { font-size: 0.72rem; color: var(--text-muted); text-align: right; }

/* Color Picker */
.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
  outline: none;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: var(--text-primary); transform: scale(1.15); }

/* Toggle */
.toggle-label {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none;
  font-size: 0.85rem; color: var(--text-secondary);
}
.toggle-wrap { position: relative; }
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  display: block; width: 40px; height: 22px;
  background: var(--bg-input); border-radius: 99px;
  border: 1px solid var(--border-medium);
  position: relative; cursor: pointer;
  transition: background var(--transition);
}
.toggle-track::after {
  content: ''; position: absolute;
  left: 3px; top: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-muted);
  transition: all var(--transition);
}
.toggle-input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle-input:checked + .toggle-track::after {
  transform: translateX(18px); background: #111;
}

.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 24px; padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}

/* Delete Modal */
.delete-msg {
  font-size: 0.9rem; color: var(--text-secondary); line-height: 1.6;
  margin-bottom: 8px;
}
.delete-msg strong { color: var(--text-primary); }

/* ─── FAB Group ─── */
.fab-group {
  position: fixed; bottom: 28px; right: 28px;
  display: flex; flex-direction: column; gap: 10px; z-index: 50;
}
.fab {
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-medium);
  border-radius: 50%; cursor: pointer;
  background: var(--bg-elevated); color: var(--text-secondary);
  transition: all var(--transition);
  box-shadow: var(--shadow-card);
}
.fab-sm { width: 44px; height: 44px; }
.fab:hover { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border-strong); transform: translateY(-2px); }

/* ─── Celebration Overlay ─── */
.celebration-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(8px);
}
.confetti-container {
  position: absolute; inset: 0;
  pointer-events: none; overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  from { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  to   { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}
.celebration-msg {
  position: relative; z-index: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: 40px 48px;
  text-align: center;
  box-shadow: var(--shadow-modal);
  animation: modalIn 0.5s cubic-bezier(0.34,1.4,0.64,1);
}
.celebration-icon { font-size: 3rem; margin-bottom: 16px; }
.celebration-msg h2 { font-size: 1.5rem; margin-bottom: 8px; }
.celebration-msg p { color: var(--text-secondary); margin-bottom: 24px; }

/* ─── Tick Animation ─── */
.tick {
  animation: tickFlash 0.2s ease;
}
@keyframes tickFlash {
  0%  { transform: scale(1); }
  50% { transform: scale(1.15); }
  100%{ transform: scale(1); }
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .header-inner { gap: 10px; padding: 0 16px; }
  .header-nav { display: none; }
  .search-input { width: 160px; }
  .search-input:focus { width: 180px; }
  .main-content { padding: 20px 16px 80px; }
  .events-grid { grid-template-columns: 1fr; }
  .stats-bar { padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
  .form-row.two-col { grid-template-columns: 1fr; }
  .celebration-msg { padding: 28px 24px; }
  .btn-primary span.btn-label { display: none; }
}

@media (max-width: 480px) {
  .brand-name { display: none; }
  .modal { padding: 20px; }
}

/* ─── Date Input Styling ─── */
input[type="date"], input[type="time"] {
  color-scheme: dark;
}
[data-theme="light"] input[type="date"],
[data-theme="light"] input[type="time"] {
  color-scheme: light;
}