@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,600;0,9..40,800;1,9..40,400&display=swap');

:root {
  --bg:      #09180f;
  --card:    #0e2318;
  --text:    #eaf6ef;
  --muted:   #88b89e;
  --green:   #2de088;
  --gold:    #f5c842;
  --red:     #ff5c5c;
  --orange:  #ffaa44;
  --line:    rgba(255,255,255,.09);
  --shadow:  0 16px 40px rgba(0,0,0,.5);
  --radius:  20px;
  --pad:     20px;
  --font-body:    'DM Sans', ui-sans-serif, system-ui, sans-serif;
  --font-display: 'Bebas Neue', 'Impact', sans-serif;
}

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

body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(ellipse 1400px 800px at 10% -10%,  rgba(39,208,125,.15),  transparent 60%),
    radial-gradient(ellipse 900px  600px at 95%  25%,  rgba(243,201,75,.12),  transparent 60%),
    radial-gradient(ellipse 600px  600px at 50%  100%, rgba(39,208,125,.06),  transparent 70%),
    var(--bg);
  color: var(--text);
  min-height: 100dvh;
  /* Safe area for iPhone notch / home indicator */
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── HEADER ───────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 16px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(6,15,10,.95);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  border-bottom: 1px solid var(--line);
}

.topbar-row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo-img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: contain;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  padding: 3px;
  flex-shrink: 0;
}

.title {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 1.5px;
  line-height: 1;
}

.subtitle {
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.lock-btn {
  flex-shrink: 0;
  font-size: 13px;
  padding: 8px 14px;
  min-height: 36px;
}

/* ── STATS BAR ────────────────────────────────────── */
.stats {
  display: flex;
  gap: 8px;
  width: 100%;
}

.stat-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stat-group-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .7px;
  padding-left: 2px;
}

.stat-group-inner {
  display: flex;
  gap: 6px;
}

.stat {
  flex: 1;
  padding: 7px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  text-align: center;
}

.stat.highlight {
  background: rgba(243,201,75,.1);
  border-color: rgba(243,201,75,.3);
}

.stat.highlight-veggie {
  background: rgba(39,208,125,.1);
  border-color: rgba(39,208,125,.3);
}

.k {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 600;
}

.v {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 1px;
  margin-top: 2px;
  line-height: 1;
}

.stat.highlight .v       { color: var(--gold); }
.stat.highlight-veggie .v { color: var(--green); }

/* ── LAYOUT ───────────────────────────────────────── */
.container {
  max-width: 600px;
  margin: 16px auto;
  padding: 0 14px 40px;
  display: grid;
  gap: 14px;
}

.card {
  background: rgba(255,255,255,.035);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--pad);
  animation: fadeUp .25s ease both;
  overflow: visible;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.pin-card {
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
  border-color: rgba(39,208,125,.15);
  background: rgba(39,208,125,.04);
}

.pin-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.pin-icon { font-size: 34px; line-height: 1; }
.pin-header h2 { margin: 0; }
.pin-header .muted { margin: 4px 0 0; }

h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 1px;
  font-weight: 400;
}

.muted {
  color: var(--muted);
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
}

/* ── FORM ─────────────────────────────────────────── */
.row {
  display: flex;
  gap: 10px;
}

/* Search wrapper — positions dropdown relative to input row */
.search-wrap {
  position: relative;
}

input, textarea {
  flex: 1;
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.28);
  color: var(--text);
  outline: none;
  font-size: 16px; /* 16px prevents iOS auto-zoom */
  font-family: var(--font-body);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}

input::placeholder, textarea::placeholder { color: var(--muted); }

input:focus, textarea:focus {
  border-color: rgba(39,208,125,.5);
  box-shadow: 0 0 0 4px rgba(39,208,125,.10);
}

textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* ── LIVE SEARCH DROPDOWN ─────────────────────────── */
.dropdown {
  position: fixed;
  z-index: 9999;
  background: #0d2218;
  background-color: #0d2218 !important;
  border: 1px solid rgba(39,208,125,.35);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,.98);
  overflow: hidden;
  animation: fadeUp .15s ease both;
  /* Force solid — no parent transparency bleeds through on fixed elements */
  isolation: isolate;
  will-change: transform;
}

.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  cursor: pointer;
  text-align: left;
  gap: 10px;
  transition: background .1s;
  /* Large tap target for mobile */
  min-height: 52px;
}

.dropdown-item:last-child { border-bottom: none; }

.dropdown-item:active,
.dropdown-item:hover {
  background: rgba(39,208,125,.1);
}

.dropdown-name { font-weight: 700; }

