/* HRK School Lunch — Component styles (plain CSS, ทำงานร่วมกับ Tailwind CDN) */
:root {
  --brand: #1d6ff2;
  --brand-700: #1559cf;
  --navy: #12306b;
  --navy-900: #0b1f47;
  --card: #ffffff;
  --card-border: rgba(226, 232, 240, .9);
  --input-bg: #ffffff;
  --input-border: #d5dde9;
  --muted: #64748b;
}
.dark {
  --card: rgba(17, 25, 45, .72);
  --card-border: rgba(51, 65, 85, .6);
  --input-bg: rgba(15, 23, 42, .7);
  --input-border: #334155;
  --muted: #94a3b8;
}
html { scroll-behavior: smooth; }
body { font-family: 'Prompt', Tahoma, sans-serif; }
.app-bg { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(1200px 500px at 85% -10%, rgba(29,111,242,.08), transparent 60%),
              radial-gradient(800px 400px at 10% 110%, rgba(249,115,22,.05), transparent 60%); }
.dark .app-bg { background: radial-gradient(1200px 500px at 85% -10%, rgba(29,111,242,.18), transparent 60%),
                            radial-gradient(800px 400px at 10% 110%, rgba(56,189,248,.08), transparent 60%); }

/* Sidebar */
.sidebar { background: linear-gradient(180deg, #163a7a 0%, #12306b 35%, #0b1f47 100%); box-shadow: 4px 0 24px -12px rgba(2,6,23,.6); }
.dark .sidebar { background: linear-gradient(180deg, #0f2550 0%, #0a1836 50%, #060f24 100%); }
.nav-link { display: flex; align-items: center; gap: .85rem; padding: .78rem 1rem; border-radius: .85rem;
  color: rgba(226,236,255,.92); font-size: .98rem; transition: background .15s, color .15s; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: var(--brand); color: #fff; font-weight: 600; box-shadow: 0 8px 20px -8px rgba(29,111,242,.8); }
.sidebar-open .sidebar { transform: translateX(0); }

/* Cards (glass) */
.card, .glass { background: var(--card); border: 1px solid var(--card-border); border-radius: 1.1rem;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 28px -12px rgba(15,23,42,.10); }
.dark .card, .dark .glass { backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.stat-icon { width: 3.6rem; height: 3.6rem; border-radius: 9999px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* Buttons */
.btn-primary, .btn-outline, .btn-ghost, .btn-danger, .btn-success {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .62rem 1.1rem;
  border-radius: .75rem; font-weight: 500; font-size: .93rem; transition: all .15s; white-space: nowrap; cursor: pointer; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px -8px rgba(29,111,242,.9); }
.btn-primary:hover { background: var(--brand-700); }
.btn-outline { border: 1.5px solid var(--brand); color: var(--brand); background: transparent; }
.btn-outline:hover { background: rgba(29,111,242,.07); }
.dark .btn-outline { color: #7fb0ff; border-color: #3b82f6; }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: rgba(100,116,139,.1); }
.btn-danger { border: 1.5px solid #e11d48; color: #e11d48; background: transparent; }
.btn-danger:hover { background: rgba(225,29,72,.07); }
.dark .btn-danger { color: #fb7185; border-color: #f43f5e; }
.dark .btn-danger:hover { background: rgba(244,63,94,.12); }
.btn-success { border: 1.5px solid #16a34a; color: #15803d; background: transparent; }
.btn-success:hover { background: rgba(22,163,74,.07); }
.btn-sm { padding: .38rem .75rem !important; font-size: .82rem !important; border-radius: .6rem !important; }
button:disabled, .btn-primary[disabled] { opacity: .5; cursor: not-allowed; }

/* Inputs */
.input, .select { width: 100%; background: var(--input-bg); border: 1px solid var(--input-border); border-radius: .7rem;
  padding: .6rem .85rem; font-size: .95rem; color: inherit; outline: none; transition: border .15s, box-shadow .15s; }
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,111,242,.18); }
.select { appearance: none; padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; background-size: 1rem; }
.label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .3rem; color: #334155; }
.dark .label { color: #cbd5e1; }

/* Tables */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.tbl thead th { background: #f1f5fb; color: #334155; font-weight: 600; padding: .7rem .8rem; text-align: left; white-space: nowrap; }
.dark .tbl thead th { background: rgba(30,41,59,.7); color: #cbd5e1; }
.tbl thead th:first-child { border-top-left-radius: .7rem; } .tbl thead th:last-child { border-top-right-radius: .7rem; }
.tbl tbody td { padding: .7rem .8rem; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
.dark .tbl tbody td { border-bottom-color: rgba(51,65,85,.5); }
.tbl tbody tr:hover td { background: rgba(29,111,242,.035); }
.tbl tfoot td { padding: .7rem .8rem; font-weight: 700; background: #e8f0fe; }
.dark .tbl tfoot td { background: rgba(29,111,242,.15); }
.num, .tbl th.num, .tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Dropdown items */
.dd-item { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; border-radius: .6rem; font-size: .9rem; text-align: left; }
.dd-item:hover { background: rgba(100,116,139,.1); }

/* Tabs */
.tab { padding: .6rem 1.1rem; color: var(--muted); border-bottom: 2.5px solid transparent; font-weight: 500; white-space: nowrap; }
.tab:hover { color: var(--brand); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* Scan page */
.scan-input { font-size: 1.35rem; letter-spacing: .02em; }
.scan-result { transition: background .2s, border-color .2s; }
.scan-result[data-state="success"]   { border-color: #22c55e; background: linear-gradient(180deg, rgba(34,197,94,.10), rgba(34,197,94,.03)); }
.scan-result[data-state="duplicate"] { border-color: #f97316; background: linear-gradient(180deg, rgba(249,115,22,.12), rgba(249,115,22,.03)); }
.scan-result[data-state="error"]     { border-color: #e11d48; background: linear-gradient(180deg, rgba(225,29,72,.10), rgba(225,29,72,.03)); }
.scan-result[data-state="pending"]   { border-color: #64748b; background: linear-gradient(180deg, rgba(100,116,139,.12), rgba(100,116,139,.03)); }
.scan-result[data-state="idle"]      { border-color: var(--card-border); }
@keyframes pop { 0% { transform: scale(.97); } 60% { transform: scale(1.01); } 100% { transform: scale(1); } }
.pop { animation: pop .28s ease-out; }
.fullscreen-mode .sidebar { display: none; }
.fullscreen-mode .main-wrap { margin-left: 0 !important; }

/* Report grid (per-student) */
.grid-cell { width: 1.75rem; min-width: 1.75rem; text-align: center; font-size: .75rem; padding: .35rem 0 !important; }
.st-R { background: #dcfce7; color: #166534; } .st-X { background: #ffedd5; color: #9a3412; }
.st-E { background: #ede9fe; color: #5b21b6; } .st-N { background: #f1f5f9; color: #94a3b8; }
.st-H { background: repeating-linear-gradient(45deg,#f8fafc,#f8fafc 4px,#eef2f7 4px,#eef2f7 8px); color: #cbd5e1; }
.dark .st-R { background: rgba(34,197,94,.2); color: #86efac; } .dark .st-X { background: rgba(249,115,22,.2); color: #fdba74; }
.dark .st-E { background: rgba(139,92,246,.22); color: #c4b5fd; } .dark .st-N { background: rgba(51,65,85,.4); color: #64748b; }
.dark .st-H { background: rgba(30,41,59,.6); color: #475569; }

/* Print */
@media print {
  .sidebar, header, footer, .no-print, #toastWrap, [style*="fixed"], [style*="position: fixed"] { display: none !important; }
  .main-wrap { margin-left: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .card, .glass { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
  .app-bg { display: none; }
}

/* Report print mode (ส่งออก PDF ผ่านเบราว์เซอร์ A4 แนวตั้ง) */
.print-mode .sidebar, .print-mode #sidebarToggle { display: none !important; }
.print-mode .main-wrap { margin-left: 0 !important; }
.print-mode .print-only { display: block !important; }
@media print {
  .print-only { display: block !important; }
  .tbl { font-size: 10px; }
  .tbl thead th { background: #1e3a8a !important; color: #fff !important; }
  .grid-cell { width: 1.2rem; min-width: 1.2rem; }
  @page { size: A4 portrait; margin: 10mm; }
}

/* แสดงวันที่ พ.ศ. ทับ input[type=date] */
.be-date { position: relative; display: block; }
.be-date input[type=date] { color: transparent; }
.be-date input[type=date]::-webkit-datetime-edit { color: transparent; }
.be-date input[type=date]:focus { color: inherit; }
.be-date input[type=date]:focus::-webkit-datetime-edit { color: inherit; }
.be-date input[type=date]:focus + .be-date-label { opacity: 0; }
.be-date-label { position: absolute; inset: 0; display: flex; align-items: center; pointer-events: none; white-space: nowrap; font-size: .95rem; }
