:root {
    /* Premium Government Palette: Navy & Gold */
    --primary: #0F2027;
    --primary-gradient: linear-gradient(135deg, #0F2027 0%, #203A43 50%, #2C5364 100%);
    
    --secondary: #1E313D;
    
    --accent: #D4AF37; /* Gold */
    --accent-light: rgba(212, 175, 55, 0.15);
    --accent-gradient: linear-gradient(135deg, #D4AF37, #F3E5AB);
    
    --success: #10B981;
    --success-light: rgba(16, 185, 129, 0.15);
    
    --warning: #F59E0B;
    --danger: #EF4444;
    
    /* Surface */
    --bg-main: #F4F7F6;
    --bg-gradient: linear-gradient(120deg, #e0c3fc 0%, #8ec5fc 100%); /* Subtle formal background */
    
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    
    --text-main: #1A202C;
    --text-muted: #718096;
    --border-color: rgba(203, 213, 225, 0.6);
    
    --sidebar-width: 270px;
    --topbar-height: 80px;
    
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --transition: 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

[data-theme="dark"] {
    --bg-main: #0B132B;
    --bg-gradient: linear-gradient(120deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    
    --glass-bg: rgba(26, 32, 44, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    
    --text-main: #F7FAFC;
    --text-muted: #A0AEC0;
}

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

body {
    background: var(--bg-gradient);
    background-size: 200% 200%;
    animation: gradientBG 15s ease infinite;
    color: var(--text-main);
    overflow-x: hidden;
    transition: background var(--transition), color var(--transition);
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #B49429; }

/* Utilities */
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.badge {
    padding: 5px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600;
}
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); border: 1px solid var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); border: 1px solid var(--warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid var(--danger); }

/* Layout */
.app-container { display: flex; min-height: 100vh; }
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    position: fixed; height: 100vh;
    display: flex; flex-direction: column; z-index: 100;
    box-shadow: var(--glass-shadow);
    transition: transform var(--transition);
}
.sidebar-header {
    height: var(--topbar-height);
    display: flex; flex-direction: column; justify-content: center;
    padding: 15px 25px 0 25px; border-bottom: 1px solid var(--glass-border);
}
.sidebar-header h2 {
    color: var(--accent); font-size: 1.8rem;
    display: flex; align-items: center; gap: 10px; transition: font-size 0.3s;
}
.sidebar-header .subtitle { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; transition: opacity 0.3s; white-space: nowrap; }

.sidebar-nav { flex: 1; padding: 25px 15px; display: flex; flex-direction: column; gap: 8px; }
.nav-item {
    display: flex; align-items: center; padding: 14px 20px;
    color: var(--text-main); text-decoration: none;
    border-radius: var(--radius-md); font-weight: 500;
    transition: all var(--transition);
}
.nav-item i { width: 30px; font-size: 1.3rem; color: var(--text-muted); transition: color var(--transition); }
.nav-item:hover { background: var(--accent-light); color: var(--accent); }
.nav-item:hover i { color: var(--accent); }
.nav-item.active { background: var(--primary-gradient); color: white; box-shadow: 0 5px 15px rgba(15,32,39,0.4); }
.nav-item.active i { color: var(--accent); }

.sidebar-footer { padding: 20px 25px; border-top: 1px solid var(--glass-border); }
.user-info { display: flex; align-items: center; gap: 15px; }
.avatar {
    width: 45px; height: 45px; border-radius: 50%;
    background: var(--accent-gradient); color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(212, 175, 55, 0.3);
}
.details .name { font-weight: 600; font-size: 0.95rem; display:block; }
.details .role { font-size: 0.8rem; color: var(--text-muted); }

/* Main Content */
.main-content {
    flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-height: 100vh;
    transition: margin-left var(--transition);
}

/* Sidebar Collapsed State */
.sidebar.collapsed { width: 85px; }
.sidebar.collapsed .sidebar-header { padding: 15px 0 0 0; align-items: center; }
.sidebar.collapsed .sidebar-header h2 span { display: none; }
.sidebar.collapsed .sidebar-header h2 { font-size: 0; }
.sidebar.collapsed .sidebar-header h2 i { font-size: 1.8rem; margin: 0; }
.sidebar.collapsed .sidebar-header .subtitle { opacity: 0; pointer-events: none; height: 0; margin: 0; }

.sidebar.collapsed .sidebar-nav { padding: 25px 10px; }
.sidebar.collapsed .nav-item { padding: 14px; justify-content: center; border-radius: 50%; width: 50px; height: 50px; margin: 0 auto; }
.sidebar.collapsed .nav-item span { display: none; }
.sidebar.collapsed .nav-item i { margin: 0; }

.sidebar.collapsed .sidebar-footer { padding: 20px 10px; display: flex; justify-content: center; }
.sidebar.collapsed .user-info .details { display: none; }
.sidebar.collapsed .avatar { width: 40px; height: 40px; }

.sidebar.collapsed ~ .main-content { margin-left: 85px; }
.topbar {
    height: var(--topbar-height);
    border-bottom: 1px solid var(--glass-border); display: flex; justify-content: space-between; align-items: center;
    padding: 0 40px; position: sticky; top: 0; z-index: 90; box-shadow: 0 4px 30px rgba(0,0,0,0.02);
}
#page-title { font-size: 1.5rem; font-weight: 600; color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 20px; }
.icon-btn {
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    color: var(--text-main); font-size: 1.2rem; cursor: pointer;
    width: 45px; height: 45px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; transition: all var(--transition);
}
.icon-btn:hover { background: var(--accent-light); color: var(--accent); transform: translateY(-2px); }

/* Views */
.view-section { display: none; padding: 40px; animation: slideFadeUp 0.6s cubic-bezier(0.165, 0.84, 0.44, 1); }
.view-section.active { display: block; }
@keyframes slideFadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
    border-radius: var(--radius-lg); padding: 30px;
    box-shadow: var(--glass-shadow); margin-bottom: 30px; transition: all var(--transition);
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.card-title { font-size: 1.3rem; font-weight: 600; display:flex; align-items:center; gap:10px;}

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 25px; margin-bottom: 35px; }
.stat-card {
    padding: 25px; border-radius: var(--radius-lg); display: flex; flex-direction: column; justify-content: space-between;
    box-shadow: var(--glass-shadow); transition: transform var(--transition); position: relative; overflow: hidden;
}
.stat-card:hover { transform: translateY(-5px); }
.stat-icon {
    width: 50px; height: 50px; border-radius: 50%;
    background: var(--accent-light); color: var(--accent);
    display: flex; align-items: center; justify-content: center; font-size: 1.5rem; margin-bottom: 15px;
}
.stat-details h3 { font-size: 0.95rem; color: var(--text-muted); font-weight: 500; margin-bottom: 5px; }
.stat-number { font-size: 2.2rem; font-weight: 700; color: var(--primary); line-height: 1; }
[data-theme="dark"] .stat-number { color: white; }

/* Table & Pagination */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0 10px; }
.data-table th {
    padding: 15px 20px; text-align: left; font-weight: 600; color: var(--text-muted); text-transform: uppercase; font-size: 0.85rem; letter-spacing: 1px;
    cursor: pointer; transition: color 0.2s; white-space: nowrap;
}
.data-table th:hover { color: var(--primary); }
.data-table th i { margin-left: 5px; opacity: 0.3; transition: opacity 0.2s; }
.data-table th:hover i { opacity: 1; }
.data-table th.active-sort { color: var(--accent); }
.data-table th.active-sort i { opacity: 1; color: var(--accent); }

.data-table td {
    padding: 18px 20px; text-align: left; background: var(--glass-bg); backdrop-filter: blur(5px);
    border-top: 1px solid var(--glass-border); border-bottom: 1px solid var(--glass-border); transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.data-table td:first-child { border-left: 1px solid var(--glass-border); border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
.data-table td:last-child { border-right: 1px solid var(--glass-border); border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }
.data-table tbody tr:hover td { background: rgba(255, 255, 255, 0.95); transform: scale(1.02); z-index: 10; position: relative; box-shadow: 0 5px 15px rgba(0,0,0,0.05); }
[data-theme="dark"] .data-table tbody tr:hover td { background: rgba(30, 41, 59, 0.95); box-shadow: 0 5px 15px rgba(0,0,0,0.4); }

/* Buttons & Inputs */
.btn {
    padding: 12px 25px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer;
    border: none; transition: all var(--transition); display: inline-flex; align-items: center; gap: 10px; font-size: 0.95rem;
}
.btn-primary { background: var(--primary-gradient); color: white; box-shadow: 0 4px 15px rgba(15,32,39,0.3); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15,32,39,0.5); }
.btn-accent { background: var(--accent-gradient); color: var(--primary); box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3); }
.btn-accent:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(212, 175, 55, 0.5); }
.btn-outline { background: var(--glass-bg); border: 1px solid var(--border-color); color: var(--text-main); }
.btn-outline:hover { background: var(--border-color); transform: translateY(-2px); }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.95rem; font-weight: 600; margin-bottom: 8px; color: var(--text-main); }
.form-input {
    width: 100%; padding: 14px 20px; border: 2px solid var(--border-color); border-radius: var(--radius-md);
    background: var(--glass-bg); color: var(--text-main); outline: none; transition: all var(--transition); font-size: 0.95rem;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-light); }

