/* =====================================================
   VMS – Visitor Management System
   Light Theme – Clean Institutional Design
   ===================================================== */

:root {
  /* Brand */
  --primary:        #1A56DB;
  --primary-light:  #EBF0FD;
  --primary-dark:   #1040B0;
  --accent:         #0EA5E9;

  /* Status */
  --success:        #059669;
  --success-bg:     #ECFDF5;
  --warning:        #D97706;
  --warning-bg:     #FFFBEB;
  --danger:         #DC2626;
  --danger-bg:      #FEF2F2;
  --info:           #0369A1;
  --info-bg:        #F0F9FF;

  /* Neutral */
  --bg:             #F8FAFC;
  --surface:        #FFFFFF;
  --border:         #E2E8F0;
  --border-light:   #F1F5F9;
  --text:           #0F172A;
  --text-secondary: #64748B;
  --text-muted:     #94A3B8;

  /* Sidebar */
  --sidebar-bg:     #0F172A;
  --sidebar-text:   #CBD5E1;
  --sidebar-active: #1A56DB;
  --sidebar-w:      260px;
  --sidebar-w-sm:   72px;

  /* Misc */
  --radius:         8px;
  --radius-lg:      12px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
  --shadow:         0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.12);
  --transition:     0.2s ease;
}

/* ── Reset & Base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: 'Inter', system-ui, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }

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

img { max-width: 100%; }

/* ── Layout ──────────────────────────────────────── */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #EBF0FD 0%, #F8FAFC 50%, #E0F2FE 100%); }

.app-body { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────── */
.sidebar { width: var(--sidebar-w); background: var(--sidebar-bg); display: flex; flex-direction: column; position: fixed; height: 100vh; top: 0; left: 0; z-index: 100; transition: width var(--transition); overflow: hidden; }

.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,.06); }

