/* ── AegisVault UI — Dark / Light themes ── */

/* Dark theme (default) */
:root {
    --bg-primary:    #111111;
    --bg-secondary:  #191919;
    --bg-card:       #1e1e1e;
    --bg-card-hover: #252525;
    --bg-nav:        #0d0d0d;
    --bg-input:      #191919;

    --text-primary:   #efefef;
    --text-secondary: #9a9a9a;
    --text-muted:     #606060;

    --border:        #2a2a2a;
    --border-color:  #2a2a2a;

    --accent-blue:   #4a8fd4;
    --accent-red:    #d96060;
    --accent-green:  #4ca87a;
    --accent-yellow: #c9943a;
    --accent-purple: #7a6fc2;
    --accent-pink:   #a87aa0;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 0 1px rgba(74,143,212,0.2);
}

/* Light theme */
[data-theme="light"] {
    --bg-primary:    #f2f2f2;
    --bg-secondary:  #e8e8e8;
    --bg-card:       #ffffff;
    --bg-card-hover: #f7f7f7;
    --bg-nav:        #ffffff;
    --bg-input:      #f8f8f8;

    --text-primary:   #111111;
    --text-secondary: #555555;
    --text-muted:     #999999;

    --border:        #dedede;
    --border-color:  #dedede;

    --accent-blue:   #2563eb;
    --accent-red:    #dc2626;
    --accent-green:  #16a34a;
    --accent-yellow: #d97706;
    --accent-purple: #6d5da8;
    --accent-pink:   #9d6b8f;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.10);
    --shadow-glow: 0 0 0 1px rgba(37,99,235,0.2);
}

/* ── Reset ── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

html { overflow-x: hidden; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    max-width: 100vw;
}

/* ── Navbar ── */
.main-nav {
    background: var(--bg-nav);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 56px;
    width: 100%;
    box-sizing: border-box;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    text-decoration: none;
    padding-right: 16px;
    margin-right: 4px;
    border-right: 1px solid var(--border);
}

.nav-role {
    font-size: 10px;
    font-weight: 600;
    margin-left: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
}
.nav-role.admin { color: var(--accent-red);    background: rgba(217,96,96,0.12); }
.nav-role.soc   { color: var(--accent-purple); background: rgba(122,111,194,0.12); }
.nav-role.cse   { color: var(--accent-green);  background: rgba(76,168,122,0.12); }
.nav-role       { color: var(--accent-blue);   background: rgba(74,143,212,0.12); }

.nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
    border: 1px solid transparent;
    line-height: 1;
    cursor: pointer;
    background: none;
    font-family: inherit;
}
.nav-link:hover  { color: var(--text-primary); background: rgba(128,128,128,0.1); }
.nav-link.active { color: var(--accent-blue); background: rgba(74,143,212,0.1); border-color: rgba(74,143,212,0.2); }
.nav-link.logout { color: var(--accent-red); }
.nav-link.logout:hover { background: rgba(217,96,96,0.1); color: var(--accent-red); }

/* ── Dropdowns ── */
.nav-dropdown { position: relative; }

.nav-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
    font-family: inherit;
    line-height: 1;
}
.nav-dropdown-toggle:hover { color: var(--text-primary); background: rgba(128,128,128,0.1); }
.nav-dropdown.active .nav-dropdown-toggle {
    color: var(--accent-blue);
    background: rgba(74,143,212,0.1);
    border-color: rgba(74,143,212,0.2);
}

.nav-chevron {
    width: 12px; height: 12px;
    opacity: 0.5;
    transition: transform 0.18s ease;
    flex-shrink: 0;
}
.nav-dropdown.open .nav-chevron { transform: rotate(180deg); opacity: 0.9; }

.nav-dropdown-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 0;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
    z-index: 1050;
}
.nav-dropdown.open .nav-dropdown-panel {
    opacity: 1; visibility: visible; transform: translateY(0);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s;
}

.nav-dropdown-item {
    display: block;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: color 0.12s, background 0.12s;
}
.nav-dropdown-item:hover { color: var(--text-primary); background: rgba(128,128,128,0.1); }
.nav-dropdown-item.active { color: var(--accent-blue); background: rgba(74,143,212,0.08); }

