/* 
   ┌─────────────────────────────────────────────────────────────────────────┐
   │ DATAMOSAIX LIVE & BPAiX GLOBAL STYLE SYSTEM                              │
   │ Brand Palette: SustainTech Red (#cf122d) & Rockwell Slate (#1e293b)    │
   └─────────────────────────────────────────────────────────────────────────┘
*/

:root {
    /* Brand Colors */
    --brand-red: #cf122d;
    --brand-red-light: #fee2e2;
    --brand-red-dark: #b91c1c;
    
    --slate-900: #0f172a;
    --slate-800: #1e293b;
    --slate-700: #334155;
    --slate-600: #475569;
    --slate-500: #64748b;
    --slate-400: #94a3b8;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50: #f8fafc;

    /* Semantic UI */
    --bg-main: #fcfdfe;
    --bg-page: #f8fafc;
    --card-bg: #ffffff;
    --border-soft: #f1f5f9;
    --border-medium: #e2e8f0;
    
    /* Functional Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* Layout Tokens (Optimized for 1080p) */
    --layout-sidebar-width: clamp(240px, 15vw, 280px);
    --header-height: 70px;
    --subheader-height: 60px;
    --content-max-width: 1800px;
    
    /* Breakpoints */
    --bp-sm: 640px;
    --bp-md: 768px;
    --bp-lg: 1024px;
    --bp-xl: 1280px;
    --bp-2xl: 1536px;
    --bp-full-hd: 1920px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   CORE RESET & RESPONSIVE TYPOGRAPHY
   ───────────────────────────────────────────────────────────────────────────── */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px; /* Base font size */
}

@media (min-width: 1920px) {
    html {
        font-size: 18px; /* Slightly scale up for 4K/Large displays to maintain readability */
    }
}

@media (max-width: 1366px) {
    html {
        font-size: 15px; /* Scale down for smaller HD laptops */
    }
}

body {
    background-color: var(--bg-page);
    color: var(--slate-900);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─────────────────────────────────────────────────────────────────────────────
   LAYOUT ARCHITECTURE
   ───────────────────────────────────────────────────────────────────────────── */
.dashboard-wrapper {
    display: flex;
    flex: 1;
    min-height: calc(100vh - (var(--header-height) + var(--subheader-height)));
    position: relative;
    --sidebar-width: var(--layout-sidebar-width);
}

.analytics-sidebar { 
    width: var(--sidebar-width);
    background: #ffffff; 
    color: var(--slate-500); 
    position: fixed; 
    height: calc(100vh - (var(--header-height) + var(--subheader-height)));
    top: calc(var(--header-height) + var(--subheader-height));
    left: 0;
    z-index: 100; 
    padding-top: 1rem; 
    border-right: 1px solid var(--border-medium);
    box-shadow: 4px 0 24px rgba(0,0,0,0.02);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
}

.analytics-sidebar.collapsed {
    --sidebar-width: 80px;
}

.analytics-sidebar.collapsed .sidebar-text {
    display: none;
}

.analytics-sidebar.collapsed .sidebar-item {
    justify-content: center;
    padding: 0.75rem 0;
}

.analytics-sidebar.collapsed .sidebar-item i {
    margin-right: 0;
    width: 1.5rem;
    height: 1.5rem;
}

.analytics-main { 
    margin-left: var(--sidebar-width); 
    flex-grow: 1; 
    width: calc(100% - var(--sidebar-width)); 
    padding: clamp(1rem, 2vw, 2.5rem);
    background: var(--bg-main);
    transition: margin-left 0.3s ease, width 0.3s ease;
}

/* Main Navigation Header */
.bpaix-nav {
    background: #ffffff;
    height: var(--header-height);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-medium);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    z-index: 1001;
    position: relative;
}

/* Sub-Header Scaling */
.subheader-wrapper {
    background: #ffffff;
    border-bottom: 1px solid var(--border-medium);
    padding: 0.6rem clamp(1rem, 5vw, 3rem);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02);
    z-index: 999;
    height: var(--subheader-height);
    display: flex;
    align-items: center;
}

.subheader-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* ─────────────────────────────────────────────────────────────────────────────
   RESPONSIVE OVERRIDES (Tablets & Smaller Displays)
   ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 80px; /* Mini sidebar on tablets */
    }
    
    .sidebar-item span {
        display: none; /* Hide labels in mini mode */
    }
    
    .sidebar-item {
        justify-content: center;
        padding: 0.85rem;
    }
    
    .sidebar-item i {
        font-size: 1.25rem;
        margin: 0 !important;
    }

    .analytics-main {
        padding: 1.5rem;
    }
}