.sidebar-logo { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.sidebar-logo i { color: var(--primary); font-size: 22px; }

.sidebar-toggle { background: none; border: none; color: var(--sidebar-text); cursor: pointer; font-size: 16px; padding: 4px; border-radius: 4px; }
.sidebar-toggle:hover { color: #fff; background: rgba(255,255,255,.08); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent; }

.nav-section { margin-bottom: 8px; }
.nav-label { display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: #475569; padding: 12px 20px 4px; }

.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 20px; color: var(--sidebar-text); font-size: 13.5px; font-weight: 450; transition: background var(--transition), color var(--transition); border-radius: 0; position: relative; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item.active::before { content: ''; position: absolute; right: 0; top: 0; height: 100%; width: 3px; background: #7CB9FF; border-radius: 3px 0 0 3px; }
.nav-item i { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.06); display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.user-details { flex: 1; min-width: 0; }
.user-name { display: block; font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: #64748B; }
.btn-logout { background: none; border: none; color: #64748B; cursor: pointer; padding: 6px; border-radius: var(--radius); font-size: 15px; transition: color var(--transition), background var(--transition); }
.btn-logout:hover { color: #F87171; background: rgba(248,113,113,.1); }

/* ── Main Wrapper ────────────────────────────────── */
.main-wrapper { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; transition: margin-left var(--transition); }

/* ── Topbar ──────────────────────────────────────── */
.topbar { height: 60px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 50; }
.mobile-menu-btn { display: none; background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-secondary); }
.page-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.badge-dept { background: var(--primary-light); color: var(--primary); font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }

/* ── Page Content ────────────────────────────────── */
.page-content { flex: 1; padding: 24px; }

/* ── Cards ───────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── Stat Cards ──────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; display: flex; align-items: flex-start; gap: 14px; box-shadow: var(--shadow-sm); }
.stat-icon { width: 44px; height: 44px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon.green  { background: var(--success-bg);    color: var(--success); }
.stat-icon.orange { background: var(--warning-bg);    color: var(--warning); }
.stat-icon.red    { background: var(--danger-bg);     color: var(--danger); }
.stat-icon.sky    { background: var(--info-bg);       color: var(--info); }
.stat-icon.gray   { background: var(--border-light);  color: var(--text-secondary); }

.stat-body {}
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ── Buttons ─────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all var(--transition); border: 1px solid transparent; line-height: 1.4; }
.btn:hover { text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }

.btn-primary   { background: var(--primary);   color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.btn-success   { background: var(--success);   color: #fff; }
.btn-success:hover { background: #047857; color: #fff; }

.btn-danger    { background: var(--danger);    color: #fff; }
.btn-danger:hover { background: #B91C1C; color: #fff; }

.btn-warning   { background: var(--warning);   color: #fff; }
.btn-warning:hover { background: #B45309; color: #fff; }

.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }

.btn-outline-primary { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary-light); }

/* ── Alerts ──────────────────────────────────────── */
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13.5px; font-weight: 500; }
.alert-success { background: var(--success-bg); color: #065F46; border: 1px solid #A7F3D0; }
.alert-warning { background: var(--warning-bg); color: #92400E; border: 1px solid #FDE68A; }
.alert-danger  { background: var(--danger-bg);  color: #991B1B; border: 1px solid #FECACA; }
.alert-info    { background: var(--info-bg);    color: #0C4A6E; border: 1px solid #BAE6FD; }

/* ── Forms ───────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-control { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13.5px; color: var(--text); background: var(--surface); transition: border-color var(--transition), box-shadow var(--transition); font-family: inherit; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.12); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.field-validation-error { color: var(--danger); font-size: 12px; margin-top: 4px; display: block; }
.input-validation-error { border-color: var(--danger) !important; }
.validation-summary-errors { background: var(--danger-bg); border: 1px solid #FECACA; border-radius: var(--radius); padding: 12px; margin-bottom: 16px; }
.validation-summary-errors ul { margin: 0; padding-left: 16px; color: var(--danger); font-size: 13px; }

/* ── Tables ──────────────────────────────────────── */
.table-container { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; }
.data-table th { background: var(--bg); padding: 10px 14px; text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); border-bottom: 2px solid var(--border); white-space: nowrap; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border-light); font-size: 13.5px; vertical-align: middle; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges / Status Chips ───────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.badge-pending   { background: #FEF3C7; color: #92400E; }
.badge-approved  { background: #D1FAE5; color: #065F46; }
.badge-rejected  { background: #FEE2E2; color: #991B1B; }
.badge-checkedin { background: #DBEAFE; color: #1E40AF; }
.badge-checkedout{ background: #F3F4F6; color: #374151; }
.badge-expired   { background: #F1F5F9; color: #64748B; }
.badge-active    { background: #D1FAE5; color: #065F46; }
.badge-inactive  { background: #F1F5F9; color: #64748B; }

/* ── Auth Page ───────────────────────────────────── */
.auth-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 40px; width: 100%; max-width: 420px; }
.auth-logo { text-align: center; margin-bottom: 30px; }
.auth-logo-icon { width: 64px; height: 64px; background: var(--primary); border-radius: 16px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; font-size: 28px; color: #fff; }
.auth-logo-title { font-size: 22px; font-weight: 700; }
.auth-logo-sub { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ── Webcam / Photo Capture ──────────────────────── */
.webcam-container { position: relative; background: #0F172A; border-radius: var(--radius-lg); overflow: hidden; aspect-ratio: 4/3; }
#webcamVideo, #capturedPhoto { width: 100%; height: 100%; object-fit: cover; }
.webcam-controls { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ── Gate Pass Print ─────────────────────────────── */
.gate-pass-card { background: white; border: 2px solid var(--primary); border-radius: var(--radius-lg); max-width: 520px; margin: 0 auto; overflow: hidden; }
.gate-pass-header { background: var(--primary); color: white; padding: 16px 20px; display: flex; align-items: center; gap: 12px; }
.gate-pass-header .logo { font-size: 24px; }
.gate-pass-header-text h2 { font-size: 16px; font-weight: 700; }
.gate-pass-header-text p { font-size: 11px; opacity: 0.8; margin-top: 2px; }
.gate-pass-body { padding: 20px; }
.gate-pass-visitor { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px dashed var(--border); }
.gate-pass-photo { width: 80px; height: 80px; border-radius: var(--radius); object-fit: cover; border: 2px solid var(--border); flex-shrink: 0; }
.gate-pass-photo-placeholder { width: 80px; height: 80px; border-radius: var(--radius); background: var(--bg); display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 30px; flex-shrink: 0; }
.gate-pass-info-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 12.5px; }
.gate-pass-info-row .label { color: var(--text-secondary); font-weight: 500; }
.gate-pass-info-row .value { font-weight: 600; text-align: right; max-width: 55%; }
.gate-pass-qr {
    text-align: center;
    padding: 16px;
    border-top: 1px dashed var(--border);
    position: relative;
    top: -45px;
}
.gate-pass-qr img { width: 140px; height: 140px; }
.gate-pass-number { font-family: 'JetBrains Mono', monospace; font-size: 18px; font-weight: 700; color: var(--primary); letter-spacing: 2px; margin-top: 8px; }
.gate-pass-footer {
    background: var(--bg);
    padding: 12px 20px;
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    position: relative;
    top: -46px;
}

/* ── Steps Wizard ────────────────────────────────── */
.steps-bar { display: flex; align-items: center; gap: 0; margin-bottom: 28px; }
.step { display: flex; align-items: center; gap: 8px; flex: 1; }
.step:last-child { flex: 0; }
.step-circle { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; border: 2px solid var(--border); background: white; color: var(--text-muted); transition: all var(--transition); }
.step.active .step-circle { background: var(--primary); border-color: var(--primary); color: white; }
.step.done .step-circle { background: var(--success); border-color: var(--success); color: white; }
.step-label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.step.active .step-label { color: var(--primary); }
.step.done .step-label { color: var(--success); }
.step-line { flex: 1; height: 2px; background: var(--border); margin: 0 8px; }
.step-line.done { background: var(--success); }

/* ── QR Scanner ──────────────────────────────────── */
.qr-scanner-container { border: 2px dashed var(--border); border-radius: var(--radius-lg); padding: 40px; text-align: center; }
.qr-result { margin-top: 20px; padding: 16px; border-radius: var(--radius); }

/* ── Dashboard Sections ───────────────────────────── */
.section-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.section-title i { color: var(--primary); }

/* ── Page Header ─────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h2 { font-size: 20px; font-weight: 700; }

/* ── Empty State ─────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; color: var(--border); }
.empty-state p { font-size: 14px; }

/* ── Visitor Photo ───────────────────────────────── */
.visitor-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.visitor-avatar-sm { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.avatar-placeholder { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }

/* ── Kiosk Mode ──────────────────────────────────── */
.kiosk-wrapper { background: linear-gradient(135deg, #EBF0FD, #F8FAFC); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.kiosk-card { background: white; border-radius: 20px; box-shadow: var(--shadow-lg); padding: 40px; width: 100%; max-width: 600px; }
.kiosk-header { text-align: center; margin-bottom: 32px; }
.kiosk-header h1 { font-size: 26px; font-weight: 800; color: var(--primary); }
.kiosk-header p { color: var(--text-secondary); margin-top: 6px; }

/* ── Search bar ──────────────────────────────────── */
.search-bar { display: flex; gap: 8px; }
.search-bar input { flex: 1; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { width: var(--sidebar-w-sm); }
  .sidebar .nav-label, .sidebar .nav-item span, .sidebar-logo span, .user-details { display: none; }
  .sidebar-header { padding: 20px 12px; justify-content: center; }
  .sidebar-toggle { display: none; }
  .sidebar-footer { padding: 12px; justify-content: center; }
  .main-wrapper { margin-left: var(--sidebar-w-sm); }
}

@media (max-width: 640px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w); }
  .sidebar .nav-label, .sidebar .nav-item span, .sidebar-logo span, .user-details { display: block; }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .mobile-menu-btn { display: flex; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 16px; }
}

@media print {
  .sidebar, .topbar, .no-print, .alert { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  body { background: white; }
}
