/* Global Layout */
:root {
    color-scheme: light; /* Enforce light mode at browser level */
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: #f8f9fa;
    color: #212529; /* Explicit dark text color */
    overflow: hidden; /* Prevent body scroll, let areas scroll individually */
}

/* App Container */
.app-container {
    display: grid;
    grid-template-rows: 80px 1fr; /* Fixed Header Height */
    grid-template-columns: 260px 1fr 220px; /* Sidebar | Content | TOC */
    height: 100vh;
    width: 100vw;
}

/* Top Navbar */
.top-navbar {
    grid-row: 1;
    grid-column: 1 / -1; /* Span all columns */
    background: linear-gradient(to right, #2a1e4b, #35265e);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    padding: 0 30px;
    z-index: 1000;
    color: #ffffff;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.15);
}

.top-navbar h3 {
    color: #ffffff !important;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Navbar Links (Premium Animated Underline) */
.navbar-link {
    color: rgba(255, 255, 255, 0.7) !important;
    font-weight: 500;
    padding: 15px 20px !important;
    transition: all 0.3s ease;
    position: relative;
    font-size: 1rem !important;
    letter-spacing: 0.3px;
}

.navbar-link::after {
    content: '';
    position: absolute;
    bottom: 12px;
    left: 50%;
    width: 0;
    height: 3px;
    background-color: #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(-50%);
    border-radius: 4px;
    opacity: 0;
}

.navbar-link:hover {
    color: #ffffff !important;
}

.navbar-link:hover::after {
    width: 30%;
    opacity: 0.4;
    bottom: 10px;
}

.navbar-link.active {
    color: #ffffff !important;
    font-weight: 700;
}

.navbar-link.active::after {
    width: 70%;
    opacity: 1;
    bottom: 10px;
}

/* Left Sidebar */
.left-sidebar {
    grid-row: 2;
    grid-column: 1;
    background-color: #f5f7fb;
    border-right: 1px solid #e0e4ec;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-networks-box {
    background-color: #ebedf5; /* Ever so slightly darker than sidebar */
    border-radius: 12px;
    padding: 15px;
}

.sidebar-status-cluster {
    border-top: 1px solid #e0e4ec;
    padding-left: 5px;
}

.x-small {
    font-size: 0.75rem;
}

/* Search Input with Icon */
.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
    z-index: 10;
    pointer-events: none;
}

.search-input {
    padding-left: 36px !important;
    border-radius: 8px !important;
    border: 1px solid #d1d5db !important;
    font-size: 0.9rem;
    background-color: #f5f7fb !important;
}

.search-input:focus {
    box-shadow: 0 0 0 3px rgba(42, 30, 75, 0.1) !important;
    border-color: #2a1e4b !important;
}

/* Main Content */
.main-content {
    grid-row: 2;
    grid-column: 2;
    padding: 30px 40px;
    overflow-y: auto;
    background-color: #f8f9fa;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    body {
        overflow-y: auto !important;
        overflow-x: hidden !important; /* Force no horizontal scroll */
        width: 100%;
        position: relative;
    }

    /* Aggressive Grid Reset for Mobile */
    .app-container, .app-container.full-width {
        display: block !important; /* Switch to block to avoid grid width issues */
        height: auto;
        min-height: 100vh;
        overflow-x: hidden;
        width: 100%;
    }

    .top-navbar {
        height: 60px; /* Reduced specific mobile height */
        padding: 0 10px;
        position: sticky;
        top: 0;
        width: 100%;
        justify-content: space-between;
    }
    
    .top-navbar img {
        height: 35px !important; /* Scale down logo */
    }

    .left-sidebar {
        position: fixed;
        top: 60px; /* Match new navbar height */
        left: -280px; /* Hide off-screen */
        width: 280px;
        height: calc(100vh - 60px);
        z-index: 2000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 15px rgba(0,0,0,0.1);
        padding-top: 20px;
    }
    
    .left-sidebar.show {
        left: 0; /* Slide in */
    }

    .app-container {
        grid-template-areas:
            "nav"
            "main";
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 10px !important;
        margin-top: 60px; /* Space for fixed navbar */
        overflow-x: hidden;
        width: 100%;
    }

    /* Stack Graph Headers on Mobile */
    .graph-header {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center;
        gap: 15px;
    }

    .graph-title-section {
        width: 100%;
        margin-bottom: 5px;
    }

    .graph-header .d-flex.flex-column.align-items-end {
        align-items: center !important;
        margin-left: 0 !important;
        width: 100%;
    }

    .metric-card h4 {
        font-size: 1.1rem !important;
    }

    .metric-card .fs-6 {
        font-size: 0.8rem !important;
    }

    .time-range-graph-container {
        padding: 10px !important;
        min-height: auto !important; /* Allow container to shrink for smaller graphs */
    }

    .graph-header {
        margin-bottom: 10px !important;
    }

    /* Move Plotly Modebar up to avoid overlap */
    .js-plotly-plot .plotly .modebar {
        display: none !important;
    }
    
    /* Ensure no text overflows */
    * {
        word-wrap: break-word;
        overflow-wrap: break-word; /* Modern standard */
    }

    .right-sidebar {
        display: none !important;
    }
    
    /* Global Mobile Font Scaling */
    html {
        font-size: 14px; /* Default root down from 16px */
    }

    h1 { font-size: 1.6rem !important; }
    h2 { font-size: 1.4rem !important; }
    h3 { font-size: 1.2rem !important; }
    h4 { font-size: 1.1rem !important; }
    h5 { font-size: 1rem !important; }
    p, .lead, li, div { font-size: 0.95rem; }
    
    .lead { font-size: 1rem !important; }

    /* Navbar link adjustments for mobile */
    .navbar-link {
        padding: 5px 6px !important;
        font-size: 0.85rem !important;
    }

    .navbar-link::after {
        bottom: 5px !important;
    }

    .navbar-link.active::after,
    .navbar-link:hover::after {
        bottom: 2px !important;
    }

    /* Publication Page Adjustments */
    .app-container.full-width .main-content {
        padding: 30px 20px !important;
    }
    
    /* Ensure Sidebar exists on mobile even in full-width mode (for overlay) */
    .app-container.full-width .left-sidebar {
        display: flex !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    /* Graph Header Adjustments */
    .graph-header {
        flex-wrap: wrap; /* Allow wrapping to avoid overlap */
    }

    .graph-header .btn {
        padding: 1px 4px !important;
        font-size: 0.65rem !important;
    }

    .graph-header h5 {
        font-size: 1rem !important;
    }

    .lead {
        font-size: 1.1rem !important;
    }

    .fs-5 {
        font-size: 1rem !important;
    }
}

/* Vertical Sidebar Layout */
.right-sidebar {
    grid-row: 2;
    grid-column: 3;
    padding: 30px 20px;
    border-left: 1px solid #eee; /* Optional subtle border */
    background-color: #f8f9fa; /* Match content bg */
    overflow-y: auto;
}

/* Typography Overrides */
h1, h2, h3, h4, h5, h6 {
    color: #2a1e4b;
}

.text-primary, .brand-color {
    color: #2a1e4b !important;
}

/* Sidebar Links */
.sidebar-link-item {
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
    color: #343a40; /* Default text color */
}

.sidebar-link-item:hover {
    background-color: #f0f4f8;
    color: #343a40; /* Maintain color on hover */
}

.sidebar-link-item.active {
    background-color: #2a1e4b;
    color: #ffffff !important;
    font-weight: 600;
}

/* Network List Styles */
.network-list-container {
    /* Collapsed state by default - controlled by inline style or class in callback */
    overflow: hidden; 
    transition: max-height 0.3s ease-out;
}

/* Gradient Overlay for "Show More" */
.network-list-gradient-overlay {
    position: relative;
    height: 60px;
    margin-top: -25px; /* Pull up to overlap list */
    background: linear-gradient(to bottom, rgba(235, 237, 245, 0), rgba(235, 237, 245, 1) 80%);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 10px;
    pointer-events: none; /* Let clicks pass through except button */
}

.network-list-gradient-overlay .btn-show-more {
    pointer-events: auto;
    z-index: 10;
    width: 32px;
    height: 32px;
    padding: 0;
    transition: all 0.2s ease;
    background-color: #ebedf5;
    color: #343a40;
}

.network-list-gradient-overlay .btn-show-more:hover {
    background-color: #2a1e4b;
    color: #ffffff;
    border-color: #2a1e4b;
}

/* Full Width Mode (No Sidebars) */
.app-container.full-width {
    grid-template-columns: 1fr;
}

.app-container.full-width .left-sidebar,
.app-container.full-width .right-sidebar {
    display: none;
}

.app-container.full-width .main-content {
    grid-column: 1;
    padding: 30px 15%; /* Add some horizontal padding for readability on wide screens */
}

/* Brand Outline Button */
.btn-brand-outline {
    color: #2a1e4b !important;
    border: 2px solid #2a1e4b !important;
    background-color: transparent !important;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}

.btn-brand-outline:hover {
    background-color: rgba(42, 30, 75, 0.08) !important;
    color: #2a1e4b !important;
    border-color: #2a1e4b !important;
    box-shadow: 0 0 10px rgba(42, 30, 75, 0.1);
}
/* Network Logo Circle Wrapper */
.network-logo-wrapper {
    width: 24px;
    height: 24px;
    background-color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.network-logo-img {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

.network-logo-wrapper i {
    font-size: 12px;
    color: #adb5bd;
}

/* Maintain background when item is active */
.sidebar-link-item.active .network-logo-wrapper {
    background-color: #ffffff;
    box-shadow: none;
}

/* TOC Styles */
.toc-list li {
    margin-bottom: 12px;
}

.toc-link {
    color: #6c757d;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: block;
    line-height: 1.2;
}

.toc-link:hover {
    color: #2a1e4b;
    padding-left: 4px;
}
/* Network Analysis Page Components */
.metric-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

.metric-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Sub-card titles */
.card-title.fw-bold {
    color: #2a1e4b;
    letter-spacing: -0.2px;
}

/* Map specific styling */
#chart-container-map .js-plotly-plot .plotly .mapboxgl-canvas {
    border-radius: 12px;
}

/* Graph Container Sizing to prevent overlap */
.time-range-graph-container {
    min-height: 450px;
    height: auto;
    display: block; /* Ensure block layout */
}

/* Specific adjustment for taller charts */
#chart-container-overlap {
    min-height: 700px;
}