/* Mobile / Small Landscape */
@media (max-width: 768px) {
    .analytics-sidebar {
        transform: translateX(-100%);
        width: 260px;
    }
    
    .analytics-main {
        margin-left: 0;
        width: 100%;
    }
    
    .sidebar-open .analytics-sidebar {
        transform: translateX(0);
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   UI COMPONENTS (TABS, BUTTONS, BADGES)
   ───────────────────────────────────────────────────────────────────────────── */
.area-tabs { 
    display: flex; 
    gap: 0.5rem; 
    padding: 0.4rem; 
    background: var(--slate-100); 
    border-radius: 14px; 
    width: fit-content; 
    margin-bottom: 2rem; 
    flex-wrap: wrap;
}

.area-tab { 
    padding: 0.6rem 1.25rem; 
    background: transparent; 
    border-radius: 10px; 
    border: none; 
    font-size: 0.7rem; 
    font-weight: 800; 
    color: var(--slate-500); 
    cursor: pointer; 
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.area-tab:hover { color: var(--slate-900); }

.area-tab.active { 
    background: #ffffff; 
    color: var(--brand-red); 
    box-shadow: var(--shadow-sm); 
}

.btn-red {
    background: var(--brand-red);
    color: #ffffff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-red:hover {
    background: var(--brand-red-dark);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(207, 18, 45, 0.2);
}

/* ─────────────────────────────────────────────────────────────────────────────
   EXPERT PANEL & AI INTERACTION (Detailed)
   ───────────────────────────────────────────────────────────────────────────── */
#expertPanel .ep-header {
    padding: clamp(1rem, 2vw, 1.5rem);
    border-bottom: 1px solid var(--border-soft);
    background: var(--bg-page);
}

#expertPanel .ep-body {
    flex: 1;
    overflow-y: auto;
    padding: clamp(1rem, 2vw, 1.25rem);
    background: #ffffff;
}

.expert-msg {
    background: var(--bg-page);
    border-left: 4px solid var(--brand-red);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    font-size: .85rem;
    color: var(--slate-700);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
    animation: slideInExpert .4s ease;
}

@keyframes slideInExpert {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: none; }
}

.expert-msg .em-header {
    font-weight: 800;
    color: var(--slate-900);
    margin-bottom: 6px;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .02em;
}

/* ─────────────────────────────────────────────────────────────────────────────
   SIMULATOR & PROCESS LOGIC
   ───────────────────────────────────────────────────────────────────────────── */
.phase-nodes-container {
    position: relative;
    padding-top: 10px;
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.phase-line {
    position: absolute;
    top: 22px; 
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--slate-100);
    overflow: hidden;
    z-index: 1;
}

.process-row.active .phase-line::before {
    content: "";
    position: absolute;
    width: 200%;
    height: 100%;
    background: radial-gradient(circle, var(--brand-red) 1.5px, transparent 1.5px);
    background-size: 30px 100%;
    opacity: 0.3;
    animation: marchingDots 5s linear infinite;
}

@keyframes marchingDots { 
    from { transform: translateX(-50%); } 
    to { transform: translateX(0); } 
}

.phase-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    flex: 1;
}

.node-circle {
    width: clamp(20px, 2vw, 24px);
    height: clamp(20px, 2vw, 24px);
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--slate-200);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 1);
}

.phase-node.active .node-circle {
    border-color: var(--brand-red);
    background: var(--brand-red);
    box-shadow: 0 0 15px rgba(207, 18, 45, 0.3);
    transform: scale(1.2);
}

