/* =====================================================
   VISITOR MANAGEMENT SYSTEM — Design System
   ===================================================== */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

/* === CSS Variables === */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2130;
    --bg-hover: #252840;
    --border: #2e3250;
    --border-light: #3d4278;

    --accent: #6c63ff;
    --accent-light: #8b85ff;
    --accent-glow: rgba(108, 99, 255, 0.18);

    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --info: #38bdf8;
    --info-bg: rgba(56, 189, 248, 0.12);

    --text-primary: #e8eaf6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --sidebar-w: 260px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.25);
    --transition: all 0.2s ease;
}

/* === Reset & Base === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    font-family: "Inter", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
}

a {
    color: var(--accent-light);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: var(--accent);
}

/* === App Shell === */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo .logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 0 16px var(--accent-glow);
}

.sidebar-logo .logo-text {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.2;
}

.sidebar-logo .logo-text span {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 12px 8px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-glow);
    color: var(--accent-light);
    border: 1px solid rgba(108, 99, 255, 0.25);
}

.nav-item .nav-icon {
    font-size: 17px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
}
.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-top: 8px;
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    font-size: 13px;
}

.btn-logout:hover {
    background: var(--danger-bg);
}

/* === Main Content === */
.main-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-title {
    font-size: 18px;
    font-weight: 600;
}
.topbar-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.page-content {
    padding: 28px;
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-card);
}

.card-sm {
    padding: 16px;
}

/* === Stat Cards === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.purple {
    background: var(--accent-glow);
}
.stat-icon.green {
    background: var(--success-bg);
}
.stat-icon.yellow {
    background: var(--warning-bg);
}
.stat-icon.red {
    background: var(--danger-bg);
}
.stat-icon.blue {
    background: var(--info-bg);
}

.stat-info {
}
.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}
.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-light);
    color: #fff;
    box-shadow: 0 0 28px rgba(108, 99, 255, 0.4);
}

.btn-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}
.btn-success:hover {
    background: rgba(34, 197, 94, 0.2);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}
.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
}
.btn-block {
    width: 100%;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === Forms === */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: "Inter", sans-serif;
    font-size: 14px;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    cursor: pointer;
}
select.form-control option {
    background: var(--bg-card);
}

/* === Badges / Pills === */
.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.badge-active {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.25);
}
.badge-done {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(56, 189, 248, 0.25);
}
.badge-in-use {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.25);
}
.badge-avail {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.25);
}

/* === Table === */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

tbody td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 13px;
}

tbody tr:hover td {
    background: var(--bg-hover);
}
tbody tr:last-child td {
    border-bottom: none;
}

/* === Camera / Scan Area === */
.scan-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--border);
}

.scan-container video,
.scan-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scan-frame {
    width: 280px;
    height: 320px;
    border: 3px solid var(--info);
    border-radius: 20px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.5), inset 0 0 30px rgba(56,189,248,0.3);
    animation: pulse-frame 2s ease-in-out infinite;
}

@keyframes pulse-frame {
    0%, 100% { box-shadow: 0 0 0 9999px rgba(0,0,0,0.5), 0 0 15px rgba(56,189,248,0.4); }
    50%       { box-shadow: 0 0 0 9999px rgba(0,0,0,0.5), 0 0 35px rgba(56,189,248,0.8); }
}

.scan-status {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--accent-light);
    border: 1px solid rgba(108, 99, 255, 0.3);
}

/* === Alerts === */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.25);
}
.alert-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
}
.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.25);
}
.alert-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(56, 189, 248, 0.25);
}

/* === Loading Spinner === */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* === Divider === */
.divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}

/* === Utilities === */
.flex {
    display: flex;
}
.flex-col {
    flex-direction: column;
}
.items-center {
    align-items: center;
}
.justify-between {
    justify-content: space-between;
}
.gap-8 {
    gap: 8px;
}
.gap-12 {
    gap: 12px;
}
.gap-16 {
    gap: 16px;
}
.gap-24 {
    gap: 24px;
}
.mt-4 {
    margin-top: 4px;
}
.mt-8 {
    margin-top: 8px;
}
.mt-16 {
    margin-top: 16px;
}
.mt-24 {
    margin-top: 24px;
}
.mb-16 {
    margin-bottom: 16px;
}
.mb-24 {
    margin-bottom: 24px;
}
.w-full {
    width: 100%;
}
.text-sm {
    font-size: 12px;
}
.text-muted {
    color: var(--text-muted);
}
.text-success {
    color: var(--success);
}
.text-danger {
    color: var(--danger);
}
.text-accent {
    color: var(--accent-light);
}
.font-bold {
    font-weight: 700;
}
.font-semi {
    font-weight: 600;
}
.rounded {
    border-radius: var(--radius-sm);
}

/* === Login Page === */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    background-image:
        radial-gradient(
            ellipse at 20% 50%,
            rgba(108, 99, 255, 0.08) 0%,
            transparent 60%
        ),
        radial-gradient(
            ellipse at 80% 20%,
            rgba(56, 189, 248, 0.05) 0%,
            transparent 60%
        );
}

.login-box {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo .icon {
    width: 60px;
    height: 60px;
    background: var(--accent);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 12px;
    box-shadow: 0 0 30px var(--accent-glow);
}

.login-logo h1 {
    font-size: 20px;
    font-weight: 700;
}
.login-logo p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* === Checkin Page Layout === */
.checkin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .checkin-grid {
        grid-template-columns: 1fr;
    }
}

/* === Visitor Photo === */
.visitor-photo {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.visitor-photo-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border: 2px solid var(--border);
}

/* === OCR Result Preview === */
.ocr-preview {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    max-height: 140px;
    overflow-y: auto;
    font-family: monospace;
    white-space: pre-wrap;
    display: none;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow);
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-overlay.open .modal-box {
    transform: scale(1);
}

/* === Mobile Responsiveness === */
@media (max-width: 768px) {
    .app-shell {
        flex-direction: column;
        overflow-y: auto;
    }
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        padding: 12px;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .sidebar-logo, .sidebar-footer {
        display: none;
    }
    .sidebar-nav {
        display: flex;
        flex-direction: row;
        gap: 10px;
        padding: 0;
        margin: 0;
        align-items: center;
    }
    .nav-section-label {
        display: none;
    }
    .nav-item {
        padding: 8px 12px;
        white-space: nowrap;
        margin-bottom: 0;
    }
    .main-content {
        padding: 10px;
        flex: unset;
        min-height: calc(100vh - 60px); 
    }
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 16px;
    }
    .checkin-grid {
        grid-template-columns: 1fr;
    }
    .scan-frame {
        width: 220px;
        height: 260px;
    }
    .flex.items-center.gap-16 {
        flex-direction: column;
        align-items: stretch;
    }
    .stat-card {
        min-width: 100%;
    }
}