.dropdown-meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── BUTTONS ──────────────────────────────────────── */
.btn {
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  color: var(--text);
  font-weight: 800;
  font-family: var(--font-body);
  font-size: 15px;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
  white-space: nowrap;
  /* Larger tap area on mobile */
  min-height: 50px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled)  { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled              { cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(135deg, rgba(39,208,125,.3), rgba(39,208,125,.18));
  border-color: rgba(39,208,125,.4);
  color: #aff4d0;
}
.btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(39,208,125,.4), rgba(39,208,125,.28));
}

.btn.success {
  background: linear-gradient(135deg, rgba(39,208,125,.22), rgba(39,208,125,.12));
  border-color: rgba(39,208,125,.35);
  color: #a8f0cc;
}
.btn.success:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(39,208,125,.32), rgba(39,208,125,.22));
}

.btn.danger {
  background: rgba(255,92,92,.14);
  border-color: rgba(255,92,92,.35);
  color: #ffaaaa;
}
.btn.danger:hover:not(:disabled) {
  background: rgba(255,92,92,.24);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
}
.btn.ghost:hover:not(:disabled) {
  background: rgba(255,255,255,.05);
  color: var(--text);
}

/* ── RESULT BOX ───────────────────────────────────── */
.result {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px dashed rgba(255,255,255,.15);
  background: rgba(0,0,0,.2);
  min-height: 64px;
  line-height: 1.6;
  transition: box-shadow .3s;
}

.result.flash-success {
  box-shadow: 0 0 0 3px rgba(39,208,125,.5);
}

.student-card-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.student-name {
  font-size: 18px;
  display: block;
  margin: 4px 0 2px;
}

.taken-count {
  font-size: 14px;
  color: var(--muted);
}

/* Allergy / notes warning pill */
.allergy-pill {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,170,68,.15);
  border: 1px solid rgba(255,170,68,.35);
  color: var(--orange);
  font-size: 13px;
  font-weight: 700;
}

.result-msg {
  margin-top: 6px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 5px 11px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: .6px;
  text-transform: uppercase;
  border: 1px solid var(--line);
  margin-right: 8px;
}
.badge.ok { background: rgba(39,208,125,.16); border-color: rgba(39,208,125,.3);  color: #7effc6; }
.badge.no { background: rgba(255,92,92,.12);  border-color: rgba(255,92,92,.3);   color: #ffaaaa; }

/* ── TYPE TOGGLE ──────────────────────────────────── */
.type-toggle {
  display: flex;
  gap: 0;
  background: rgba(0,0,0,.25);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  width: 100%;
}

.type-btn {
  flex: 1;
  padding: 12px 10px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, color .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.type-btn.active {
  background: rgba(39,208,125,.18);
  color: #a8f0cc;
}

.type-btn[data-type="veggie"].active {
  background: rgba(39,208,125,.18);
  color: #a8f0cc;
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}

.action-row .btn {
  flex: 1;
  min-width: 100px;
}

/* ── ACTIONS ──────────────────────────────────────── */
.actions {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.actions .btn {
  flex: 1;
  min-width: 130px;
}

/* ── NOTES CARD ───────────────────────────────────── */
.notes-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.notes-msg {
  font-size: 14px;
  font-weight: 700;
}

/* ── HIDDEN ───────────────────────────────────────── */
.hidden { display: none !important; }

.notice {
  margin-top: 10px;
  font-size: 14px;
  color: var(--red);
  font-weight: 600;
  min-height: 20px;
}

/* ── RECENT CLAIMS ────────────────────────────────── */
.recent { display: grid; gap: 8px; }

.recentItem {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.15);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  transition: background .15s;
}

.recentItem:hover { background: rgba(39,208,125,.05); }

.recentItem-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  min-width: 0;
}

.recentItem-id   { color: var(--text); }
.recentItem-note { color: var(--muted); font-size: 13px; }

.recentItem-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.recentItem-time { color: var(--muted); font-size: 13px; }

.undo-btn {
  padding: 6px 12px !important;
  font-size: 13px !important;
  min-height: 36px !important;
}

/* ── RESPONSIVE / MOBILE ──────────────────────────── */
@media (max-width: 540px) {
  .topbar {
    padding: 8px 12px 10px;
    padding-top: calc(8px + env(safe-area-inset-top));
    gap: 8px;
  }

  .title   { font-size: 17px; }
  .subtitle { display: none; }

  h2 { font-size: 18px; }

  .container {
    margin: 12px auto;
    padding: 0 10px 60px;
    gap: 12px;
  }

  .card { padding: 16px; }

  .actions { gap: 8px; }

  .actions .btn {
    font-size: 14px;
    padding: 13px 12px;
  }

  .row { gap: 8px; }

  input, textarea { font-size: 16px; } /* prevent iOS zoom */

  .dropdown-item { padding: 16px 14px; min-height: 56px; }
}

@media (max-width: 360px) {
  .actions .btn { min-width: 100px; font-size: 13px; }
}