.node-label {
    margin-top: 12px;
    font-size: clamp(0.55rem, 1vw, 0.65rem);
    font-weight: 800;
    color: var(--slate-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
}

.process-row { 
    transition: all 0.3s ease; 
    border-left: 0 solid transparent; 
    padding: 1rem;
    border-radius: 12px;
}

.process-row.active { 
    background: rgba(207, 18, 45, 0.02) !important; 
    border-left: 6px solid var(--brand-red); 
}

/* ─────────────────────────────────────────────────────────────────────────────
   UTILITIES
   ───────────────────────────────────────────────────────────────────────────── */
.fw-black { font-weight: 900 !important; }
.tracking-tight-px { letter-spacing: -0.01em; }
.tracking-widest-px { letter-spacing: 0.1em; }

.isa-node { 
    display: flex; 
    align-items: center; 
    padding: 0.6rem 1rem; 
    margin: 0.15rem 0.75rem; 
    border-radius: 10px; 
    cursor: pointer; 
    color: var(--slate-700); 
    font-weight: 800; 
    font-size: 0.7rem; 
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.isa-node:hover { background: var(--slate-100); color: var(--brand-red); }
.isa-node.active { background: #ffffff; color: var(--brand-red); box-shadow: 0 2px 8px rgba(0,0,0,0.05); border: 1px solid var(--brand-red-light); }

.sidebar-divider { border-bottom: 1px solid var(--border-soft); margin: 1.25rem 1rem; opacity: 0.5; }

.stat-label {
    text-transform: uppercase;
    font-size: clamp(0.5rem, 0.8vw, 0.6rem);
    font-weight: 900;
    color: var(--slate-400);
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.view-page { 
    display: none; 
    animation: slideUpFade 0.5s cubic-bezier(0.4, 0, 0.2, 1); 
}

.view-page.active { display: block; }

.text-red-500 { color: var(--brand-red) !important; }
.bg-red-500 { background: var(--brand-red) !important; }
.text-slate-400 { color: var(--slate-400) !important; }
.text-slate-500 { color: var(--slate-500) !important; }
.fs-xs { font-size: 0.65rem !important; }
.fs-7 { font-size: 0.7rem !important; }

/* ─────────────────────────────────────────────────────────────────────────────
   4K & ULTRA-WIDE OPTIMIZATIONS
   ───────────────────────────────────────────────────────────────────────────── */
@media (min-width: 2560px) {
    :root {
        --content-max-width: 2200px;
    }
    .analytics-main {
        padding: 3rem 5rem;
    }
}
/* ─────────────────────────────────────────────────────────────────────────────
   PREMIUM UTILITIES & FLUID TOKENS (Overhaul Extensions)
   ───────────────────────────────────────────────────────────────────────────── */
:root {
    /* Glassmorphism Tokens */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --glass-blur: blur(12px);

    /* Fluid Spacing (Scale from 1080p to 4K) */
    --space-xs: clamp(0.25rem, 0.5vw, 0.5rem);
    --space-sm: clamp(0.5rem, 1vw, 1rem);
    --space-md: clamp(1rem, 2vw, 2rem);
    --space-lg: clamp(1.5rem, 3vw, 4rem);
    --space-xl: clamp(2rem, 5vw, 8rem);
}

/* 4K Specific Enhancements */
@media (min-width: 2500px) {
    :root {
        --layout-sidebar-width: 320px;
        --header-height: 90px;
        --subheader-height: 80px;
    }
    .analytics-main {
        padding: 4rem;
    }
    .container-fluid {
        max-width: 2200px;
        margin: 0 auto;
    }
}

/* Premium Component: Glass Card */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 1.5rem;
    transition: all 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.12);
    border-color: rgba(255, 255, 255, 0.8);
}

/* Responsive Grid Helpers */
.responsive-grid {
    display: grid;
    gap: var(--space-md);
    grid-template-columns: repeat(auto-fit, minmax(clamp(280px, 20vw, 400px), 1fr));
}

/* Typography Fluid Scaling */
.text-fluid-h1 { font-size: clamp(2.2rem, 4.5vw, 4rem); font-weight: 950; line-height: 1.1; letter-spacing: -0.05em; }
.text-fluid-h2 { font-size: clamp(1.8rem, 3.5vw, 3rem); font-weight: 800; line-height: 1.2; letter-spacing: -0.03em; }
.text-fluid-p { font-size: clamp(1rem, 1.2vw, 1.3rem); line-height: 1.6; color: var(--slate-600); }

/* Sidebar Premium Items */
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 1.2rem;
    margin: 0.3rem 0.6rem;
    border-radius: 0.8rem;
    text-decoration: none !important;
    color: var(--slate-600);
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-item:hover {
    background: var(--slate-50);
    color: #3b82f6;
    transform: translateX(4px);
}

.sidebar-item.active {
    background: #eff6ff;
    color: #3b82f6;
    border-left: 4px solid #3b82f6;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Responsive visibility for 1080p landscape vs Mobile */
@media (max-width: 1024px) {
    .analytics-sidebar {
        transform: translateX(-100%);
    }
    .analytics-sidebar.active {
        transform: translateX(0);
    }
    .analytics-main {
        margin-left: 0;
        width: 100%;
        padding: 1.5rem;
    }
}
