/* ============================================================
   Equipment Checkout — Mobile-first Dark Theme
   ============================================================ */

:root {
  --bg: #020010;
  --surface: rgba(10, 6, 28, 0.55);
  --surface-2: rgba(16, 10, 38, 0.5);
  --border: rgba(255, 255, 255, 0.07);
  --text: #e8e8f0;
  --text-muted: #a0a0c8;
  --accent: #8b5cf6;
  --accent-hover: #a78bfa;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --info: #3b82f6;
  --radius: 14px;
  --radius-sm: 10px;
  --glass-blur: 20px;
}

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

html {
  height: 100%;
  background: var(--bg);
}

body {
  background: transparent;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

/* ============================================================
   Layout
   ============================================================ */

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 40px;
  position: relative;
  z-index: 2;
}

.page-header {
  padding: 20px 0 16px;
  margin-bottom: 8px;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.page-header .subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

.card-header {
  padding: 14px 16px;
  background: rgba(12, 6, 32, 0.4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.card-header strong {
  font-size: 1rem;
  color: var(--text);
}

.card-body {
  padding: 14px 16px;
}

.card-body p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.card-body p:last-child {
  margin-bottom: 0;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: rgba(139, 92, 246, 0.22);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #c4b5fd;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.btn-primary:hover {
  background: rgba(167, 139, 250, 0.3);
}

.btn-primary:disabled {
  background: rgba(30, 20, 60, 0.5);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  border-color: var(--border);
}

.btn-secondary {
  background: rgba(16, 10, 38, 0.5);
  color: var(--text);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.btn-secondary:hover {
  background: rgba(24, 14, 50, 0.6);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.4);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.btn-success {
  background: rgba(34, 197, 94, 0.35);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: #86efac;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  min-height: 44px;
  padding: 8px 14px;
  font-size: 0.875rem;
}

/* ============================================================
   Forms + Inputs
   ============================================================ */

.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="url"],
textarea,
select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  background: rgba(12, 6, 32, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

input:hover,
textarea:hover,
select:hover {
  border-color: rgba(139, 92, 246, 0.3);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

input:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.input-row input,
.input-row textarea {
  flex: 1;
}

/* PIN input — large digits */
input.pin-input {
  font-size: 2rem;
  letter-spacing: 0.5em;
  text-align: center;
  min-height: 64px;
  max-width: 200px;
}

/* ============================================================
   Badges
   ============================================================ */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #fff;
  white-space: nowrap;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.badge-registered { background: rgba(59, 130, 246, 0.35); border: 1px solid rgba(59, 130, 246, 0.3); color: #93c5fd; }
.badge-checked_out { background: rgba(245, 158, 11, 0.3); border: 1px solid rgba(245, 158, 11, 0.25); color: #fcd34d; }
.badge-returned { background: rgba(34, 197, 94, 0.3); border: 1px solid rgba(34, 197, 94, 0.25); color: #86efac; }

/* ============================================================
   Unit list (assigned barcodes)
   ============================================================ */

.unit-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.unit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  gap: 8px;
}

.barcode {
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  color: var(--accent);
}

/* ============================================================
   Stats grid (dashboard)
   ============================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 6px;
}

.stat-card.highlight {
  border-color: rgba(139, 92, 246, 0.25);
}

/* ============================================================
   Navigation / Landing cards
   ============================================================ */

.nav-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.nav-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
  min-height: 80px;
}

.nav-card:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}

.nav-card .nav-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.nav-card .nav-text strong {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
}

.nav-card .nav-text span {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Admin nav row */
.admin-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ============================================================
   Scanner area
   ============================================================ */

.scanner-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

.scanner-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

#scanner, #checkin-scanner {
  width: 100%;
  max-width: 360px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  max-height: 130px;
  margin: 0 auto 8px;
}

.scanner-fallback {
  margin-top: 12px;
}

.scanner-fallback p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Request picker */
#request-picker {
  display: none;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
}

#request-picker h4 {
  margin-bottom: 12px;
  font-size: 0.95rem;
  color: var(--text);
}

#request-picker .btn {
  width: 100%;
  margin-bottom: 8px;
  text-align: left;
  justify-content: flex-start;
}

/* ============================================================
   Modal
   ============================================================ */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: rgba(10, 6, 28, 0.82);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 420px;
  width: 100%;
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
}

.modal-content h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.modal-content p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 20px;
  line-height: 1.6;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  margin-bottom: 20px;
  font-size: 0.95rem;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  min-height: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--accent);
}

