/* ============================================================
   NAAP Tool Inventory PWA — Stylesheet
   ============================================================ */

:root {
  --navy:      #1a2744;
  --navy-mid:  #243560;
  --navy-lite: #2e4080;
  --accent:    #3b82f6;
  --accent-dk: #2563eb;
  --green:     #22c55e;
  --red:       #ef4444;
  --amber:     #f59e0b;
  --text:      #f1f5f9;
  --text-sub:  #94a3b8;
  --card-bg:   #1e3a5f;
  --border:    #2e4a7a;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
}

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

html {
  min-height: 100%;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--navy);
  color: var(--text);
}
body {
  min-height: 100%;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--navy);
  color: var(--text);
  /* Don't use overflow:hidden — it clips position:fixed modals on iOS */
  overflow-x: clip;
}

/* ── Screens ─────────────────────────────────────────────── */
.screen {
  display: none;
  padding: 0 0 20px;
  animation: fadeIn .2s ease;
}
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Idle Screen ─────────────────────────────────────────── */
.idle-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
  text-align: center;
}

.naap-logo {
  position: relative;
  width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; letter-spacing: 2px;
  color: var(--accent);
}
.logo-ring {
  position: absolute; inset: 0;
  border: 3px solid var(--accent);
  border-radius: 50%;
}

.idle-wrap h1 { font-size: 28px; font-weight: 700; }
.subtitle { color: var(--text-sub); font-size: 14px; }

.scan-pulse {
  position: relative;
  width: 100px; height: 100px;
  display: flex; align-items: center; justify-content: center;
  margin: 16px 0;
}
.pulse-ring {
  position: absolute; inset: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0%   { transform: scale(.8); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}
.scan-icon { font-size: 40px; }
.scan-hint { color: var(--text-sub); font-size: 15px; }

.status-badge {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  min-height: 30px;
}
.status-badge.denied  { background: rgba(239,68,68,.2);  color: var(--red);   border: 1px solid var(--red); }
.status-badge.granted { background: rgba(34,197,94,.2);  color: var(--green); border: 1px solid var(--green); }

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; font-weight: 700; }
.page-header .sub { color: var(--text-sub); font-size: 14px; margin-top: 4px; }

.back-btn {
  background: none; border: none; color: var(--accent);
  font-size: 14px; cursor: pointer; padding: 0 0 8px;
}

/* ── Mode / Another cards ────────────────────────────────── */
.mode-cards, .another-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: left;
  position: relative;
}
.mode-card:hover   { border-color: var(--accent); background: var(--navy-mid); }
.mode-card.end-card { border-color: var(--green); }
.mode-card.end-card:hover { background: rgba(34,197,94,.1); }

.mode-icon  { font-size: 28px; margin-bottom: 8px; }
.mode-label { font-size: 17px; font-weight: 700; color: var(--text); }
.mode-desc  { font-size: 13px; color: var(--text-sub); margin-top: 4px; }

.badge {
  position: absolute; top: 14px; right: 14px;
  background: var(--amber); color: #000;
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 10px;
}
.badge.hidden { display: none; }

/* ── Forms ───────────────────────────────────────────────── */
.form-wrap { display: flex; flex-direction: column; gap: 18px; }

.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label { font-size: 13px; color: var(--text-sub); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

select, input[type="text"], input[type="email"], input[type="datetime-local"] {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  padding: 12px 14px;
  width: 100%;
  appearance: none;
  transition: border-color .15s;
}
select:focus, input:focus {
  outline: none;
  border-color: var(--accent);
}
select:disabled { opacity: .4; cursor: not-allowed; }
option { background: var(--navy-mid); }

/* ── Flag notice ─────────────────────────────────────────── */
.flag-notice {
  background: rgba(245,158,11,.1);
  border: 1px solid var(--amber);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 14px;
  color: var(--amber);
}
.flag-notice.hidden { display: none; }
.flag-inputs { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-ghost {
  width: 100%; padding: 14px;
  border: none; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 700;
  cursor: pointer; transition: background .15s, opacity .15s;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dk); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.btn-secondary { background: var(--navy-mid); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--navy-lite); }
.btn-ghost     { background: none; color: var(--text-sub); }
.btn-ghost:hover { color: var(--text); }

/* ── Scan status bar ─────────────────────────────────────── */
.scan-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.scan-indicator {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text-sub);
}
.scan-indicator.active { color: var(--green); }
.scan-indicator .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-sub);
}
.scan-indicator.active .dot {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: .3; } }

.tool-count-badge {
  background: var(--accent);
  color: #fff; font-size: 13px; font-weight: 700;
  padding: 4px 12px; border-radius: 12px;
}

/* ── Tool list ───────────────────────────────────────────── */
.tool-list {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 20px;
}

.tool-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  animation: slideIn .2s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; } }

.tool-item-name  { font-size: 15px; font-weight: 600; }
.tool-item-sub   { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.tool-item-badge {
  font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 10px;
}
.tool-item-badge.borrowed { background: rgba(59,130,246,.2); color: var(--accent); border: 1px solid var(--accent); }
.tool-item-badge.returned { background: rgba(34,197,94,.2);  color: var(--green);  border: 1px solid var(--green); }

/* ── Summary ─────────────────────────────────────────────── */
.summary-wrap { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }

.summary-student {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.summary-student h3 { font-size: 16px; margin-bottom: 10px; }
.summary-tool-row {
  display: flex; justify-content: space-between;
  font-size: 13px; padding: 6px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-sub);
}
.summary-tool-row:last-child { border-bottom: none; }
.summary-tool-row .tool-name { color: var(--text); }

/* ── Scan actions ────────────────────────────────────────── */
.scan-actions { margin-top: 8px; }

/* ── Toast ───────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999; pointer-events: none;
  width: calc(100% - 40px); max-width: 420px;
}
.toast {
  background: var(--navy-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  animation: toastIn .2s ease;
  pointer-events: auto;
}
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red);   }
.toast.info    { border-color: var(--accent); color: var(--accent); }
@keyframes toastIn { from { opacity:0; transform: translateY(12px); } to { opacity:1; } }

/* ── Nav ─────────────────────────────────────────────────── */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--navy-mid);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 0 env(safe-area-inset-bottom);
}
#bottom-nav.hidden { display: none; }

.nav-item {
  flex: 1; background: none; border: none;
  color: var(--text-sub); font-size: 11px;
  padding: 8px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: color .15s;
}
.nav-item.active { color: var(--accent); }