/* ── Hamburger ── */
.nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 9px;
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
}
.nav-hamburger span {
    display: block; width: 18px; height: 2px;
    background: var(--text-secondary); border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Layout ── */
.container {
    padding: 28px 30px;
    max-width: 1500px;
    margin: 0 auto;
}

.page-header {
    margin-bottom: 28px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.page-header h1 { font-size: 22px; font-weight: 600; color: var(--text-primary); }
.page-header p  { color: var(--text-muted); margin-top: 4px; font-size: 14px; }

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.card:hover { border-color: rgba(74,143,212,0.25); }

.card h3 {
    color: var(--text-primary);
    margin-bottom: 18px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card h3::before {
    content: '';
    width: 3px; height: 16px;
    background: var(--accent-blue);
    border-radius: 2px;
    flex-shrink: 0;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.card-header h3 { margin-bottom: 0; }

/* ── Stat cards ── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent-blue);
}
.stat-card:hover { border-color: rgba(74,143,212,0.25); box-shadow: var(--shadow-sm); }
.stat-card.warning::before { background: var(--accent-red); }
.stat-card.success::before { background: var(--accent-green); }
.stat-card.info::before    { background: var(--accent-purple); }

.stat-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    margin-bottom: 14px;
    background: rgba(74,143,212,0.08);
}
.stat-card.warning .stat-icon { background: rgba(217,96,96,0.08); }
.stat-card.success .stat-icon { background: rgba(76,168,122,0.08); }
.stat-card.info .stat-icon    { background: rgba(122,111,194,0.08); }

.stat-number {
    font-size: 34px; font-weight: 600; color: var(--text-primary); line-height: 1;
}
.stat-card.warning .stat-number { color: var(--accent-red); }
.stat-card.success .stat-number { color: var(--accent-green); }
.stat-card.info .stat-number    { color: var(--accent-purple); }

.stat-label  { color: var(--text-muted); margin-top: 6px; font-size: 13px; font-weight: 500; }
.stat-value  { font-size: 26px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-info   { display: flex; flex-direction: column; }

/* ── Tables ── */
table { width: 100%; border-collapse: separate; border-spacing: 0; }

th, td { padding: 12px 16px; text-align: left; }

th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border);
}
th:first-child { border-radius: 8px 0 0 0; }
th:last-child  { border-radius: 0 8px 0 0; }

td {
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
}
tr:hover td {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
tr:last-child td:first-child { border-radius: 0 0 0 8px; }
tr:last-child td:last-child  { border-radius: 0 0 8px 0; }

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-secondary); font-size: 13px; }
.data-table tr:hover td { background: var(--bg-card-hover); color: var(--text-primary); }

/* ── Buttons ── */
.btn {
    background: var(--accent-blue);
    color: #fff;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-weight: 500;
    font-size: 13px;
    transition: filter 0.15s, transform 0.15s;
    font-family: inherit;
    line-height: 1.4;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-danger  { background: var(--accent-red); }
.btn-success { background: var(--accent-green); }
.btn-primary { background: var(--accent-blue); }
.btn-sm { padding: 7px 14px; font-size: 12px; }

/* ── Inputs ── */
input, select, textarea {
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    width: 100%;
    margin-bottom: 14px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input[type=checkbox], input[type=radio] {
    width: auto;
    padding: 0;
    margin-bottom: 0;
    border: none;
    background: none;
    cursor: pointer;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(74,143,212,0.15);
}
input::placeholder { color: var(--text-muted); }

label {
    display: block;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
    margin-bottom: 6px;
}

/* ── Badges ── */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.badge-danger  { background: rgba(217,96,96,0.12);   color: var(--accent-red);    border: 1px solid rgba(217,96,96,0.25); }
.badge-success { background: rgba(76,168,122,0.12);  color: var(--accent-green);  border: 1px solid rgba(76,168,122,0.25); }
.badge-warning { background: rgba(201,148,58,0.12);  color: var(--accent-yellow); border: 1px solid rgba(201,148,58,0.25); }
.badge-info    { background: rgba(122,111,194,0.12); color: var(--accent-purple); border: 1px solid rgba(122,111,194,0.25); }
.badge-secondary { background: rgba(128,128,128,0.1); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Alerts ── */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}
.alert-error   { background: rgba(217,96,96,0.08);   border: 1px solid rgba(217,96,96,0.25);   color: var(--accent-red); }
.alert-success { background: rgba(76,168,122,0.08);  border: 1px solid rgba(76,168,122,0.25);  color: var(--accent-green); }
.alert-warning { background: rgba(201,148,58,0.08);  border: 1px solid rgba(201,148,58,0.25);  color: var(--accent-yellow); }

/* ── Misc ── */
.progress-bar { height: 6px; background: var(--bg-secondary); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }

.filter-group { display: flex; gap: 10px; align-items: center; }
.filter-group select { margin-bottom: 0; width: auto; min-width: 140px; }

/* ── Theme toggle ── */
.theme-toggle {
    width: 34px; height: 34px;
    padding: 0;
    justify-content: center;
    color: var(--text-muted);
    border-radius: 8px;
}
.theme-toggle:hover { color: var(--text-primary); }

/* ── Animations ── */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.loading { animation: pulse 2s ease-in-out infinite; }

/* ── Responsive ── */
@media (max-width: 1200px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

/* ── Mobile nav — pure CSS checkbox toggle, no JS required ── */
.nav-cb           { display: none; }
.nav-mobile-dashboard { display: none; }

/* Backdrop: clicking it closes the menu (label toggles the checkbox) */
.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1190;
    background: rgba(0,0,0,0.45);
}

@media (max-width: 1280px) {
    /* Show hamburger label */
    .nav-hamburger {
        display: flex;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }
    /* Hide Dashboard from top bar on mobile */
    .nav-left .nav-link { display: none; }
    .nav-left  { flex: 1; min-width: 0; overflow: hidden; }
    .nav-brand { border-right: none; padding-right: 0; margin-right: 0; }

    /* Menu: hidden by default, full-height fixed overlay when checkbox checked */
    .nav-menu {
        display: none;
        flex-direction: column;
        align-items: stretch;
        position: fixed;
        top: 56px; left: 0; right: 0; bottom: 0;
        background: var(--bg-nav);
        border-top: 2px solid var(--accent-blue);
        padding: 6px 0 40px;
        z-index: 1200;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: 4px 0 24px rgba(0,0,0,0.6);
    }

    /* CSS toggle — no JavaScript needed */
    .nav-cb:checked ~ .nav-backdrop         { display: block; }
    .nav-cb:checked ~ nav .nav-menu         { display: flex; }
    /* Hamburger → X animation */
    .nav-cb:checked ~ nav .nav-hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .nav-cb:checked ~ nav .nav-hamburger span:nth-child(2) { opacity: 0; }
    .nav-cb:checked ~ nav .nav-hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

    /* Dashboard inside menu on mobile */
    .nav-mobile-dashboard {
        display: flex;
        border-bottom: 1px solid var(--border);
        padding-bottom: 4px;
        margin-bottom: 4px;
    }

    /* 48 px touch targets */
    .nav-link            { width: 100%; min-height: 48px; padding: 13px 20px; font-size: 15px; border-radius: 0; }
    .nav-dropdown        { width: 100%; }
    .nav-dropdown-toggle { width: 100%; min-height: 48px; justify-content: space-between; padding: 13px 20px; font-size: 15px; border-radius: 0; }

    /* Sub-menus inline */
    .nav-dropdown-panel  {
        position: static; opacity: 1; visibility: visible; transform: none;
        box-shadow: none; border: none; border-radius: 0;
        background: rgba(128,128,128,0.07);
        padding: 4px 0 4px 16px; display: none;
    }
    .nav-dropdown.open .nav-dropdown-panel { display: block; }
    .nav-dropdown-item   { padding: 12px 20px; font-size: 14px; min-height: 44px; display: flex; align-items: center; }
    .nav-menu .theme-toggle  { border-top: 1px solid var(--border); margin-top: 8px; }
    .nav-menu .nav-link.logout { color: var(--accent-red); }
}

/* ── Mobile (≤768px) ── */
@media (max-width: 768px) {
    .container   { padding: 12px; }
    .stats-grid  { grid-template-columns: repeat(2, 1fr); }
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .page-header > * { width: 100%; }

    .card        { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table, .data-table { min-width: 520px; }

    .grid        { grid-template-columns: 1fr !important; }
    .form-row    { grid-template-columns: 1fr; }
    .btn         { min-height: 44px; }
}

/* ── Small phones (≤480px) ── */
@media (max-width: 480px) {
    .stats-grid  { grid-template-columns: 1fr; }
    .nav-brand   { font-size: 12px; }
}

/* ── Modals (centered overlay; JS toggles inline display none/flex) ───── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}
.modal-content {
    position: relative;
    z-index: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 20px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
}
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.modal-close:hover { color: var(--text-primary); }