/* Search Highlight */
.search-box { position: relative; max-width: 500px; margin-bottom: 30px; }
.search-box i { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 1.2rem; }
.search-box input { padding-left: 55px; height: 60px; font-size: 1.1rem; border-radius: 30px; box-shadow: var(--glass-shadow); border: none; }
.search-box input:focus { box-shadow: 0 10px 30px rgba(212, 175, 55, 0.2); }
.search-stats { font-size: 0.9rem; color: var(--success); margin-left: 15px; font-weight: 500; display: none; }

/* Modal */
.modal {
    display: none; position: fixed; z-index: 1000; left: 0; top: 0;
    width: 100%; height: 100%; background-color: rgba(0,0,0,0.6); backdrop-filter: blur(5px);
    align-items: center; justify-content: center;
}
.modal.show { display: flex; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content { width: 90%; max-width: 600px; padding: 40px; position: relative; animation: slideFadeUp 0.4s ease; }
.close-btn { position: absolute; top: 25px; right: 30px; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }

/* Toast */
.toast {
    position: fixed; bottom: -100px; left: 50%; transform: translateX(-50%);
    background: var(--primary-gradient); color: white; padding: 12px 30px;
    border-radius: 30px; font-weight: 500; transition: bottom 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000; box-shadow: 0 10px 25px rgba(15,32,39, 0.4); display: flex; align-items: center; gap: 10px;
}
.toast.show { bottom: 40px; }
.toast i { color: var(--accent); }

/* Action Buttons */
.action-btn { background: transparent; border: none; cursor: pointer; font-size: 1.1rem; padding: 8px; border-radius: 8px; transition: all 0.2s; margin: 0 3px; }
.btn-view { color: var(--primary); }
.btn-view:hover { background: var(--accent-light); color: var(--accent); transform: scale(1.1); }
.btn-edit { color: var(--warning); }
.btn-edit:hover { background: rgba(245, 158, 11, 0.1); color: var(--warning); transform: scale(1.1); }
.btn-delete { color: var(--danger); }
.btn-delete:hover { background: rgba(239, 68, 68, 0.1); transform: scale(1.1); }

/* Notification Dropdown */
.notif-wrapper { position: relative; }
.notif-badge {
    position: absolute; top: -2px; right: -2px; width: 12px; height: 12px;
    background: var(--danger); border-radius: 50%; border: 2px solid white; display: none;
}
[data-theme="dark"] .notif-badge { border-color: var(--primary); }
.notif-badge.active { display: block; animation: pulseRed 2s infinite; }
@keyframes pulseRed { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); } 70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }

