/* ═══════════════════════════════════════════════════════════════════════════
   ADMIN PANEL — Premium Dark Theme
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Ensure HTML hidden attribute always wins over CSS display rules */
[hidden] { display: none !important; }

:root {
  --bg:          #0b1220;
  --surface:     #111827;
  --surface-2:   #1a2438;
  --surface-3:   #1f2d45;
  --border:      rgba(142,177,209,0.1);
  --border-hover:rgba(142,177,209,0.25);
  --text:        #e2e8f0;
  --text-muted:  #7a93b0;
  --text-dim:    #4a6080;
  --accent:      #8EB1D1;
  --accent-glow: rgba(142,177,209,0.15);
  --green:       #4ade80;
  --green-glow:  rgba(74,222,128,0.15);
  --red:         #f87171;
  --red-glow:    rgba(248,113,113,0.15);
  --purple:      #a78bfa;
  --purple-glow: rgba(167,139,250,0.15);
  --font-ui:     'Inter', system-ui, sans-serif;
  --font-script: 'Great Vibes', cursive;
  --font-serif:  'Cormorant Garamond', Georgia, serif;
  --radius:      12px;
  --radius-lg:   18px;
  --sidebar-w:   240px;
  --topbar-h:    60px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --transition:  0.2s ease;
}

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

/* ─── LOGIN VIEW ──────────────────────────────────────────────────────────── */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 20% 50%, #0d1e38 0%, #0b1220 60%);
}

.login-bg { position: absolute; inset: 0; pointer-events: none; }

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: orb-drift 8s ease-in-out infinite alternate;
}
.login-orb--1 { width: 400px; height: 400px; background: #1C2B48; top: -100px; left: -100px; animation-duration: 9s; }
.login-orb--2 { width: 300px; height: 300px; background: #8EB1D1; bottom: -80px; right: -80px; animation-duration: 11s; opacity: 0.15; }
.login-orb--3 { width: 200px; height: 200px; background: #243555; top: 50%; left: 55%; animation-duration: 7s; }

@keyframes orb-drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(30px, 20px) scale(1.08); }
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 48px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
}

.login-header { text-align: center; margin-bottom: 36px; }

.login-cursive {
  font-family: var(--font-script);
  font-size: 2.4rem;
  color: var(--accent);
  line-height: 1.2;
  margin-bottom: 4px;
}

.login-date {
  font-family: var(--font-serif);
  font-size: 0.82rem;
  letter-spacing: 0.3em;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.login-divider {
  width: 48px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  margin: 0 auto 20px;
}

.login-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 6px;
}

.login-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Fields */
.field-group { margin-bottom: 20px; }

.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.field-icon {
  position: absolute;
  left: 14px;
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}

.field-input {
  width: 100%;
  padding: 12px 44px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.field-input::placeholder { color: var(--text-dim); }
.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field-toggle {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  padding: 4px;
  transition: color var(--transition);
}
.field-toggle:hover { color: var(--accent); }
.field-toggle svg { width: 16px; height: 16px; }

.field-error {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--red);
  min-height: 18px;
}

/* Login button */
.login-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, #6a9ec4 100%);
  color: #0b1220;
  font-family: var(--font-ui);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.login-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(142,177,209,0.35);
}
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.login-btn__spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(11,18,32,0.3);
  border-top-color: #0b1220;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.login-btn.is-loading .login-btn__spinner { display: block; }
.login-btn.is-loading .login-btn__text { opacity: 0.7; }

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

.login-back {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.login-back svg { width: 14px; height: 14px; }
.login-back:hover { color: var(--accent); }

/* ─── DASHBOARD LAYOUT ────────────────────────────────────────────────────── */
.dashboard {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 28px 20px 24px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.sidebar-cursive {
  font-family: var(--font-script);
  font-size: 2rem;
  color: var(--accent);
  line-height: 1.2;
}

.sidebar-wedding {
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  margin-top: 2px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-align: left;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(142,177,209,0.15);
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 26px;
  border: none;
  border-top: 1px solid var(--border);
  background: none;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}
.sidebar-logout svg { width: 16px; height: 16px; }
.sidebar-logout:hover { color: var(--red); background: var(--red-glow); }

/* Topbar (mobile) */
.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 101;
}

.topbar-burger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}
.topbar-burger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: all 0.2s;
}
.topbar-burger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.topbar-burger.is-open span:nth-child(2) { opacity: 0; }
.topbar-burger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.topbar-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text);
}

.topbar-logout {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 6px;
  display: flex;
  align-items: center;
}
.topbar-logout svg { width: 18px; height: 18px; }
.topbar-logout:hover { color: var(--red); }

/* Main content */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 36px 40px;
  max-width: calc(1280px + var(--sidebar-w));
}

/* Views */
.view { display: none; }
.view.active { display: block; animation: fade-in 0.3s ease; }

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

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-serif);
  font-size: 1.9rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.2;
}

.page-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.page-badge {
  font-size: 0.72rem;
  color: var(--text-dim);
  padding-top: 6px;
}

