/* ==========================================================================
   1. THEME VARIABLES
   ========================================================================== */
:root {
  /* Light Theme Layout */
  --bg-color: #f0f4f8;
  --card-bg: rgba(255, 255, 255, 0.75);
  --text-main: #334155;
  --text-muted: #64748b;
  --border-color: #e2e8f0;

  /* Vibrant Light Theme Pills */
  --boy-bg: #e0f2fe;
  --boy-text: #0284c7;
  --boy-border: #7dd3fc;

  --girl-bg: #fce7f3;
  --girl-text: #db2777;
  --girl-border: #f9a8d4;

  --neutral-bg: #dcfce7;
  --neutral-text: #15803d;
  --neutral-border: #86efac;

  /* Gradients & Shadows */
  --primary-btn: linear-gradient(135deg, #38bdf8, #f472b6);
  --primary-btn-hover: linear-gradient(135deg, #0ea5e9, #ec4899);
  --card-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
  --pill-shadow: 0 4px 0px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
  /* Dark Theme Layout */
  --bg-color: #0f172a;
  --card-bg: rgba(30, 41, 59, 0.75);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;

  /* Glowing Dark Theme Pills */
  --boy-bg: rgba(59, 130, 246, 0.15);
  --boy-text: #60a5fa;
  --boy-border: rgba(59, 130, 246, 0.4);

  --girl-bg: rgba(236, 72, 153, 0.15);
  --girl-text: #f472b6;
  --girl-border: rgba(236, 72, 153, 0.4);

  --neutral-bg: rgba(34, 197, 94, 0.15);
  --neutral-text: #4ade80;
  --neutral-border: rgba(34, 197, 94, 0.4);

  /* Gradients & Shadows */
  --primary-btn: linear-gradient(135deg, #0284c7, #db2777);
  --primary-btn-hover: linear-gradient(135deg, #0369a1, #be185d);
  --card-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  --pill-shadow: 0 4px 0px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   2. BASE & LAYOUT
   ========================================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Quicksand', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  transition: background-color 0.4s ease;
  min-height: 100vh;
  padding: 2rem 1rem;
  display: flex;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
}

.app-container { width: 100%; max-width: 600px; z-index: 1; }

.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.brand { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.5px; }

/* --- Floating Background Blobs --- */
.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  z-index: -1;
  animation: float 20s infinite alternate ease-in-out;
  opacity: 0.7;
}

.blob-1 { width: 300px; height: 300px; background: #bae6fd; top: -50px; left: -50px; }
.blob-2 { width: 400px; height: 400px; background: #fbcfe8; bottom: -100px; right: -100px; animation-delay: -5s; }
.blob-3 { width: 250px; height: 250px; background: #bbf7d0; top: 40%; left: 50%; animation-delay: -10s; }
[data-theme="dark"] .blob { opacity: 0.15; }

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(50px, 50px) scale(1.1); }
}

/* ==========================================================================
   3. CARDS & CONTAINERS
   ========================================================================== */
.card {
  background: var(--card-bg); 
  backdrop-filter: blur(16px); 
  -webkit-backdrop-filter: blur(16px);
  border-radius: 28px; 
  padding: 2.5rem; 
  box-shadow: var(--card-shadow);
  margin-bottom: 2rem; 
  border: 1px solid rgba(255, 255, 255, 0.2); 
  transition: background 0.4s, border 0.4s;
}
[data-theme="dark"] .card { border: 1px solid rgba(255, 255, 255, 0.05); }

.card h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 1.2rem; display: flex; align-items: center; gap: 0.5rem; }

/* ==========================================================================
   4. FORMS, INPUTS & BUTTONS
   ========================================================================== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.inline-form { display: flex; gap: 0.75rem; }
.input-group label { display: block; font-weight: 700; margin-bottom: 0.5rem; font-size: 0.95rem; color: var(--text-muted); }

input[type="text"], input[type="number"], input[type="password"], select {
  flex: 1; padding: 0.85rem 1.2rem; border: 2px solid var(--border-color);
  border-radius: 16px; background: var(--bg-color); color: var(--text-main);
  font-family: inherit; font-size: 1.05rem; font-weight: 600; outline: none; transition: all 0.2s;
}

input:focus, select:focus { 
  border-color: #38bdf8; 
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.2); 
}

/* --- Custom Select Arrows to Fix Browser Overlap --- */
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: right 1rem center; background-size: 1.2rem;
  padding-right: 2.8rem !important; cursor: pointer;
}

/* --- Buttons --- */
.btn {
  padding: 0.85rem 1.5rem; border: none; border-radius: 16px;
  font-family: inherit; font-weight: 800; font-size: 1.05rem; cursor: pointer;
  transition: all 0.15s ease; box-shadow: 0 4px 0px rgba(0,0,0,0.1);
}

.btn:active { transform: translateY(4px); box-shadow: 0 0px 0px rgba(0,0,0,0.1); }
.btn-primary { background: var(--primary-btn); color: white; box-shadow: 0 4px 0px rgba(190, 24, 93, 0.3); }
.btn-primary:active { box-shadow: 0 0px 0px rgba(190, 24, 93, 0.3); }
.btn-neutral { background: var(--border-color); color: var(--text-main); }
.full-width { width: 100%; margin-top: 1.5rem; }

.theme-btn {
  background: var(--card-bg); border: 1px solid var(--border-color); font-size: 1.2rem; 
  padding: 0.6rem; border-radius: 16px; cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05); transition: transform 0.2s; backdrop-filter: blur(10px);
}
.theme-btn:hover { transform: scale(1.1) rotate(15deg); }

/* ==========================================================================
   5. COMPONENTS (Pills, Banners, Alerts, Modals)
   ========================================================================== */

/* --- Navigation Bar --- */
.nav-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem;
}
.nav-links { display: flex; gap: 1.2rem; align-items: center; }
.nav-links a { font-weight: 700; text-decoration: none; color: var(--text-muted); transition: color 0.2s; font-size: 1.05rem; }
.nav-links a:hover, .nav-links a.active { color: var(--text-main); }

