/* LocalID - Official Red/Blue/White Theme Styling */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-gradient: #f1f5f9;
    --panel-bg: #ffffff;
    --panel-border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --accent-blue: #00529c;       /* Deep Official Blue */
    --accent-blue-hover: #003e75;
    --accent-red: #da251d;        /* Government Red */
    --accent-red-hover: #a81c15;
    --success: #16a34a;
    --warning: #ea580c;
    --danger: #dc2626;
    --border-radius: 8px;
    --transition: all 0.2s ease-in-out;
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    background-color: var(--bg-gradient);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Header & Navigation Styling */
header {
    background: var(--accent-blue);
    border-bottom: 3px solid var(--accent-red);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #ffffff;
}

.brand-logo {
    height: 40px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.brand-title {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #ffffff;
}

.user-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #ffffff;
}

.badge {
    padding: 0.25rem 0.65rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    display: inline-block;
}

.badge-admin { background: #fee2e2; color: var(--accent-red); border: 1px solid rgba(218, 37, 29, 0.3); }
.badge-ward { background: #dbeafe; color: var(--accent-blue); border: 1px solid rgba(0, 82, 156, 0.3); }
.badge-officer { background: #dcfce7; color: var(--success); border: 1px solid rgba(22, 163, 74, 0.3); }
.badge-pending { background: #ffedd5; color: var(--warning); border: 1px solid rgba(234, 88, 12, 0.3); }
.badge-active { background: #dcfce7; color: var(--success); border: 1px solid rgba(22, 163, 74, 0.3); }
.badge-rejected { background: #fee2e2; color: var(--danger); border: 1px solid rgba(220, 38, 38, 0.3); }

/* Buttons & Controls */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-size: 0.9rem;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}
.btn-primary:hover {
    background: var(--accent-blue-hover);
    box-shadow: 0 4px 10px rgba(0, 82, 156, 0.2);
}

.btn-secondary {
    background: #f8fafc;
    color: var(--text-primary);
    border: 1px solid #cbd5e1;
}
.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-danger {
    background: var(--accent-red);
    color: white;
}
.btn-danger:hover {
    background: var(--accent-red-hover);
    box-shadow: 0 4px 10px rgba(218, 37, 29, 0.2);
}

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover {
    background: #15803d;
    box-shadow: 0 4px 10px rgba(22, 163, 74, 0.2);
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
}
.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.95rem;
    transition: var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 82, 156, 0.15);
}
.form-control[readonly] {
    background-color: #f1f5f9;
    color: var(--text-secondary);
}

/* Cards & Panels */
.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius);
    padding: 1.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
}

.main-container {
    max-width: 1400px;
    width: 100%;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    flex-grow: 1;
}

/* Login Page Styling */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    padding: 2rem;
    background-color: #f8fafc;
}
.login-card {
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border-top: 4px solid var(--accent-red);
}
.login-card img {
    height: 90px;
    margin-bottom: 1.25rem;
}
.login-card h2 {
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    color: var(--accent-blue);
}
.login-card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Grid & Dashboard layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}
.kpi-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    border-left: 4px solid var(--accent-blue);
}
.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: #eff6ff;
    color: var(--accent-blue);
}
.kpi-details h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}
.kpi-details p {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Tables Styling */
.table-wrapper {
    overflow-x: auto;
    margin-top: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--panel-border);
}
table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background: #ffffff;
}
th {
    background: #f8fafc;
    color: var(--text-primary);
    padding: 0.85rem 1rem;
    font-weight: 700;
    font-size: 0.85rem;
    border-bottom: 2px solid var(--panel-border);
}
td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--panel-border);
    color: var(--text-primary);
    font-size: 0.9rem;
}
tr:hover td {
    background: #f8fafc;
}

/* Tabs Navigation */
.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--panel-border);
    margin-bottom: 1.5rem;
    padding-bottom: 1px;
}
.tab {
    padding: 0.6rem 1.2rem;
    border-radius: 4px 4px 0 0;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    border: 1px solid transparent;
    margin-bottom: -2px;
}
.tab.active {
    color: var(--accent-blue);
    background: #ffffff;
    border: 1px solid var(--panel-border);
    border-bottom-color: #ffffff;
}
.tab:hover:not(.active) {
    color: var(--text-primary);
    background: #e2e8f0;
}

/* Modal Popup Window */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.modal.active {
    opacity: 1;
    pointer-events: auto;
}
.modal-content {
    background: #ffffff;
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--panel-border);
    padding-bottom: 0.75rem;
}
.modal-header h3 {
    color: var(--accent-blue);
}
.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.75rem;
    cursor: pointer;
}
.modal-close:hover {
    color: var(--accent-red);
}

/* Camera Scanner Box */
.qr-scanner-box {
    width: 100%;
    max-width: 400px;
    height: 300px;
    margin: 0 auto 1.5rem;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: #000;
    border: 2px solid var(--accent-red);
}
.qr-scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 40px solid rgba(0,0,0,0.5);
    pointer-events: none;
}
.qr-scanner-laser {
    position: absolute;
    left: 40px;
    right: 40px;
    height: 2px;
    background: var(--accent-red);
    animation: scannerScan 2s linear infinite;
}
@keyframes scannerScan {
    0% { top: 40px; }
    50% { top: 260px; }
    100% { top: 40px; }
}

/* Alert Notification Banner */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    border: 1px solid transparent;
    font-weight: 500;
}
.alert-success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}
.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

/* Mobile responsive fixes */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
        align-items: center;
    }
    .user-status {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
        width: 100%;
    }
    .main-container {
        padding: 0 0.75rem;
        margin: 1rem auto;
    }
    
    /* Native-like Bottom Navigation Bar */
    .tabs {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #ffffff;
        border-top: 1px solid var(--panel-border);
        border-bottom: none;
        margin-bottom: 0;
        padding: 0.6rem 0.5rem;
        display: flex;
        justify-content: space-around;
        align-items: center;
        z-index: 999;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
        overflow-x: auto;
        white-space: nowrap;
    }
    .tab {
        border-radius: 8px;
        font-size: 0.75rem;
        padding: 0.5rem 0.7rem;
        border: none;
        margin-bottom: 0;
        flex-grow: 1;
        text-align: center;
    }
    .tab.active {
        background: rgba(0, 82, 156, 0.08);
        color: var(--accent-blue);
        border: none;
    }
    
    /* Push content up to avoid bottom tab overlaps */
    body {
        padding-bottom: 80px;
    }

    /* Native Bottom Sheet Modal Slide-Up Spring */
    .modal {
        align-items: flex-end;
    }
    .modal-content {
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        padding: 1.5rem;
        max-height: 85vh;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    .modal.active .modal-content {
        transform: translateY(0);
    }

    /* Pull drawer bottom alignment */
    #mobile-admin-drawer {
        align-items: flex-end;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
    #mobile-admin-drawer .modal-content {
        transform: translateY(100%);
        transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }
    #mobile-admin-drawer.active .modal-content {
        transform: translateY(0);
    }
}

/* Strict constraints to prevent camera video/canvas horizontal & vertical overflows */
#vneid-reader {
    width: 100% !important;
    max-width: 100% !important;
    position: relative !important;
    overflow: hidden !important;
    border-radius: 8px !important;
}
#vneid-reader * {
    max-width: 100% !important;
    box-sizing: border-box !important;
}
#vneid-reader video {
    width: 100% !important;
    height: auto !important;
    max-height: 45vh !important;
    object-fit: cover !important;
    display: block !important;
}
#vneid-reader canvas {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
}
