/* ============================================================
   Science Fair Platform — Main Stylesheet
   ============================================================ */

:root {
  --bg-primary:   #070d1a;
  --bg-secondary: #0d1526;
  --bg-card:      #111827;
  --bg-card-hover:#161f30;
  --border:       rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.15);

  --text-primary:   #f0f4ff;
  --text-secondary: #94a3b8;
  --text-muted:     #4b5563;

  --accent:       #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow:  rgba(59,130,246,0.25);

  --physics:  #f59e0b;
  --biology:  #22c55e;
  --chemistry:#ef4444;
  --cs:       #8b5cf6;

  --physics-bg:  rgba(245,158,11,0.12);
  --biology-bg:  rgba(34,197,94,0.12);
  --chemistry-bg:rgba(239,68,68,0.12);
  --cs-bg:       rgba(139,92,246,0.12);

  --radius:    12px;
  --radius-lg: 20px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.5);
  --transition: 0.2s ease;
  --font:      'Inter', system-ui, sans-serif;
  --font-head: 'Space Grotesk', 'Inter', system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Typography ── */
h1,h2,h3,h4,h5 { font-family: var(--font-head); font-weight: 700; line-height: 1.2; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); }
h3 { font-size: 1.25rem; }
p  { color: var(--text-secondary); }
a  { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ── Layout ── */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.section { padding: 64px 0; }

/* ── Navbar ── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(7,13,26,0.92);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.nav-container {
  max-width: 1200px; margin: 0 auto;
  padding: 0 24px;
  display: flex; align-items: center; gap: 32px;
  height: 64px;
}
.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-head); font-weight: 700;
  font-size: 1.1rem; color: var(--text-primary);
  text-decoration: none; flex-shrink: 0;
}
.brand-icon { font-size: 1.4rem; }
.brand-text { color: var(--text-primary); }
.nav-links {
  display: flex; align-items: center; gap: 4px; margin-left: auto;
}
.nav-link {
  color: var(--text-secondary); font-size: 0.9rem; font-weight: 500;
  padding: 8px 14px; border-radius: 8px;
  transition: all var(--transition);
}
.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
  background: rgba(255,255,255,0.07);
}
.nav-user { display: flex; align-items: center; gap: 10px; margin-left: 12px; }
.user-badge {
  font-size: 0.8rem; font-weight: 600; padding: 4px 10px;
  border-radius: 20px; border: 1px solid;
}
.user-badge.admin   { color: var(--physics); border-color: var(--physics); background: var(--physics-bg); }
.user-badge.teacher { color: var(--biology); border-color: var(--biology); background: var(--biology-bg); }
.logout-link { color: var(--text-muted) !important; font-size: 0.85rem; }
.logout-link:hover { color: var(--chemistry) !important; background: none !important; }
.nav-btn {
  background: var(--accent); color: #fff !important;
  padding: 8px 18px; border-radius: 8px; font-weight: 600; font-size: 0.9rem;
  transition: background var(--transition), box-shadow var(--transition);
}
.nav-btn:hover { background: var(--accent-hover); box-shadow: 0 0 20px var(--accent-glow); }
.nav-toggle {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 4px; margin-left: auto;
}
.nav-toggle span {
  display: block; width: 22px; height: 2px;
  background: var(--text-primary); border-radius: 2px;
  transition: all 0.3s;
}

/* ── Flash Messages ── */
.flash-message {
  position: fixed; top: 72px; right: 20px; z-index: 200;
  padding: 14px 20px; border-radius: var(--radius);
  font-weight: 500; font-size: 0.9rem;
  display: flex; align-items: center; gap: 12px;
  animation: slideIn 0.3s ease;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.flash-success { background: #052e16; border: 1px solid #166534; color: #86efac; }
.flash-error   { background: #1c0707; border: 1px solid #991b1b; color: #fca5a5; }
.flash-info    { background: #0c1a3a; border: 1px solid #1d4ed8; color: #93c5fd; }
.flash-close   { background: none; border: none; cursor: pointer; color: inherit; font-size: 1.2rem; line-height: 1; padding: 0; }
@keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: none; } }

/* ── Main Content ── */
.main-content { min-height: calc(100vh - 64px - 80px); }

/* ── Hero Section ── */
.hero {
  position: relative; overflow: hidden;
  padding: 100px 24px 80px;
  text-align: center;
}
.hero-bg {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 60% 60% at 20% 30%, rgba(59,130,246,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 50% 50% at 80% 70%, rgba(139,92,246,0.10) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 50% 0%, rgba(245,158,11,0.06) 0%, transparent 60%);
}
.hero-orb {
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: 0.15; z-index: 0;
  animation: float 8s ease-in-out infinite;
}
.hero-orb-1 { width: 500px; height: 500px; background: var(--accent); top: -200px; left: -150px; }
.hero-orb-2 { width: 400px; height: 400px; background: var(--cs); bottom: -150px; right: -100px; animation-delay: -4s; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-20px); } }

.hero-content { position: relative; z-index: 1; max-width: 800px; margin: 0 auto; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(59,130,246,0.12); border: 1px solid rgba(59,130,246,0.25);
  color: var(--accent); padding: 6px 14px; border-radius: 20px;
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  margin-bottom: 24px;
}
.hero h1 { margin-bottom: 20px; letter-spacing: -0.02em; }
.hero h1 span { color: var(--accent); }
.hero p { font-size: 1.15rem; color: var(--text-secondary); max-width: 600px; margin: 0 auto 40px; }
.hero-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px; border-radius: 10px;
  font-weight: 600; font-size: 0.95rem;
  cursor: pointer; border: none; transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
}
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 0 30px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); color: #fff; }
.btn-outline {
  background: transparent; color: var(--text-primary);
  border: 1px solid var(--border-hover);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.btn-sm { padding: 7px 14px; font-size: 0.85rem; border-radius: 8px; }
.btn-danger { background: var(--chemistry); color: #fff; }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); color: #fff; }
.btn-success { background: var(--biology); color: #fff; }
.btn-success:hover { background: #16a34a; transform: translateY(-1px); color: #fff; }
.btn-ghost {
  background: rgba(255,255,255,0.05); color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

/* ── Stats Strip ── */
.stats-strip {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--border);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  margin-top: 60px;
}
.stat-item {
  background: var(--bg-primary); padding: 28px 24px; text-align: center;
}
.stat-number { font-family: var(--font-head); font-size: 2rem; font-weight: 800; color: var(--text-primary); }
.stat-label  { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* ── Section Headers ── */
.section-header { text-align: center; margin-bottom: 48px; }
.section-header h2 { margin-bottom: 12px; }
.section-header p  { max-width: 500px; margin: 0 auto; }

/* ── Category Grid (homepage) ── */
.category-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.category-card {
  padding: 28px 20px; border-radius: var(--radius-lg);
  border: 1px solid var(--border); text-align: center;
  transition: all var(--transition); cursor: default;
  position: relative; overflow: hidden;
}
.category-card:hover { transform: translateY(-4px); border-color: var(--border-hover); box-shadow: var(--shadow); }
.cat-icon  { font-size: 2.5rem; margin-bottom: 12px; }
.cat-name  { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; margin-bottom: 6px; }
.cat-count { font-size: 0.85rem; color: var(--text-muted); }

.category-card.cat-physics   { background: var(--physics-bg); border-color: rgba(245,158,11,0.2); }
.category-card.cat-biology   { background: var(--biology-bg); border-color: rgba(34,197,94,0.2); }
.category-card.cat-chemistry { background: var(--chemistry-bg); border-color: rgba(239,68,68,0.2); }
.category-card.cat-cs        { background: var(--cs-bg); border-color: rgba(139,92,246,0.2); }

.cat-physics   .cat-name { color: var(--physics);  }
.cat-biology   .cat-name { color: var(--biology);  }
.cat-chemistry .cat-name { color: var(--chemistry);}
.cat-cs        .cat-name { color: var(--cs);       }

/* ── Project Cards ── */
.projects-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.project-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px;
  transition: all var(--transition); position: relative; overflow: hidden;
}
.project-card:hover {
  border-color: var(--border-hover); background: var(--bg-card-hover);
  transform: translateY(-3px); box-shadow: var(--shadow);
}
.card-category {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; padding: 4px 10px; border-radius: 20px;
  margin-bottom: 14px; border: 1px solid currentColor;
}
.cat-physics   .card-category, .card-category.cat-physics   { color: var(--physics);   background: var(--physics-bg);   border-color: rgba(245,158,11,0.3); }
.cat-biology   .card-category, .card-category.cat-biology   { color: var(--biology);   background: var(--biology-bg);   border-color: rgba(34,197,94,0.3);  }
.cat-chemistry .card-category, .card-category.cat-chemistry { color: var(--chemistry); background: var(--chemistry-bg); border-color: rgba(239,68,68,0.3);  }
.cat-cs        .card-category, .card-category.cat-cs        { color: var(--cs);        background: var(--cs-bg);        border-color: rgba(139,92,246,0.3); }

.card-table {
  position: absolute; top: 16px; right: 16px;
  font-size: 0.75rem; font-weight: 700; color: var(--text-muted);
  background: rgba(255,255,255,0.05); padding: 3px 8px; border-radius: 6px;
}
.card-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; color: var(--text-primary); }
.card-students { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 10px; }
.card-students span { color: var(--text-muted); margin-right: 4px; }
.card-grade { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 14px; }
.card-description { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 18px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-image { width: 100%; height: 160px; object-fit: cover; border-radius: 10px; margin-bottom: 16px; }
.card-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Filters Bar ── */
.filters-bar {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px;
  margin-bottom: 32px;
  display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
}
.filter-group { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 160px; }
.filter-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.filter-input, .filter-select {
  background: var(--bg-secondary); border: 1px solid var(--border);
  color: var(--text-primary); padding: 9px 14px; border-radius: 8px;
  font-size: 0.9rem; font-family: var(--font);
  transition: border-color var(--transition);
  width: 100%;
}
.filter-input:focus, .filter-select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.filter-select option { background: var(--bg-secondary); }
.filter-actions { display: flex; align-items: flex-end; gap: 8px; }
.results-count { font-size: 0.85rem; color: var(--text-muted); align-self: center; white-space: nowrap; }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 36px;
  max-width: 600px; width: 100%; position: relative;
  animation: slideUp 0.3s ease;
  max-height: 90vh; overflow-y: auto;
}
@keyframes slideUp { from { opacity:0; transform: translateY(20px); } to { opacity:1; transform: none; } }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,0.07); border: 1px solid var(--border);
  color: var(--text-secondary); width: 32px; height: 32px;
  border-radius: 8px; cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--chemistry-bg); color: var(--chemistry); }
