:root {
    /* Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    
    /* Glassmorphism */
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    
    /* Variables */
    --sidebar-width: 260px;
    --header-height: 70px;
    --border-radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    overflow-x: hidden;
    min-height: 100vh;
}

/* Background Decoration */
.bg-blob {
    position: absolute;
    filter: blur(80px);
    z-index: -1;
    border-radius: 50%;
    opacity: 0.5;
}
.blob-1 {
    width: 400px;
    height: 400px;
    background: rgba(59, 130, 246, 0.4);
    top: -100px;
    left: -100px;
}
.blob-2 {
    width: 300px;
    height: 300px;
    background: rgba(16, 185, 129, 0.3);
    bottom: -50px;
    right: -50px;
}

/* Base Components */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--glass-shadow);
}

.glass-nav {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: var(--glass-border);
}

h1, h2, h3, h4, h5 { font-weight: 600; }
p { color: var(--text-muted); }

/* Buttons */
button {
    cursor: pointer;
    border: none;
    outline: none;
    font-weight: 500;
    font-family: 'Outfit', sans-serif;
    border-radius: 10px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 14px;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-outline:hover { background: rgba(255,255,255,0.05); }
.btn-text { background: transparent; color: var(--primary); padding: 0; }
.btn-large { padding: 14px 24px; font-size: 16px; width: 100%; border-radius: 12px; }

button:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* Inputs */
.input-group {
    margin-bottom: 16px;
    position: relative;
    width: 100%;
}
.input-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-muted);
}
.input-group i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
}
.input-group input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: white;
    font-size: 14px;
    transition: var(--transition);
}
.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    outline: none;
}
.input-group input:not(:placeholder-shown) ~ i,
.input-group input:focus ~ i {
    color: var(--primary);
}

/* Forms */
.w-100 { width: 100%; }
.mt-3 { margin-top: 16px; }

/* Utilities */
.hidden { display: none !important; }

/* Layouts / SPA */
.app-container {
    width: 100%;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    opacity: 0;
    visibility: hidden;
    overflow-y: auto;
}

.page.active {
    opacity: 1;
    visibility: visible;
    z-index: 10;
}

/* ==================== LOGIN PAGE ==================== */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
}
.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px 30px;
    z-index: 2;
    animation: slideUp 0.6s ease;
}
.login-header {
    text-align: center;
    margin-bottom: 30px;
}
.logo-box {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 16px;
    font-size: 32px;
    color: white;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
}
.role-selector {
    display: flex;
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 24px;
}
.role-btn {
    flex: 1;
    background: transparent;
    color: var(--text-muted);
}
.role-btn.active {
    background: var(--glass-bg);
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ==================== USER APP ==================== */
.user-layout {
    height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    background: var(--bg-primary);
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}
.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    z-index: 20;
    position: sticky;
    top: 0;
}
.user-info-mini {
    display: flex;
    align-items: center;
    gap: 12px;
}
.avatar-mini {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
}
.user-info-mini h4 { margin-bottom: 2px; font-size: 15px; }
.user-info-mini span { font-size: 12px; color: var(--text-muted); }
.icon-btn {
    background: transparent;
    font-size: 24px;
    color: var(--text-main);
    padding: 8px;
}

.user-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 90px; /* space for bottom nav */
}

.user-view {
    display: none;
    animation: fadeIn 0.4s ease;
}
.user-view.active { display: block; }

/* User Dashboard Components */
.status-card {
    padding: 24px;
    text-align: center;
    margin-bottom: 20px;
}
.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.date-badge {
    background: rgba(255,255,255,0.1);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
}
.time-display {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 10px;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.location-status {
    font-size: 13px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Camera */
.camera-container {
    width: 100%;
    aspect-ratio: 3/4;
    max-width: 300px;
    margin: 0 auto 20px;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    background: #000;
    border: 2px solid var(--border-color);
}
#camera-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror */
}
.camera-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.action-btn {
    padding: 12px 8px;
    font-size: 13px;
    border-radius: 12px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.stat-box {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-box i {
    font-size: 32px;
    color: var(--primary);
    opacity: 0.8;
}

/* Bottom Nav */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    padding: 12px 10px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    border-top: var(--glass-border);
    z-index: 20;
}
.nav-item {
    background: transparent;
    flex-direction: column;
    gap: 4px;
    color: var(--text-muted);
    font-size: 11px;
    padding: 8px 16px;
}
.nav-item i { font-size: 24px; }
.nav-item.active {
    color: var(--primary);
}

/* ==================== ADMIN DASHBOARD ==================== */
.admin-layout {
    display: flex;
    height: 100vh;
}
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border-right: var(--glass-border);
    border-top: none;
    border-bottom: none;
    border-left: none;
    z-index: 20;
}
.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: var(--glass-border);
}
.logo-box-small {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
}
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    transition: var(--transition);
}
.menu-item i { font-size: 20px; }
.menu-item:hover { background: rgba(255,255,255,0.05); color: var(--text-main); }
.menu-item.active { background: rgba(59, 130, 246, 0.15); color: var(--primary); border-left: 3px solid var(--primary); }
.sidebar-footer { padding: 20px; border-top: var(--glass-border); }

.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.admin-header {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    border-bottom: var(--glass-border);
}
.header-search {
    position: relative;
    width: 300px;
}
.header-search input {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    padding: 8px 16px 8px 40px;
    border-radius: 20px;
    color: white;
}
.header-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-content-area {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}
.admin-view, .user-view {
    display: none;
    animation: fadeIn 0.4s ease;
}
.admin-view.active, .user-view.active { display: block; }
.admin-view > h2, .user-view > h2 { margin-bottom: 24px; font-size: 24px; }
.hidden { display: none !important; }
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

/* Admin Dashboard Stats */
.admin-stats { grid-template-columns: repeat(4, 1fr); margin-bottom: 30px; }
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
}
.bg-primary { background: rgba(59, 130, 246, 0.2); color: var(--primary); }
.bg-success { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.bg-warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.bg-danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); }

/* Tables */
.table-responsive { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.data-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.badge.success { background: rgba(16, 185, 129, 0.2); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge.danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge.warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }

/* Map & Settings */
.map-placeholder {
    height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-muted);
    background: rgba(0,0,0,0.2);
    border-radius: var(--border-radius);
}
.map-placeholder i { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.setting-card { padding: 24px; }
.setting-card h3 { margin-bottom: 20px; font-size: 18px; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.tab-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}
.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}
.modal.active {
    opacity: 1;
    visibility: visible;
}
.modal-content {
    width: 100%;
    max-width: 500px;
    padding: 24px;
    transform: translateY(20px);
    transition: var(--transition);
}
.modal.active .modal-content {
    transform: translateY(0);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.close-modal {
    background: transparent;
    color: var(--text-muted);
    font-size: 24px;
    padding: 4px;
}
.close-modal:hover { color: white; }

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: var(--glass-border);
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: slideLeft 0.3s ease;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideLeft { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }

/* Responsive */
@media (max-width: 768px) {
    .admin-layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; display: none; } /* On mobile admin might need toggle, omitted for brevity */
    .admin-stats { grid-template-columns: 1fr 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
}