.modal-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-buttons .btn {
  flex: 1;
  min-width: 120px;
}

/* ============================================================
   Toast notifications
   ============================================================ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  z-index: 9999;
  max-width: 360px;
  width: calc(100% - 40px);
  text-align: center;
  animation: slideUp 0.2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

@keyframes slideUp {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

.toast-success { background: rgba(34, 197, 94, 0.35); border: 1px solid rgba(34, 197, 94, 0.3); color: #86efac; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.toast-error   { background: rgba(239, 68, 68, 0.4); border: 1px solid rgba(239, 68, 68, 0.3); color: #fca5a5; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.toast-warning { background: rgba(245, 158, 11, 0.35); border: 1px solid rgba(245, 158, 11, 0.3); color: #fcd34d; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.toast-info    { background: rgba(59, 130, 246, 0.35); border: 1px solid rgba(59, 130, 246, 0.3); color: #93c5fd; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }

/* ============================================================
   Utility classes
   ============================================================ */

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 0;
  font-size: 0.95rem;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 16px;
  padding: 8px 0;
}

.back-link:hover {
  color: var(--text);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  margin-top: 24px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.remaining {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface);
  border-radius: 99px;
  padding: 2px 10px;
}

.remaining.done {
  color: var(--success);
}

/* ============================================================
   Add-item form
   ============================================================ */

.add-item-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 20px;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

.add-item-form h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}

/* ============================================================
   Admin header row
   ============================================================ */

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
}

.admin-badge {
  background: rgba(139, 92, 246, 0.35);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #c4b5fd;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 99px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ============================================================
   Scan result area
   ============================================================ */

#scan-result {
  margin-top: 16px;
}

/* ============================================================
   Page entrance & micro-interactions
   ============================================================ */

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

.container {
  animation: pageIn 0.3s ease both;
}

.card {
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
  border-color: rgba(139, 92, 246, 0.2);
  box-shadow: 0 2px 20px rgba(139, 92, 246, 0.07);
}

.modal-content {
  animation: pageIn 0.3s ease both;
}

/* ============================================================
   Desktop tweaks (> 520px)
   ============================================================ */

@media (min-width: 520px) {
  .container {
    padding: 24px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .admin-nav .btn {
    flex: 1;
  }
}

@media (min-width: 768px) {
  .container {
    max-width: 540px;
    padding: 32px;
  }
}

/* ============================================================
   Capture-based Barcode Scanner (.bcs-*)
   ============================================================ */

.bcs-wrap { margin-bottom: 8px; }

.bcs-viewfinder {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto 10px;
  border-radius: var(--radius);
  background: #000;
  aspect-ratio: 16 / 9;
}

.bcs-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--radius);
}

.bcs-guide {
  position: absolute;
  left: 8%; right: 8%;
  top: 30%; bottom: 30%;
  border: 2px solid rgba(139, 92, 246, 0.35);
  border-radius: 8px;
  pointer-events: none;
}

.bcs-capture-btn {
  display: block;
  width: 100%;
  max-width: 400px;
  margin: 8px auto 4px;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid rgba(139, 92, 246, 0.55);
  background: rgba(139, 92, 246, 0.5);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}
.bcs-capture-btn:active { background: rgba(139, 92, 246, 0.7); }
.bcs-capture-btn:disabled { opacity: 0.5; }

.bcs-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
}

.bcs-result {
  text-align: center;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  font-family: monospace;
  margin-bottom: 8px;
}
.bcs-result-ok {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #86efac;
}
.bcs-result-fail {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.bcs-alt {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.bcs-upload-label {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.bcs-upload-label:active { background: var(--surface); }

.bcs-or {
  font-size: 0.72rem;
  color: rgba(136, 136, 176, 0.5);
}