.notif-panel {
    position: absolute; top: 60px; right: 0; width: 350px; background: var(--glass-bg); backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border); border-radius: var(--radius-md); box-shadow: var(--glass-shadow);
    display: none; flex-direction: column; z-index: 1000; overflow: hidden;
    transform-origin: top right; transform: scale(0.9); opacity: 0; transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.notif-panel.show { display: flex; transform: scale(1); opacity: 1; }
.notif-header { padding: 15px 20px; border-bottom: 1px solid var(--glass-border); font-weight: 600; color: var(--primary); display: flex; justify-content: space-between; align-items: center; }
.notif-clear { font-size: 0.8rem; color: var(--text-muted); cursor: pointer; transition: color 0.3s; }
.notif-clear:hover { color: var(--danger); }
.notif-body { max-height: 300px; overflow-y: auto; }
.notif-item { padding: 15px 20px; border-bottom: 1px solid var(--glass-border); display: flex; gap: 15px; align-items: flex-start; transition: background 0.3s; cursor: pointer; }
.notif-item:hover { background: rgba(0,0,0,0.03); }
[data-theme="dark"] .notif-item:hover { background: rgba(255,255,255,0.03); }
.notif-item .icon { width: 35px; height: 35px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; flex-shrink: 0; }
.notif-item .content h4 { font-size: 0.9rem; margin-bottom: 3px; color: var(--text-main); }
.notif-item .content p { font-size: 0.8rem; color: var(--text-muted); margin: 0; }
.notif-item .time { font-size: 0.7rem; color: var(--text-muted); margin-top: 5px; display: block; }
.notif-empty { padding: 30px; text-align: center; color: var(--text-muted); font-size: 0.9rem; }