/* --- A-Z Stats Table --- */
.stats-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.stats-table th, .stats-table td { padding: 1rem; text-align: center; border-bottom: 1px solid var(--border-color); }
.stats-table th { font-weight: 800; color: var(--text-muted); font-size: 0.95rem; text-transform: uppercase; }
.stats-table td.letter { font-weight: 800; font-size: 1.4rem; color: var(--text-main); }
.stats-table tr:hover { background-color: rgba(125, 211, 252, 0.05); }

/* --- Animated Names Grid & Pills --- */
.names-grid { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 2rem; justify-content: center; }
.name-pill {
  padding: 0.7rem 1.4rem; border-radius: 99px; font-weight: 700; font-size: 1.15rem;
  border: 2px solid transparent; cursor: pointer; transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: var(--pill-shadow); opacity: 0; transform: scale(0.8) translateY(10px);
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.name-pill:hover { transform: scale(1.05) translateY(-3px); z-index: 2; }
.name-pill:active { transform: scale(0.98) translateY(2px); box-shadow: 0 0px 0px rgba(0,0,0,0); }

.theme-boy { background-color: var(--boy-bg); color: var(--boy-text); border-color: var(--boy-border); }
.theme-girl { background-color: var(--girl-bg); color: var(--girl-text); border-color: var(--girl-border); }
.theme-neutral { background-color: var(--neutral-bg); color: var(--neutral-text); border-color: var(--neutral-border); }

/* --- Stats Banner --- */
.stats-banner { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-bottom: 2rem; justify-content: center; }
.stat-badge {
  padding: 0.5rem 1rem; border-radius: 99px; font-size: 0.95rem; font-weight: 800;
  border: 2px solid transparent; display: flex; align-items: center; gap: 0.4rem; box-shadow: var(--pill-shadow);
}
.pending-badge { background-color: #fef3c7; color: #b45309; border-color: #fde68a; }
[data-theme="dark"] .pending-badge { background-color: rgba(245, 158, 11, 0.2); color: #fcd34d; border-color: rgba(245, 158, 11, 0.4); }

/* --- Alerts & Submit Boxes --- */
.alert { padding: 1.2rem; border-radius: 16px; margin-bottom: 1.5rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.alert.success { background: #dcfce7; color: #15803d; border: 2px solid #bbf7d0; }
[data-theme="dark"] .alert.success { background: rgba(22, 163, 74, 0.2); color: #4ade80; border-color: rgba(22, 163, 74, 0.4); }
.alert.error { background: #fee2e2; color: #b91c1c; border: 2px solid #fecaca; }
[data-theme="dark"] .alert.error { background: rgba(220, 38, 38, 0.2); color: #f87171; border-color: rgba(220, 38, 38, 0.4); }

.submit-box { margin-top: 1.5rem; padding: 1.5rem; background: var(--bg-color); border-radius: 20px; border: 2px dashed var(--border-color); }
.submit-box p { margin-bottom: 1.2rem; font-size: 1rem; }

/* --- Modals --- */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 1000; display: flex; justify-content: center; align-items: center; padding: 1rem;
}
.modal-content { position: relative; max-width: 450px; width: 100%; margin-bottom: 0; text-align: center; }
.close-btn {
  position: absolute; top: 1rem; right: 1.5rem; background: transparent; border: none;
  font-size: 2rem; color: var(--text-muted); cursor: pointer; transition: color 0.2s; line-height: 1;
}
.close-btn:hover { color: var(--text-main); }

/* --- Hover Tooltips for Names --- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip); position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%) translateY(5px);
  background: var(--text-main); color: var(--bg-color); padding: 0.5rem 0.8rem; border-radius: 12px;
  font-size: 0.9rem; font-weight: 700; white-space: nowrap; opacity: 0; visibility: hidden;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); box-shadow: 0 4px 15px rgba(0,0,0,0.15); z-index: 10; pointer-events: none;
}
[data-tooltip]::before {
  content: ''; position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%) translateY(5px);
  border-width: 6px; border-style: solid; border-color: var(--text-main) transparent transparent transparent;
  opacity: 0; visibility: hidden; transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); z-index: 10; pointer-events: none;
}
[data-tooltip]:hover::after, [data-tooltip]:hover::before { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* ==========================================================================
   6. ANIMATIONS & RESPONSIVE
   ========================================================================== */
@keyframes popIn { to { opacity: 1; transform: scale(1) translateY(0); } }
.pop-in { animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }

@media (max-width: 500px) {
  .inline-form { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .card { padding: 1.5rem; }
}