/*
 * Copyright (c) Evan Webb, Australia - WebbMTS Modular Tech Systems.
 * Proprietary software. Unauthorized distribution, tampering, reverse engineering, or unlicensed use is prohibited.
 * Use is subject to WebbMTS commercial license and EULA terms.
 */

/* =========================================
    GLOBAL THEME & RESET
   ========================================= */
body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    background: #1a252f; 
    color: #ecf0f1; 
    margin: 0; 
    overflow-x: hidden;
}

/* Hide components by default */
#main-dashboard, #top-bar, .modal { 
    display: none; 
}

/* =========================================
    LOADING STATE
   ========================================= */
#loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #1a252f; display: flex; flex-direction: column;
    align-items: center; justify-content: center; z-index: 10000;
}

.spinner {
    width: 40px; height: 40px; border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: #3498db; border-radius: 50%; animation: spin 1s linear infinite;
    margin-bottom: 15px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================
    TOP BAR & USER CONTROLS
   ========================================= */
#top-bar { 
    background: #2c3e50; padding: 0 25px; display: flex;
    justify-content: space-between; align-items: center; 
    border-bottom: 2px solid #34495e; height: 78px; box-sizing: border-box;
}

.logo { font-size: 21px; font-weight: 600; color: #66b6ff; letter-spacing: 0.6px; }

/* Wrapper for User Info + Dropdown */
.user-controls { display: flex; align-items: center; gap: 15px; }

#user-display { 
    font-size: 14px; color: #95a5a6; font-weight: 600; 
}

.user-dropdown { position: relative; display: inline-block; }

/* The Menu Button (Icon only) */
.dropbtn {
    background: #34495e; color: #ecf0f1; width: 36px; height: 36px; 
    border: 1px solid #455a64; border-radius: 6px; cursor: pointer; 
    transition: 0.2s; display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.user-dropdown:hover .dropbtn { background: #3e5871; border-color: #3498db; }

/* THE FIX: Invisible bridge to prevent menu closing over the gap */
.user-dropdown::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 15px;
    display: block;
}

.dropdown-content {
    display: none; position: absolute; right: 0; background-color: #2c3e50; 
    min-width: 200px; box-shadow: 0px 8px 16px rgba(0,0,0,0.4);
    z-index: 1000; border-radius: 6px; border: 1px solid #455a64; 
    margin-top: 10px; overflow: hidden;
}
.dropdown-content a {
    color: #ecf0f1; padding: 12px 16px; text-decoration: none; display: block; 
    font-size: 13px; transition: 0.2s; cursor: pointer;
}
.dropdown-content a:hover { background-color: #34495e; color: #3498db; }
.user-dropdown:hover .dropdown-content { display: block; }

/* =========================================
    MODALS (Fixed Flex behavior)
   ========================================= */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0, 0, 0, 0.75); z-index: 9999;
    backdrop-filter: blur(4px);
    align-items: center; justify-content: center; 
}

/* =========================================
    MAIN LAYOUT & CARDS
   ========================================= */
.card { 
    background: #2c3e50; padding: 30px; border-radius: 12px; width: 94%; 
    max-width: 1400px; margin: 30px auto; box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
}
h1#dept-title { margin-top: 0; color: #8ecbff; font-size: 24px; }

/* =========================================
    TABS & NAVIGATION
   ========================================= */
.tab-container { border-bottom: 2px solid #34495e; margin-bottom: 25px; display: flex; align-items: flex-end; flex-wrap: wrap; }
.tab { 
    padding: 12px 20px; cursor: pointer; color: #95a5a6; 
    display: block; font-weight: 600; transition: 0.2s;
}
.tab:hover { color: #ecf0f1; }
.tab.active { color: #3498db; border-bottom: 3px solid #3498db; }
.tab-right { margin-left: auto; }

.settings-toc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 8px;
    padding-bottom: 14px;
    border-bottom: 1px solid #34495e;
}

.settings-toc-col {
    border-right: 1px dashed #3a4d5f;
    padding-right: 16px;
}

.settings-toc-col:last-child {
    border-right: none;
}

.settings-toc-col h3 {
    margin: 0 0 10px 0;
    color: #ecf0f1;
    font-size: 30px;
    font-weight: 300;
}

.settings-toc-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
    height: auto;
    padding: 10px 12px;
    border: 1px solid #3a4d5f;
    border-radius: 8px;
    background: #1f2c36;
    text-align: left;
    color: #95a5a6;
}
.settings-toc-item + .settings-toc-item {
    margin-top: 10px;
}

.settings-toc-item:hover {
    border-color: #3498db;
    color: #ecf0f1;
    transform: translateY(-1px);
}

.settings-toc-item.active {
    border-color: #3498db;
    background: #22384a;
    color: #ecf0f1;
}

.settings-toc-title {
    color: #66b6ff;
    font-size: 26px;
    line-height: 1.1;
    font-weight: 500;
}

.settings-toc-desc {
    color: #95a5a6;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 400;
}

/* =========================================
    SHARED BUTTONS & INPUTS
   ========================================= */
button { 
    height: 40px; padding: 0 20px; border-radius: 6px; border: none; 
    font-weight: 700; cursor: pointer; transition: 0.2s; font-size: 13px;
}
.btn-blue { background: #3498db; color: white; }
.btn-blue:hover { background: #2980b9; transform: translateY(-1px); }
.btn-red { background: transparent; color: #e74c3c; border: 1px solid #e74c3c; }
.btn-red:hover { background: #e74c3c; color: white; }

.admin-input {
    width: 100%; padding: 10px; background: #1a252f; border: 1px solid #455a64; 
    color: white; border-radius: 6px; box-sizing: border-box;
}

.system-license-status {
    margin-top: 6px;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #455a64;
    background: #1a252f;
    color: #ecf0f1;
    font-size: 13px;
    line-height: 1.45;
}

.system-license-availability {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #455a64;
    background: #1a252f;
    display: grid;
    gap: 6px;
}

.system-license-availability-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 2px 0;
    font-size: 13px;
}

.system-license-availability-name {
    color: #ecf0f1;
}

.system-license-availability-value {
    color: #95a5a6;
}

/* =========================================
    DEPARTMENT SWITCHER
   ========================================= */
#switch-dept-list {
    display: flex; flex-direction: column; gap: 10px;
    max-height: 300px; overflow-y: auto; margin-top: 20px;
}
#switch-dept-list::-webkit-scrollbar { width: 6px; }
#switch-dept-list::-webkit-scrollbar-thumb { background: #34495e; border-radius: 3px; }

.dept-switch-option {
    background: #34495e; color: white; padding: 12px; border: 1px solid #455a64; 
    border-radius: 6px; text-align: left; cursor: pointer; transition: 0.2s;
}
.dept-switch-option:hover { background: #3e5871; border-color: #3498db; transform: translateX(3px); }
