/* =====================================================================
   VMS Stylesheet - Mobile-first, PWA-ready
   ===================================================================== */
:root {
    --teal-900: #0f3d3e;
    --teal-700: #14544f;
    --teal-500: #1a7a72;
    --teal-300: #4fb3a9;
    --gold: #c9a227;
    --navy: #0b1f3a;
    --bg: #f4f7f6;
    --card-bg: #ffffff;
    --text-dark: #1c2b2b;
    --text-muted: #6b7c7c;
    --danger: #c0392b;
    --success: #1e8e5a;
    --warning: #b8860b;
    --border: #e1e8e7;
    --radius: 10px;
    --shadow: 0 2px 10px rgba(15, 61, 62, 0.08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text-dark);
    -webkit-tap-highlight-color: transparent;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }

.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

/* ---- Topbar ---- */
.topbar {
    display: flex; align-items: center; gap: 12px;
    background: var(--teal-900); color: #fff;
    padding: 12px 16px;
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow);
}
.hamburger { background: none; border: none; color: #fff; font-size: 22px; display: none; }
.topbar-title { font-weight: 700; font-size: 17px; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.notif-bell { position: relative; font-size: 20px; }
.notif-badge {
    position: absolute; top: -6px; right: -8px;
    background: var(--danger); color: #fff; font-size: 10px;
    border-radius: 10px; padding: 1px 5px; font-weight: 700;
}
.user-chip { display: flex; flex-direction: column; text-align: right; line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--teal-300); }

/* ---- Body layout ---- */
.app-body { display: flex; flex: 1; }
.sidebar {
    width: 230px; background: var(--teal-700); color: #fff;
    flex-shrink: 0; padding: 16px 0;
}
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px; color: #d7e8e6; font-size: 14px;
    border-left: 3px solid transparent;
}
.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,0.08); color: #fff;
    border-left-color: var(--gold);
}
.nav-icon { width: 20px; text-align: center; }
.nav-divider { height: 1px; background: rgba(255,255,255,0.15); margin: 10px 20px; }
.nav-logout { color: #f3c6c0; }

.main-content { flex: 1; padding: 20px; max-width: 1200px; }

/* ---- Cards ---- */
.card {
    background: var(--card-bg); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
    border: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 700; color: var(--teal-900); margin: 0 0 12px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
    background: var(--card-bg); border-radius: var(--radius); padding: 16px;
    box-shadow: var(--shadow); border-left: 4px solid var(--teal-500);
}
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.gold { border-left-color: var(--gold); }
.stat-value { font-size: 26px; font-weight: 800; color: var(--teal-900); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-dark); }
.form-control {
    width: 100%; padding: 12px; border: 1px solid var(--border);
    /* 16px is intentional, not a stylistic choice: anything smaller makes iOS Safari
       auto-zoom the page on focus, which is jarring on a touch device and exactly
       the kind of thing that needs to be right before this ships as a mobile app. */
    border-radius: 8px; font-size: 16px; background: #fff; color: var(--text-dark);
}
.form-control:focus { outline: none; border-color: var(--teal-500); box-shadow: 0 0 0 3px rgba(26,122,114,0.15); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 18px; border-radius: 8px; border: none;
    font-size: 15px; font-weight: 600; cursor: pointer;
    min-height: 44px; /* Apple HIG / Android tap-target minimum */
}
.btn-primary { background: var(--teal-700); color: #fff; }
.btn-primary:hover { background: var(--teal-900); }
.btn-gold { background: var(--gold); color: #1c2b2b; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-secondary { background: #eef2f2; color: var(--text-dark); }
.btn-outline { background: transparent; border: 1px solid var(--teal-500); color: var(--teal-700); }
.btn-sm { padding: 8px 14px; font-size: 13px; min-height: 36px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
    text-align: left; padding: 10px 12px; background: var(--teal-900); color: #fff;
    white-space: nowrap; font-weight: 600;
}
table.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:hover { background: #f8fbfa; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.badge-pending { background: #fff3cd; color: #8a6d00; }
.badge-approved { background: #d9f2ea; color: var(--success); }
.badge-checked_in { background: #d3e9ff; color: #0b5ea8; }
.badge-checked_out { background: #e3e6e6; color: #4a5656; }
.badge-expired { background: #f3d9d9; color: var(--danger); }
.badge-cancelled { background: #f3d9d9; color: var(--danger); }
.badge-rejected { background: #f3d9d9; color: var(--danger); }
.badge-active { background: #d9f2ea; color: var(--success); }
.badge-suspended { background: #fff3cd; color: #8a6d00; }
.badge-disabled { background: #f3d9d9; color: var(--danger); }

/* ---- Auth pages ---- */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--teal-900), var(--navy));
    padding: 20px;
}
.auth-card {
    background: #fff; border-radius: 14px; padding: 32px 28px;
    width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.auth-logo { text-align: center; margin-bottom: 8px; font-size: 22px; font-weight: 800; color: var(--teal-900); }
.auth-sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }

/* ---- Flash messages ---- */
.flash-container { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 320px; }
.flash { padding: 12px 16px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); display: flex; justify-content: space-between; gap: 10px; animation: slideIn 0.25s ease; }
.flash-success { background: #d9f2ea; color: var(--success); }
.flash-error { background: #f8d7da; color: var(--danger); }
.flash-info { background: #d3e9ff; color: #0b5ea8; }
.flash-close { background: none; border: none; font-size: 16px; cursor: pointer; color: inherit; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- QR display ---- */
.qr-box { text-align: center; padding: 20px; background: #fff; border-radius: var(--radius); border: 1px dashed var(--teal-500); }
.qr-box img { max-width: min(220px, 100%); height: auto; }
.visit-code-display { font-size: 30px; font-weight: 800; letter-spacing: 6px; color: var(--teal-900); margin: 10px 0; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(11,31,58,0.55); display: none; align-items: center; justify-content: center; z-index: 150; padding: 16px; }
.modal-overlay.open { display: flex; }
.modal-box { background: #fff; border-radius: 12px; padding: 22px; max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

/* ---- Responsive ---- */
@media (max-width: 860px) {
    .hamburger { display: block; }
    .sidebar {
        position: fixed; left: -240px; top: 0; bottom: 0; width: 230px;
        z-index: 100; transition: left 0.2s ease; padding-top: 64px;
    }
    .sidebar.open { left: 0; }
    .main-content { padding: 14px; }
    .user-chip { display: none; }
    .topbar-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---- Small phones ---- */
@media (max-width: 480px) {
    .main-content { padding: 10px; }
    .card { padding: 14px; }
    .modal-box { padding: 16px; }
    .qr-box { padding: 14px; }
    .visit-code-display { font-size: 24px; letter-spacing: 4px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-value { font-size: 22px; }
    /* Full-width action buttons stack cleanly instead of wrapping into an
       uneven row on a narrow screen. */
    .form-row { flex-direction: column; }
    .form-row .form-group { min-width: 100%; }
    table.data-table { font-size: 12px; }
    table.data-table th, table.data-table td { padding: 8px; }
}