/* ─── STAT CARDS ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); }

.stat-card--blue  { border-left: 3px solid var(--accent); }
.stat-card--blue:hover  { box-shadow: 0 8px 32px var(--accent-glow); border-color: rgba(142,177,209,0.4); }

.stat-card--green { border-left: 3px solid var(--green); }
.stat-card--green:hover { box-shadow: 0 8px 32px var(--green-glow); border-color: rgba(74,222,128,0.3); }

.stat-card--red   { border-left: 3px solid var(--red); }
.stat-card--red:hover   { box-shadow: 0 8px 32px var(--red-glow); border-color: rgba(248,113,113,0.3); }

.stat-card--purple{ border-left: 3px solid var(--purple); }
.stat-card--purple:hover{ box-shadow: 0 8px 32px var(--purple-glow); border-color: rgba(167,139,250,0.3); }

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-card--blue   .stat-icon { background: var(--accent-glow);  color: var(--accent); }
.stat-card--green  .stat-icon { background: var(--green-glow);   color: var(--green); }
.stat-card--red    .stat-icon { background: var(--red-glow);     color: var(--red); }
.stat-card--purple .stat-icon { background: var(--purple-glow);  color: var(--purple); }
.stat-icon svg { width: 20px; height: 20px; }

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

/* ─── CHART CARD ──────────────────────────────────────────────────────────── */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.chart-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 24px;
}

.chart-body {
  display: flex;
  align-items: center;
  gap: 40px;
  flex-wrap: wrap;
}

.donut-wrap { flex-shrink: 0; }
.donut-svg { width: 160px; height: 160px; }

.chart-legend { flex: 1; min-width: 180px; }

.legend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

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

.legend-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.legend-val {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--text);
  line-height: 1;
}

.progress-wrap { margin-top: 8px; }

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #6a9ec4);
  border-radius: 99px;
  width: 0%;
  transition: width 1.2s cubic-bezier(.4,0,.2,1);
}

/* ─── RSVP TABLE VIEW ─────────────────────────────────────────────────────── */
.search-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 11px 40px 11px 42px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input::placeholder { color: var(--text-dim); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 4px;
  transition: color var(--transition);
}
.search-clear:hover { color: var(--red); }

.export-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  background: var(--accent-glow);
  border: 1px solid rgba(142,177,209,0.25);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  white-space: nowrap;
}
.export-btn svg { width: 15px; height: 15px; }
.export-btn:hover { background: rgba(142,177,209,0.22); transform: translateY(-1px); }

.table-count {
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.state-loading, .state-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.state-empty__icon { font-size: 2.5rem; }
.state-empty__msg  { font-family: var(--font-serif); font-size: 1.2rem; color: var(--text); }
.state-empty__sub  { font-size: 0.82rem; color: var(--text-dim); text-align: center; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.rsvp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.rsvp-table thead {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.rsvp-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.rsvp-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.rsvp-table tbody tr:last-child { border-bottom: none; }
.rsvp-table tbody tr:hover { background: var(--surface-2); }

.rsvp-table td {
  padding: 13px 16px;
  color: var(--text);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rsvp-table td.td-email  { color: var(--text-muted); font-size: 0.8rem; }
.rsvp-table td.td-ts     { color: var(--text-dim);   font-size: 0.78rem; }
.rsvp-table td.td-dietary,
.rsvp-table td.td-menu-choices,
.rsvp-table td.td-message { max-width: 140px; color: var(--text-muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge--yes { background: var(--green-glow); color: var(--green); border: 1px solid rgba(74,222,128,0.25); }
.badge--no  { background: var(--red-glow);   color: var(--red);   border: 1px solid rgba(248,113,113,0.25); }

.delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color var(--transition), background var(--transition);
}
.delete-btn svg { width: 15px; height: 15px; }
.delete-btn:hover { color: var(--red); background: var(--red-glow); }

/* ─── MODAL ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  animation: fade-in 0.2s ease;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  animation: slide-up 0.25s ease;
}

@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.modal-icon {
  width: 52px;
  height: 52px;
  background: var(--red-glow);
  border: 1px solid rgba(248,113,113,0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: var(--red);
}
.modal-icon svg { width: 22px; height: 22px; }

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 10px;
}

.modal-body {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 28px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-cancel {
  padding: 11px 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.modal-cancel:hover { background: var(--surface-3); color: var(--text); }

.modal-confirm {
  padding: 11px 24px;
  background: var(--red-glow);
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: var(--radius);
  color: var(--red);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.modal-confirm:hover:not(:disabled) { background: rgba(248,113,113,0.2); transform: translateY(-1px); }
.modal-confirm:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .topbar { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    top: var(--topbar-h);
  }
  .sidebar.is-open { transform: translateX(0); box-shadow: 8px 0 32px rgba(0,0,0,0.5); }

  .main {
    margin-left: 0;
    padding: 80px 16px 24px;
  }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .chart-body { flex-direction: column; align-items: flex-start; gap: 24px; }

  .page-header { flex-direction: column; }

  .search-row { flex-direction: column; align-items: stretch; }

  .export-btn { justify-content: center; }

  .rsvp-table { font-size: 0.78rem; }
  .rsvp-table th, .rsvp-table td { padding: 10px 10px; }
}

@media (max-width: 480px) {
  .login-card { padding: 36px 24px; }
  .stats-grid { grid-template-columns: 1fr; }
}