/* Detail View Modal & PDF Fake Viewer */
.detail-table { width: 100%; border-collapse: collapse; margin-top: 15px; }
.detail-table td { padding: 12px 15px; border-bottom: 1px solid var(--glass-border); }
.detail-table td:first-child { font-weight: 600; color: var(--text-muted); width: 35%; }
.detail-table td:last-child { color: var(--text-main); font-weight: 500; }

.pdf-viewer {
    background: #525659; border-radius: 8px; overflow: hidden; display: flex; flex-direction: column;
    height: 600px; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.pdf-toolbar {
    background: #323639; padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; color: white;
}
.pdf-tools { display: flex; gap: 15px; font-size: 1.1rem; }
.pdf-tools i { cursor: pointer; opacity: 0.7; transition: 0.2s; }
.pdf-tools i:hover { opacity: 1; }
.pdf-body {
    flex: 1; display: flex; justify-content: center; overflow-y: auto; padding: 20px; background: #525659;
}
.pdf-page {
    background: white; width: 100%; max-width: 600px; min-height: 800px; box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    padding: 40px; position: relative;
}
.pdf-skeleton { background: #eee; height: 12px; margin-bottom: 10px; border-radius: 4px; }
.pdf-skeleton.title { height: 20px; width: 60%; margin-bottom: 25px; background: #ddd; }
.pdf-skeleton.short { width: 80%; }
.pdf-skeleton.image { height: 150px; background: #f5f5f5; margin: 20px 0; border: 1px solid #ddd; }

/* Pagination Controls */
.pagination-container {
    display: flex; justify-content: space-between; align-items: center; margin-top: 20px; padding: 10px 0;
}
.pagination-info { font-size: 0.9rem; color: var(--text-muted); font-weight: 500; }
.pagination-controls { display: flex; gap: 10px; }
.page-btn {
    padding: 8px 15px; border-radius: 6px; border: 1px solid var(--border-color); background: var(--glass-bg);
    cursor: pointer; transition: all 0.2s; font-weight: 600; color: var(--text-main);
}
.page-btn:hover:not(:disabled) { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Responsive Design (Mobile Friendly) */
@media (max-width: 768px) {
    /* Sidebar as Off-Canvas Drawer */
    .sidebar { transform: translateX(-100%); }
    .sidebar.collapsed { transform: translateX(0); width: var(--sidebar-width); }
    
    /* Reset Collapsed state for mobile so it opens fully */
    .sidebar.collapsed .sidebar-header { padding: 15px 25px 0 25px; align-items: flex-start; }
    .sidebar.collapsed .sidebar-header h2 span { display: inline; }
    .sidebar.collapsed .sidebar-header h2 { font-size: 1.8rem; }
    .sidebar.collapsed .sidebar-header .subtitle { opacity: 1; pointer-events: auto; height: auto; margin-top: 3px; }
    .sidebar.collapsed .sidebar-nav { padding: 25px 15px; }
    .sidebar.collapsed .nav-item { padding: 14px 20px; justify-content: flex-start; border-radius: var(--radius-md); width: auto; height: auto; }
    .sidebar.collapsed .nav-item span { display: inline; }
    .sidebar.collapsed .nav-item i { margin-right: 15px; width: 30px; }
    .sidebar.collapsed .sidebar-footer { padding: 20px 25px; justify-content: flex-start; }
    .sidebar.collapsed .user-info .details { display: block; }
    
    /* Main Content */
    .main-content, .sidebar.collapsed ~ .main-content { margin-left: 0; }
    .topbar { padding: 0 15px; }
    #current-time { display: none; }
    
    /* Layouts */
    .stats-grid { grid-template-columns: 1fr; gap: 15px; }
    .card-header { flex-direction: column; align-items: flex-start; gap: 15px; }
    .card-header > div { width: 100%; flex-direction: column; gap: 10px; }
    .card-header > div button { width: 100%; }
    
    /* Modal Forms */
    .modal-content { width: 95%; padding: 20px; }
    #upload-form .form-group[style*="flex"] { flex-direction: column !important; }
    
    /* Pagination */
    .pagination-container { flex-direction: column; gap: 15px; align-items: flex-start; }
    
    /* Notification */
    .notif-panel { right: -60px; width: 320px; }
    
    /* Fake PDF Viewer */
    .pdf-viewer { height: 450px; }
    .pdf-page { padding: 20px; }
}
