:root {
    --bg-color: #120512;
    --accent-color: #e95420;
    --text-main: #ffffff;
    --text-dim: #aea79f;
    --glass-bg: rgba(30, 20, 40, 0.4);
    --glass-border: rgba(255, 255, 255, 0.12);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    background-color: var(--bg-color);
    overflow-x: hidden;
}

/* --- SIDEBAR (Fixed Left Pane) --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    background: var(--bg-color);
    border-right: 1px solid var(--glass-border);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Increased slightly to 85px to fit the profile picture perfectly */
.sidebar.collapsed {
    width: 85px;
}

/* Branding Area - Anchored to the Left */
.sidebar-brand-area {
    height: 75px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 0 15px;
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: padding 0.3s ease, align-items 0.3s ease;
}

.logo { color: var(--accent-color); font-weight: bold; font-size: 20px; text-align: left; line-height: 1.2; transition: 0.3s; }
.version { font-size: 10px; color: var(--text-dim); margin-top: 3px; letter-spacing: 1px; transition: 0.3s; }

/* The fix for the collapsed Logo stacking & Version */
.sidebar.collapsed .sidebar-brand-area {
    align-items: center;
    padding: 0;
}

.sidebar.collapsed .sidebar-brand-area .logo {
    font-size: 12px;
    white-space: normal;
    text-align: center;
    width: 60px;
    line-height: 1.3;
}

.sidebar.collapsed .sidebar-brand-area .version {
    display: block;
    font-size: 8px;
    text-align: center;
    margin-top: 4px;
    letter-spacing: 0.5px;
}

/* Dashboard Title & Hamburger Row - Anchored Left */
.sidebar-control-row {
    display: flex;
    align-items: center;
    padding: 20px 15px 10px 15px;
    min-height: 54px;
    white-space: nowrap;
    overflow: hidden;
}

.hamburger {
    color: var(--accent-color);
    font-size: 20px;
    cursor: pointer;
    min-width: 24px;
    text-align: center;
    margin-right: 12px;
    transition: 0.2s;
}
.hamburger:hover { opacity: 0.8; }

.sidebar-page-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--text-main);
    letter-spacing: 1px;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: translateY(0);
}

.sidebar.collapsed .sidebar-page-title { display: none; }

/* Animations for collapsing */
.sidebar.collapsed .profile-info,
.sidebar.collapsed .menu-text,
.sidebar.collapsed .menu-section-title,
.sidebar.collapsed .empty-modules {
    opacity: 0;
    transform: translateY(15px);
    pointer-events: none;
    position: absolute;
    visibility: hidden;
}

.sidebar-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar-body::-webkit-scrollbar { width: 4px; }
.sidebar-body::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }

/* Profile Section - Anchored Left */
.profile-section {
    margin: 10px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    min-height: 57px;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed .profile-section {
    background: transparent;
    border-color: transparent;
}

.profile-icon { width: 35px; height: 35px; min-width: 35px; border-radius: 50%; object-fit: cover; border: 1px solid var(--accent-color); }
.profile-info { display: flex; flex-direction: column; transition: all 0.3s ease; }
.profile-name { color: var(--text-main); font-size: 13px; }
.profile-role { color: var(--accent-color); font-size: 10px; font-weight: bold; }

/* Menu Items - Anchored Left */
.sidebar-menu { padding: 0 15px 15px 15px; flex-grow: 1; }
.sidebar-menu ul { list-style: none; display: flex; flex-direction: column; }

.menu-icon { font-size: 16px; min-width: 24px; text-align: center; margin-right: 12px; display: inline-block; }
.menu-text { transition: opacity 0.3s ease, transform 0.3s ease; transform: translateY(0); }

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.2s ease, border 0.2s ease, color 0.2s ease;
    cursor: pointer;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.menu-item:hover { background: rgba(255, 255, 255, 0.1); color: var(--text-main); }
.menu-item.active { background-color: var(--accent-color); color: var(--text-main); font-weight: bold; border-color: var(--accent-color); }

.menu-section-title { font-size: 10px; color: var(--text-dim); text-transform: uppercase; margin: 15px 0 10px 5px; letter-spacing: 0.5px; transition: all 0.3s ease;}
.menu-divider { margin: 15px 0; border-top: 1px solid var(--glass-border); }

/* Updated Sticky Sidebar Footer */
.sidebar-footer {
    padding: 15px;
    border-top: 1px solid var(--glass-border);
    flex-shrink: 0;
    background: var(--bg-color);
    z-index: 10;
}
.logout-btn { background: rgba(255, 0, 0, 0.05); border-color: rgba(255,0,0,0.1); font-weight: bold;}
.logout-btn:hover { background: rgba(255, 0, 0, 0.2); }

/* --- MAIN WRAPPER --- */
.main-wrapper {
    margin-left: 280px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-wrapper.expanded { margin-left: 85px; }

/* Top Header */
.top-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    padding: 15px 40px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}
.top-header .clock-box { text-align: right; color: var(--text-dim); font-size: 11px; line-height: 1.6; font-weight: normal; }

/* Main Content Area */
.main-content {
    flex-grow: 1;
    padding: 30px 40px;
}

/* Footer */
.system-footer {
    background: #220D22;
    padding: 25px 40px;
    border-top: 1px solid var(--glass-border);
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.6;
}

/* CRITICAL FIX: Forces CSS Grid items to allow word-breaking */
.system-footer > div {
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-all;
}

.footer-center { text-align: center; }
.footer-right { text-align: right; }
.footer-link { color: var(--accent-color); text-decoration: none; font-weight: bold; }

/* --- RESPONSIVENESS --- */
@media (max-width: 992px) {
    .system-footer {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 15px;
    }
    .footer-right { text-align: center; }
}

@media (max-width: 768px) {
    .sidebar { width: 85px; }
    .sidebar:not(.collapsed) { width: 280px; box-shadow: 2px 0 15px rgba(0,0,0,0.5); }
    .main-wrapper { margin-left: 85px; }
    .main-wrapper.expanded { margin-left: 85px; }

    .top-header { grid-template-columns: 1fr; text-align: center; gap: 15px; padding: 15px; }
    .top-header .clock-box { text-align: center; }

    /* FLEX OVERRIDE: Eliminates CSS Grid width limits entirely on mobile */
    .system-footer {
        display: flex;
        flex-direction: column;
        padding: 25px 20px;
        gap: 15px;
        text-align: center;
    }
}

/* --- SESSION TIMEOUT MODAL --- */
.timeout-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.timeout-modal-box {
    background: #1a0a1a;
    padding: 30px 35px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    max-width: 420px;
    width: 90%;
    box-shadow: 0 15px 50px rgba(0,0,0,0.6);
    animation: slideDownFade 0.4s ease forwards;
}

.btn-extend {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 13px;
    transition: opacity 0.2s;
}

.btn-extend:hover {
    opacity: 0.85;
}

@keyframes slideDownFade {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}