/**
 * ASEAN CT - Master Unified Stylesheet
 * Version: 2.6 (Feb 2026) - Fixed Header Structure
 * Handles: Sidebar, IAM, MDM, LIMS, and Statistics
 */

:root {
    /* Corporate Color Palette */
    --accent: #3498db;
    --primary-bg: #f5f7fa;
    --sidebar-bg: #ffffff;
    --sidebar-text: #5f6c80;
    --sidebar-border: #e6e9ef;
    --card-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #7f8c8d;
    --success: #27ae60;
    --danger: #c0392b;
    --warning: #f39c12;
    --slate: #34495e;
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --primary-bg: #121416;
    --sidebar-bg: #1c1e21;
    --sidebar-text: #a0aec0;
    --sidebar-border: #2d3238;
    --card-bg: #24272b;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --accent: #5dade2;
}

* { box-sizing: border-box; }
body { 
    margin: 0; 
    display: flex; 
    font-family: 'Inter', 'Segoe UI', sans-serif; 
    background: var(--primary-bg); 
    color: var(--text-main); 
    line-height: 1.5;
    min-height: 100vh;
}

/* --- SIDEBAR NAVIGATION --- */
.sidebar { 
    width: 250px; 
    height: 100vh; 
    background: var(--sidebar-bg); 
    border-right: 1px solid var(--sidebar-border); 
    position: fixed; 
    display: flex; 
    flex-direction: column; 
    z-index: 100; 
}
.sidebar-brand { 
    padding: 25px; 
    font-weight: 800; 
    color: var(--accent); 
    border-bottom: 1px solid var(--sidebar-border); 
    font-size: 18px; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
}
.nav-scroll { 
    flex: 1; 
    overflow-y: auto; 
    padding: 15px 10px; 
}
.nav-label { 
    font-size: 10px; 
    font-weight: 700; 
    color: #a0aec0; 
    text-transform: uppercase; 
    padding: 10px 15px; 
    letter-spacing: 1px; 
}
.nav-item { 
    display: flex; 
    align-items: center; 
    padding: 11px 15px; 
    color: var(--sidebar-text); 
    text-decoration: none; 
    font-size: 13px; 
    border-radius: 8px; 
    margin-bottom: 2px; 
    transition: 0.2s; 
}
.nav-item:hover, .nav-item.active { 
    background: var(--primary-bg); 
    color: var(--accent); 
    font-weight: 600; 
}
.nav-item i { 
    width: 18px; 
    margin-right: 10px; 
    opacity: 0.6; 
}

/* --- MAIN VIEWPORT & HEADERS --- FIXED STRUCTURE */
.main-viewport { 
    flex: 1; 
    margin-left: 250px; 
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* GLOBAL PAGE HEADER - FIXED POSITION */
.global-page-header {
    position: sticky;
    top: 0;
    z-index: 99;
    background: linear-gradient(to right, var(--card-bg), var(--primary-bg));
    padding: 25px 40px;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    min-height: 80px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-left h1 { 
    font-size: 26px; 
    margin: 0; 
    font-weight: 800; 
    color: var(--text-main); 
    letter-spacing: -0.5px;
}

.header-left p { 
    color: var(--text-muted); 
    font-size: 14px; 
    margin: 5px 0 0 0;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Status Badge */
.status-badge {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}

.status-badge.warning {
    background: rgba(243, 156, 18, 0.15);
    color: var(--warning);
    border: 1px solid rgba(243, 156, 18, 0.3);
}

.status-badge.warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.2);
}

/* User Profile Block */
.user-profile-block {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--card-bg);
    border-radius: 10px;
    border: 1px solid var(--sidebar-border);
    transition: 0.2s;
}

.user-profile-block:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.user-info {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.user-role {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.logout-trigger {
    width: 40px;
    height: 40px;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e74c3c;
    text-decoration: none;
    transition: 0.2s;
}

.logout-trigger:hover {
    background: #e74c3c;
    color: white;
    transform: rotate(90deg);
}

/* --- CONTENT BODY --- This holds your page content */
.content-body {
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
    background: var(--primary-bg);
}

/* --- STATISTICS TILES --- */
.stats-row { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 15px; 
    margin-bottom: 25px; 
}
.stat-box { 
    background: var(--card-bg); 
    padding: 18px; 
    border-radius: 10px; 
    border: 1px solid var(--sidebar-border); 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    transition: 0.2s; 
}
.stat-box:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 4px 12px rgba(0,0,0,0.05); 
}
.stat-icon { 
    width: 42px; 
    height: 42px; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 16px; 
    background: var(--accent); 
    color: #fff; 
}
.stat-box h3 { 
    margin: 0; 
    font-size: 22px; 
    font-weight: 800; 
    color: var(--text-main); 
    line-height: 1; 
}
.stat-box small { 
    font-size: 11px; 
    color: var(--text-muted); 
    text-transform: uppercase; 
    font-weight: 700; 
}

/* --- REFINED SUB-SECTION HEADER --- */
.module-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 15px 0;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--sidebar-border);
}
.module-section-header .title-group { 
    border-left: 5px solid var(--accent); 
    padding-left: 15px; 
}
.module-section-header h3 { 
    margin: 0; 
    font-size: 18px; 
    font-weight: 800; 
    color: var(--text-main); 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
}
.module-section-header p { 
    margin: 3px 0 0; 
    font-size: 12px; 
    color: var(--text-muted); 
}