.modal-category { margin-bottom: 16px; }
.modal-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 8px; }
.modal-meta { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.modal-meta-item { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text-secondary); }
.modal-meta-item strong { color: var(--text-primary); }
.modal-description { font-size: 0.95rem; line-height: 1.7; color: var(--text-secondary); margin-bottom: 24px; border-top: 1px solid var(--border); padding-top: 20px; }
.modal-image { width: 100%; border-radius: 12px; margin-bottom: 20px; max-height: 280px; object-fit: cover; }

/* ── Forms ── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.form-label.required::after { content: ' *'; color: var(--chemistry); }
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--bg-secondary);
  border: 1px solid var(--border); color: var(--text-primary);
  padding: 11px 16px; border-radius: 10px;
  font-size: 0.95rem; font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-textarea { resize: vertical; min-height: 120px; }
.form-select option { background: var(--bg-secondary); }
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; }
.form-error { font-size: 0.8rem; color: var(--chemistry); margin-top: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── Cards generic ── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px;
}

/* ── Page Header ── */
.page-header {
  padding: 48px 0 36px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}
.page-header h1 { margin-bottom: 8px; }
.page-header p  { max-width: 600px; }
.page-header-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }

/* ── Table ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 12px 16px;
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.data-table tr:last-child td { border-bottom: none; }
.table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }

/* ── Status badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 600; border: 1px solid;
}
.badge-green  { color: var(--biology);   background: var(--biology-bg);   border-color: rgba(34,197,94,0.3);  }
.badge-red    { color: var(--chemistry); background: var(--chemistry-bg); border-color: rgba(239,68,68,0.3);  }
.badge-yellow { color: var(--physics);   background: var(--physics-bg);   border-color: rgba(245,158,11,0.3); }
.badge-purple { color: var(--cs);        background: var(--cs-bg);        border-color: rgba(139,92,246,0.3); }
.badge-blue   { color: var(--accent);    background: var(--accent-glow);  border-color: rgba(59,130,246,0.3); }

/* ── Login page ── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary); padding: 20px;
}
.login-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 48px 40px;
  width: 100%; max-width: 420px;
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .brand-icon { font-size: 3rem; display: block; }
.login-logo h1 { font-size: 1.5rem; margin-top: 12px; }
.login-logo p  { font-size: 0.9rem; color: var(--text-muted); margin-top: 6px; }

/* ── Vote page ── */
.vote-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 36px;
  max-width: 700px; margin: 0 auto;
}
.vote-slot {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px;
  transition: border-color var(--transition);
}
.vote-slot:focus-within { border-color: var(--accent); }
.vote-slot-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.vote-rank {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.9rem; flex-shrink: 0;
}
.vote-rank-1 { background: var(--physics-bg); color: var(--physics); border: 1px solid rgba(245,158,11,0.3); }
.vote-rank-2 { background: rgba(203,213,225,0.1); color: #94a3b8; border: 1px solid rgba(203,213,225,0.2); }
.vote-rank-3 { background: rgba(180,83,9,0.1); color: #d97706; border: 1px solid rgba(180,83,9,0.2); }
.vote-points { font-size: 0.8rem; color: var(--text-muted); margin-left: auto; }

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  text-align: center;
}
.footer-container { max-width: 1200px; margin: 0 auto; }
.footer-brand { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.footer-info  { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; }
.footer-copy  { font-size: 0.8rem; color: var(--text-muted); }

/* ── Utilities ── */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }
.flex  { display: flex; }
.gap-8 { gap: 8px; }
.gap-16{ gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.empty-state {
  text-align: center; padding: 80px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { max-width: 360px; margin: 0 auto; }
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .projects-grid    { grid-template-columns: repeat(2, 1fr); }
  .category-grid    { grid-template-columns: repeat(2, 1fr); }
  .stats-strip      { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .nav-toggle       { display: flex; }
  .nav-links        {
    display: none; position: fixed; top: 64px; left: 0; right: 0;
    background: var(--bg-secondary); border-bottom: 1px solid var(--border);
    flex-direction: column; padding: 16px; gap: 4px; z-index: 99;
  }
  .nav-links.open   { display: flex; }
  .nav-user         { flex-direction: column; align-items: flex-start; }
  .projects-grid    { grid-template-columns: 1fr; }
  .category-grid    { grid-template-columns: repeat(2, 1fr); }
  .form-row         { grid-template-columns: 1fr; }
  .filters-bar      { flex-direction: column; }
  .filter-group     { min-width: 100%; }
  .hero             { padding: 60px 24px 50px; }
  .modal            { padding: 24px; }
  .login-card       { padding: 32px 24px; }
  .vote-card        { padding: 24px; }
}
@media (max-width: 480px) {
  .stats-strip      { grid-template-columns: repeat(2, 1fr); }
  .category-grid    { grid-template-columns: 1fr 1fr; }
  .hero-actions     { flex-direction: column; align-items: center; }
}
