/* ============================================================
   DSA Portal — Mobile-First CSS
   ============================================================ */

:root {
  --primary:   #2563eb;
  --primary-d: #1d4ed8;
  --success:   #16a34a;
  --danger:    #dc2626;
  --warning:   #d97706;
  --bg:        #f1f5f9;
  --card:      #ffffff;
  --border:    #e2e8f0;
  --text:      #1e293b;
  --muted:     #64748b;
  --radius:    12px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Utility ---- */
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.w-full { width: 100%; }

/* ============================================================
   PIN LOGIN PAGE
   ============================================================ */
.pin-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  padding: 1.5rem;
}

.pin-logo {
  font-size: 2.2rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -1px;
  margin-bottom: .25rem;
}

.pin-subtitle {
  color: rgba(255,255,255,.7);
  font-size: .9rem;
  margin-bottom: 2rem;
}

.pin-card {
  background: #fff;
  border-radius: 24px;
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.pin-display {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 1.5rem;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  background: transparent;
  transition: all .15s ease;
}

.pin-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.15);
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.key-btn {
  aspect-ratio: 1;
  border: none;
  border-radius: 16px;
  background: var(--bg);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all .12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.key-btn:active { transform: scale(.92); background: #dbeafe; }

.key-btn.backspace {
  font-size: 1.2rem;
  color: var(--muted);
}

.key-btn.enter-btn {
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
}

.key-btn.enter-btn:active { background: var(--primary-d); }

.pin-error {
  text-align: center;
  color: var(--danger);
  font-size: .85rem;
  margin-top: .75rem;
  min-height: 1.2em;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  background: var(--primary);
  color: #fff;
  padding: .9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.navbar-brand {
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  letter-spacing: -.3px;
}

.navbar-user {
  font-size: .8rem;
  opacity: .85;
}

.navbar-actions { display: flex; gap: .5rem; align-items: center; }

.btn-logout {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .35rem .75rem;
  font-size: .8rem;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.25); text-decoration: none; color: #fff; }

/* ============================================================
   MAIN CONTAINER
   ============================================================ */
.container {
  max-width: 700px;
  margin: 0 auto;
  padding: 1rem;
}

.page-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1rem;
}

.card-header {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: .95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 1rem; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { text-decoration: none; opacity: .9; }
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-sm { padding: .35rem .7rem; font-size: .78rem; border-radius: 6px; }
.btn-lg { padding: .8rem 1.5rem; font-size: 1rem; }
.btn-w100 { width: 100%; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.form-control {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s;
  outline: none;
  appearance: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

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

/* ============================================================
   CASE LIST ITEM (Staff Dashboard)
   ============================================================ */
.case-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: .75rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}

.case-item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: .5rem;
}

.case-customer { font-weight: 700; font-size: 1rem; }
.case-mob { color: var(--muted); font-size: .85rem; }

.case-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .75rem;
  margin-top: .5rem;
}

.case-meta span {
  font-size: .78rem;
  color: var(--muted);
}

.case-meta span strong { color: var(--text); }

.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 6px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .3px;
}

.badge-primary { background: #dbeafe; color: var(--primary); }
.badge-success { background: #dcfce7; color: var(--success); }
.badge-danger  { background: #fee2e2; color: var(--danger); }

/* ============================================================
   FAB (Floating Action Button)
   ============================================================ */
.fab {
  position: fixed;
  right: 1.25rem;
  bottom: 1.5rem;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(37,99,235,.45);
  cursor: pointer;
  transition: all .15s ease;
  z-index: 200;
  text-decoration: none;
}

.fab:hover { background: var(--primary-d); text-decoration: none; color: #fff; transform: scale(1.05); }
.fab:active { transform: scale(.95); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 700px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 1.25rem 1rem 2rem;
  animation: slideUp .25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 1.25rem;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

/* ============================================================
   ADMIN — STATS CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  text-align: center;
}

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

.stat-label {
  font-size: .75rem;
  color: var(--muted);
  margin-top: .25rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* ============================================================
   ADMIN — TABLE
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--card);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
  white-space: nowrap;
}

thead th {
  background: #f8fafc;
  padding: .65rem .85rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  border-bottom: 1.5px solid var(--border);
}

tbody td {
  padding: .7rem .85rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

/* ============================================================
   ADMIN — STAFF LIST
   ============================================================ */
.staff-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
}

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

.staff-name { font-weight: 700; }
.staff-pin  { font-size: .8rem; color: var(--muted); margin-top: .1rem; }

.staff-actions { display: flex; gap: .4rem; }

/* ============================================================
   GLOBAL TOGGLE
   ============================================================ */
.global-toggle-card {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  border-radius: var(--radius);
  padding: 1.25rem;
  color: #fff;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 15px rgba(37,99,235,.35);
}

.toggle-label { font-weight: 700; font-size: 1rem; }
.toggle-sub   { font-size: .8rem; opacity: .8; margin-top: .2rem; }

.toggle-switch {
  position: relative;
  width: 56px;
  height: 30px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.3);
  border-radius: 15px;
  transition: .3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px; height: 22px;
  left: 4px; top: 4px;
  background: #fff;
  border-radius: 50%;
  transition: .3s;
}

.toggle-switch input:checked + .toggle-slider { background: #4ade80; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(26px); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: .75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: .88rem;
  font-weight: 500;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ============================================================
   FILTERS ROW
   ============================================================ */
.filter-row {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filter-row .form-control {
  flex: 1;
  min-width: 120px;
  font-size: .82rem;
  padding: .5rem .75rem;
}

/* ============================================================
   EXPORT BUTTONS
   ============================================================ */
.export-row {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* ============================================================
   ADMIN NAV (Bottom bar for mobile)
   ============================================================ */
.admin-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,.08);
}

.admin-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: .6rem .25rem .5rem;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 600;
  text-decoration: none;
  transition: color .15s;
  border-top: 3px solid transparent;
}

.admin-nav a.active {
  color: var(--primary);
  border-top-color: var(--primary);
}

.admin-nav a .nav-icon { font-size: 1.3rem; margin-bottom: .1rem; }

.admin-body { padding-bottom: 70px; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}

.empty-icon { font-size: 3rem; margin-bottom: .75rem; }
.empty-text { font-size: .95rem; }

/* ============================================================
   NEW PIN REVEAL MODAL
   ============================================================ */
.pin-reveal {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: .5rem;
  color: var(--primary);
  text-align: center;
  background: #dbeafe;
  border-radius: 12px;
  padding: 1rem;
  margin: 1rem 0;
}

/* ============================================================
   RESPONSIVE — Tablet/Desktop
   ============================================================ */
@media (min-width: 640px) {
  .container { padding: 1.5rem; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .modal { border-radius: 20px; margin: auto; max-height: 85vh; }
  .modal-overlay.open { align-items: center; }
  .admin-nav { display: none; }
  .admin-sidebar { display: block; }
}

/* ============================================================
   PRINT / PDF
   ============================================================ */
@media print {
  body { background: #fff; font-size: 11pt; }
  .navbar, .fab, .admin-nav, .filter-row, .export-row, .btn { display: none !important; }
  .container { max-width: 100%; padding: 0; }
  table { font-size: 9pt; }
  thead th { background: #e2e8f0 !important; -webkit-print-color-adjust: exact; }
  .table-wrap { box-shadow: none; border: 1px solid #ccc; border-radius: 0; }
}
