/* Gaya untuk Sport Stacking System (admin & laman awam). */

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f7f8fa;
  color: #1f2937;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; background: #0f172a; color: #fff;
}
.topbar a, .topbar .link { color: #fff; }
.topbar nav a, .topbar nav .link { margin-left: 16px; }
.brand { font-weight: 700; font-size: 1.1rem; }
.inline { display: inline; }
.link { background: none; border: 0; cursor: pointer; padding: 0; font: inherit; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }
.flash { padding: 10px 20px; }
.flash.success { background: #d1fae5; color: #065f46; }
.flash.error   { background: #fee2e2; color: #991b1b; }

/* ---------- Wira / Hero ---------- */
.hero {
  padding: 56px 24px;
  text-align: center;
  color: #fff;
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 50%, #7c3aed 100%);
  border-radius: 12px;
  margin-bottom: 24px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, .15);
}
.hero h1 { margin: 0 0 8px; font-size: 2.4rem; letter-spacing: .5px; }
.hero p  { margin: 0 auto; max-width: 640px; opacity: .95; }
.hero .cta { margin-top: 20px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero .btn { background: #fff; color: #1e3a8a; border-color: #fff; }
.hero .btn.primary { background: #f59e0b; color: #1f2937; border-color: #f59e0b; }
.hero .btn:hover { transform: translateY(-1px); }

.cta { margin-top: 16px; display: flex; gap: 12px; justify-content: center; }

.btn {
  display: inline-block; padding: 8px 14px; border-radius: 6px;
  background: #fff; border: 1px solid #cbd5e1; color: #1f2937;
  cursor: pointer; transition: transform .12s ease, box-shadow .12s ease;
}
.btn.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn:hover { filter: brightness(0.97); box-shadow: 0 2px 6px rgba(0,0,0,.1); }
.danger { color: #b91c1c; }

/* ---------- Kad statistik ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); gap: 12px; margin: 16px 0; }
.card { background: #fff; padding: 18px; border-radius: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.06); text-align: center; }
.card h3 { margin: 0 0 4px; font-size: 1.8rem; color: #1e3a8a; }
.card.accent-blue   h3 { color: #2563eb; }
.card.accent-green  h3 { color: #059669; }
.card.accent-purple h3 { color: #7c3aed; }
.card.accent-orange h3 { color: #d97706; }
.card .icon { font-size: 1.6rem; line-height: 1; margin-bottom: 4px; }

/* ---------- Seksyen laman utama ---------- */
.section { margin: 28px 0; }
.section h2 {
  margin: 0 0 12px;
  font-size: 1.35rem;
  border-left: 4px solid #2563eb;
  padding-left: 10px;
}
.section .lead { color: #475569; margin-top: -6px; margin-bottom: 12px; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.cat-tile {
  background: #fff;
  padding: 16px;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  border-top: 4px solid #2563eb;
}
.cat-tile h3 { margin: 0 0 4px; font-size: 1.05rem; }
.cat-tile .count { color: #2563eb; font-weight: 700; font-size: 1.6rem; }
.cat-tile small { color: #6b7280; }

.disc-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e0e7ff;
  color: #1e3a8a;
  font-size: .85rem;
  font-weight: 600;
}

.podium-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.podium-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  border-top: 4px solid #f59e0b;
}
.podium-card header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.podium-card header h3 { margin: 0; font-size: 1rem; }
.podium-card header .pill { background: #fef3c7; color: #92400e; }
.podium-card ol { margin: 0; padding-left: 18px; }
.podium-card li { padding: 3px 0; }
.podium-card li.gold   { font-weight: 700; color: #b45309; }
.podium-card li.silver { color: #475569; }
.podium-card li.bronze { color: #9a3412; }
.podium-card .time { color: #2563eb; font-weight: 600; }

.recent-list {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 8px;
}
.recent-list li {
  background: #fff; padding: 10px 14px; border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 6px;
}
.recent-list li .name { font-weight: 600; }
.recent-list li small { color: #6b7280; }

.empty {
  background: #fff;
  padding: 18px;
  border-radius: 10px;
  border: 1px dashed #cbd5e1;
  color: #6b7280;
  text-align: center;
}

/* ---------- Borang ---------- */
.form { display: grid; gap: 12px; max-width: 520px; }
.form.narrow { max-width: 360px; }
.form label { display: grid; gap: 4px; font-size: .9rem; color: #374151; }
.form input, .form select {
  padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 1rem; background: #fff;
}

.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; max-width: none; }
.inline-form input, .inline-form select { padding: 6px 8px; }

.filter-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 12px 0 16px; }
.filter-form label { display: grid; gap: 4px; font-size: .85rem; color: #374151; }
.filter-form select { padding: 6px 8px; }

.results { width: 100%; border-collapse: collapse; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.results th, .results td { padding: 8px 10px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: middle; }
.results thead th { background: #f1f5f9; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }

.results tr.gold      { background: #fef9c3; }
.results tr.silver    { background: #e5e7eb; }
.results tr.bronze    { background: #fde68a; }
.results tr.qualified { background: #dcfce7; }

.actions { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.hint { color: #6b7280; font-size: .9rem; }
.error { background: #fef2f2; padding: 12px; border-radius: 6px; }
.footer { padding: 24px; text-align: center; color: #6b7280; }

/* ---------- Hamburger / Nav Toggle ---------- */
.nav-toggle {
  display: none;
  background: none; border: 0; color: #fff;
  font-size: 1.5rem; cursor: pointer; padding: 4px 8px;
}

/* ---------- Responsive: Jadual scroll ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -20px; padding: 0 20px; }

/* ---------- Mobile (max 768px) ---------- */
@media (max-width: 768px) {
  /* Nav hamburger */
  .nav-toggle { display: block; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; }
  .topbar nav {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 0;
    margin-top: 10px;
    border-top: 1px solid rgba(255,255,255,.15);
    padding-top: 10px;
  }
  .topbar nav.open { display: flex; }
  .topbar nav a, .topbar nav .link { margin-left: 0; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
  .topbar nav .inline { width: 100%; }
  .topbar nav .inline button { padding: 8px 0; width: 100%; text-align: left; }

  /* Hero */
  .hero { padding: 36px 16px; border-radius: 8px; margin-bottom: 16px; }
  .hero h1 { font-size: 1.6rem; }
  .hero p { font-size: .9rem; }
  .hero .cta { flex-direction: column; align-items: center; }

  /* Container */
  .container { padding: 16px 12px; }

  /* Kad statistik */
  .cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .card { padding: 12px; }
  .card h3 { font-size: 1.4rem; }

  /* Kategori grid */
  .cat-grid { grid-template-columns: 1fr; gap: 8px; }

  /* Podium grid */
  .podium-grid { grid-template-columns: 1fr; gap: 10px; }

  /* Jadual: scroll horizontal */
  .results { font-size: .8rem; min-width: 600px; }
  .results th, .results td { padding: 6px 6px; white-space: nowrap; }

  /* Borang */
  .filter-form { flex-direction: column; align-items: stretch; gap: 8px; }
  .filter-form label { width: 100%; }
  .filter-form select { width: 100%; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input, .inline-form select, .inline-form button { width: 100%; }
  .form { max-width: 100%; }

  /* Actions */
  .actions { flex-direction: column; }
  .actions .btn { width: 100%; text-align: center; }

  /* Section headings */
  .section h2 { font-size: 1.15rem; }

  /* Recent list */
  .recent-list li { flex-direction: column; align-items: flex-start; }
}

/* ---------- Tablet (max 1024px) ---------- */
@media (max-width: 1024px) and (min-width: 769px) {
  .topbar nav a, .topbar nav .link { margin-left: 10px; font-size: .85rem; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .podium-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Print (A4) ---------- */
@media print {
  @page {
    size: A4 landscape;
    margin: 15mm 10mm;
  }
  body { background: #fff; margin: 0; padding: 0; font-size: 11pt; }
  .topbar, .no-print, .footer, .flash, .hero, .filter-form, .actions.no-print { display: none !important; }
  .container { max-width: 100%; padding: 0; margin: 0; }
  .print-header { display: block !important; text-align: center; margin-bottom: 12pt; }
  .print-header h1 { font-size: 16pt; margin: 0 0 4pt; }
  .print-header h2 { font-size: 13pt; margin: 0 0 4pt; font-weight: normal; }
  .print-header p  { font-size: 10pt; margin: 0; }
  .results.printable { box-shadow: none; width: 100%; font-size: 10pt; }
  .results.printable th, .results.printable td { padding: 4pt 6pt; border: 1px solid #333; }
  .results.printable thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .results tr.gold   { background: #fff8dc !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .results tr.silver { background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .results tr.bronze { background: #fff3cd !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .results tr.qualified { background: #e8f5e9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  td.no-print, th.no-print { display: none !important; }
}