/* --- GLOBAL TAB SYSTEM --- */
.tab-container { 
    background: var(--card-bg); 
    border: 1px solid var(--sidebar-border); 
    border-radius: 12px; 
    min-height: 600px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.03); 
    overflow: hidden; 
}
.tab-nav { 
    display: flex; 
    background: #fafafa; 
    border-bottom: 1px solid var(--sidebar-border); 
    padding: 0 10px; 
}
.tab-trigger { 
    padding: 18px 25px; 
    border: none; 
    background: none; 
    cursor: pointer; 
    font-size: 12px; 
    font-weight: 700; 
    color: var(--text-muted); 
    border-bottom: 3px solid transparent; 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    transition: 0.2s; 
}
.tab-trigger.active { 
    color: var(--accent); 
    border-bottom-color: var(--accent); 
    background: var(--card-bg); 
}
.tab-trigger:hover { 
    color: var(--text-main); 
}
.tab-content { 
    padding: 30px; 
    width: 100%; 
}

/* --- DATA GRIDS & TABLES --- */
.table-industrial { 
    width: 100%; 
    border-collapse: collapse; 
    background: var(--card-bg); 
}
.table-industrial th { 
    padding: 15px; 
    text-align: left; 
    font-size: 11px; 
    color: var(--text-muted); 
    text-transform: uppercase; 
    border-bottom: 2px solid var(--sidebar-border); 
    background: #fafafa;
    cursor: pointer; 
    transition: 0.2s;
}
.table-industrial th:hover { 
    color: var(--accent); 
    background: #f0f7ff; 
}
.table-industrial td { 
    padding: 15px; 
    border-bottom: 1px solid var(--sidebar-border); 
    font-size: 13px; 
}
.table-industrial tr:hover { 
    background: rgba(52, 152, 219, 0.02); 
}

/* --- STATUS PILLS & BADGES --- */
.status-pill { 
    font-size: 10px; 
    font-weight: 800; 
    padding: 3px 10px; 
    border-radius: 20px; 
    border: 1px solid; 
    display: inline-block; 
    text-transform: uppercase; 
}
.status-pill.active, .status-pill.pass, .status-pill.approved { 
    color: var(--success); 
    background: rgba(39, 174, 96, 0.1); 
    border-color: var(--success); 
}
.status-pill.inactive, .status-pill.fail, .status-pill.rejected { 
    color: var(--danger); 
    background: rgba(192, 57, 43, 0.1); 
    border-color: var(--danger); 
}
.badge { 
    padding: 4px 10px; 
    border-radius: 4px; 
    font-size: 11px; 
    font-weight: 700; 
    color: #fff; 
    background: var(--accent); 
}

/* --- BUTTONS --- */
.btn-industrial { 
    background: var(--accent); 
    color: white; 
    border: none; 
    padding: 10px 20px; 
    border-radius: 6px; 
    font-weight: 700; 
    cursor: pointer; 
    display: inline-flex; 
    align-items: center; 
    gap: 8px; 
    font-size: 12px; 
    transition: 0.2s; 
    text-decoration: none;
}
.btn-industrial:hover { 
    opacity: 0.9; 
    transform: translateY(-1px); 
}

/* --- FORM CONTROLS --- */
.form-grid-industrial { 
    display: grid; 
    grid-template-columns: repeat(2, 1fr); 
    gap: 30px; 
    width: 100%; 
}
.form-group { 
    margin-bottom: 20px; 
}
.form-label { 
    display: block; 
    font-size: 11px; 
    font-weight: 800; 
    text-transform: uppercase; 
    color: var(--text-muted); 
    margin-bottom: 8px; 
    letter-spacing: 0.5px; 
}
.form-input { 
    width: 100%; 
    padding: 12px; 
    border: 1px solid var(--sidebar-border); 
    border-radius: 6px; 
    font-size: 13px; 
    background: #fff; 
    transition: 0.2s;
}
.form-input:focus { 
    outline: none; 
    border-color: var(--accent); 
    box-shadow: 0 0 0 3px rgba(52,152,219,0.1); 
}

/* --- STANDARDIZED SECTION TITLE --- */
.section-title { 
    border-left: 4px solid var(--accent); 
    padding-left: 15px; 
    margin: 20px 0 30px 0; 
}
.section-title h4 { 
    margin: 0; 
    font-size: 16px; 
    font-weight: 800; 
    color: var(--text-main); 
    text-transform: uppercase; 
    letter-spacing: 1px; 
}
.section-title p { 
    margin: 5px 0 0; 
    font-size: 12px; 
    color: var(--text-muted); 
}

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

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .main-viewport {
        margin-left: 0;
    }
    .global-page-header {
        padding: 20px 25px;
    }
    .content-body {
        padding: 20px 25px;
    }
}

@media (max-width: 768px) {
    .stats-row {
        grid-template-columns: 1fr;
    }
    .form-grid-industrial {
        grid-template-columns: 1fr;
    }
    .global-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 20px;
    }
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
    .header-left h1 {
        font-size: 22px;
    }
}

@media (max-width: 576px) {
    .content-body {
        padding: 15px;
    }
    .global-page-header {
        padding: 15px;
    }
    .user-info {
        display: none;
    }
}