/* =====================================================================
   VIA MIA — Advanced Analytics Dashboard
   Light theme inspired by time.track.pt — professional design
   ===================================================================== */

/* ----- Google Fonts import ----- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ----- CSS Variables ----- */
:root {
    /* Sidebar */
    --sidebar_width: 270px;
    --sidebar_bg: #1a1f2e;
    --sidebar_bg_hover: #252b3b;
    --sidebar_bg_active: rgba(232, 72, 63, 0.15);
    --sidebar_text: #7b8794;
    --sidebar_text_active: #ffffff;
    --sidebar_accent: #e8483f;

    /* Main area */
    --main_bg: #f0f2f5;
    --card_bg: #ffffff;
    --card_border: #e3e6ea;
    --card_radius: 12px;
    --card_shadow: 0 1px 4px rgba(0, 0, 0, 0.06), 0 2px 12px rgba(0, 0, 0, 0.03);
    --card_shadow_hover: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);

    /* Typography */
    --font_family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
    --text_primary: #1a2332;
    --text_secondary: #6b7a8d;
    --text_muted: #95a5a6;

    /* Accents */
    --accent_brand: #e8483f;
    --accent_brand_dark: #c93a32;
    --accent_brand_light: rgba(232, 72, 63, 0.08);
    --accent_green: #27ae60;
    --accent_green_light: rgba(39, 174, 96, 0.08);
    --accent_orange: #f39c12;
    --accent_orange_light: rgba(243, 156, 18, 0.08);
    --accent_blue: #3498db;
    --accent_blue_light: rgba(52, 152, 219, 0.08);
    --accent_purple: #9b59b6;

    /* Misc */
    --border: #e3e6ea;
    --top_bar_height: 68px;
    --transition_fast: 0.15s ease;
    --transition_smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----- Reset & Base ----- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: var(--font_family);
    background: var(--main_bg);
    color: var(--text_primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
    height: 100%;
    font-size: 14px;
    line-height: 1.5;
}

#react-entry-point {
    background: var(--main_bg);
}

/* =====================================================================
   APP CONTAINER
   ===================================================================== */
.app_container {
    display: flex;
    min-height: 100vh;
}

/* No-data fallback container */
.no_data_container {
    background-color: var(--main_bg);
    min-height: 100vh;
}

/* =====================================================================
   SIDEBAR
   ===================================================================== */
.sidebar {
    width: var(--sidebar_width);
    min-height: 100vh;
    background: var(--sidebar_bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.15);
}

/* Scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* ----- Sidebar Logo ----- */
.sidebar_logo {
    padding: 24px 20px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
}

.sidebar_logo::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 20px;
    right: 20px;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(232, 72, 63, 0.3),
        transparent
    );
}

.sidebar_logo_img {
    max-width: 150px;
    height: auto;
    border-radius: 8px;
    filter: brightness(1.05);
    transition: transform var(--transition_smooth);
}

.sidebar_logo_img:hover {
    transform: scale(1.03);
}

.sidebar_logo_subtitle {
    margin-top: 10px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    color: rgba(232, 72, 63, 0.7);
    line-height: 1.4;
    padding: 6px 12px;
    background: rgba(232, 72, 63, 0.06);
    border-radius: 4px;
    border: 1px solid rgba(232, 72, 63, 0.1);
}

/* ----- Sidebar Section Label ----- */
.sidebar_section_label {
    padding: 24px 24px 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.2);
    user-select: none;
}

/* ----- Sidebar Nav ----- */
.sidebar_nav {
    flex: 1;
    padding: 4px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Each sidebar item is a dcc.Link (<a> tag) */
.sidebar_item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--sidebar_text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition_fast);
    border-left: 3px solid transparent;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    position: relative;
}

.sidebar_item:hover {
    background: var(--sidebar_bg_hover);
    color: #c8d0dc;
    text-decoration: none;
}

.sidebar_item_active {
    background: var(--sidebar_bg_active);
    color: var(--sidebar_text_active);
    border-left-color: var(--sidebar_accent);
    font-weight: 600;
}

.sidebar_item_active:hover {
    background: var(--sidebar_bg_active);
    color: var(--sidebar_text_active);
}

/* Sidebar item numbers */
.sidebar_item_number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.06);
    color: var(--sidebar_text);
    transition: all var(--transition_fast);
    flex-shrink: 0;
}

.sidebar_item_active .sidebar_item_number {
    background: var(--sidebar_accent);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(232, 72, 63, 0.35);
}

/* ----- Sidebar Footer ----- */
.sidebar_footer {
    padding: 18px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.18);
    text-align: center;
    letter-spacing: 0.5px;
}

/* =====================================================================
   MAIN CONTENT
   ===================================================================== */
.main_content {
    flex: 1;
    margin-left: var(--sidebar_width);
    min-height: 100vh;
    background: var(--main_bg);
}

/* ----- Top Bar ----- */
.top_bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    height: var(--top_bar_height);
    background: var(--card_bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.top_bar_title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text_primary);
    letter-spacing: -0.2px;
}

.top_bar_subtitle {
    font-size: 12px;
    color: var(--text_secondary);
    margin-top: 1px;
    letter-spacing: 0.3px;
    font-weight: 400;
}

.top_bar_right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ----- Dropdown ----- */
.dropdown_label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text_secondary);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 4px;
    display: block;
}

.client_dropdown {
    min-width: 220px;
}

/* Dash Dropdown styling for light theme */
.client_dropdown .Select-control {
    background-color: var(--card_bg);
    border-color: var(--border);
    color: var(--text_primary);
    border-radius: 8px;
    height: 38px;
    transition: border-color var(--transition_fast);
}

.client_dropdown .Select-control:hover {
    border-color: var(--accent_brand);
}

.client_dropdown .Select-menu-outer {
    background-color: var(--card_bg);
    border-color: var(--border);
    color: var(--text_primary);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.client_dropdown .Select-value-label,
.client_dropdown .Select-placeholder {
    color: var(--text_primary);
}

.client_dropdown .Select-option {
    background-color: var(--card_bg);
    color: var(--text_primary);
    padding: 8px 14px;
    font-size: 13px;
    transition: background-color var(--transition_fast);
}

.client_dropdown .Select-option:hover,
.client_dropdown .Select-option.is-focused {
    background-color: var(--accent_brand_light);
    color: var(--text_primary);
}

.client_dropdown .Select-option.is-selected {
    background-color: var(--accent_brand);
    color: white;
}

/* =====================================================================
   SUNBURST VARIANT SELECTOR
   ===================================================================== */
.variant_container {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: #fafbfc;
    border: 1px solid #f0f2f5;
    border-radius: 8px;
}

.variant_hidden {
    display: none;
}

.variant_label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text_secondary);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
}

.variant_radio {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.variant_radio label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text_secondary);
    background: var(--card_bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition_fast);
    user-select: none;
}

.variant_radio label:hover {
    border-color: var(--accent_brand);
    color: var(--text_primary);
}

.variant_radio input[type="radio"] {
    display: none;
}

.variant_radio input[type="radio"]:checked + label,
.variant_radio label:has(input:checked) {
    background: var(--accent_brand);
    color: white;
    border-color: var(--accent_brand);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(232, 72, 63, 0.25);
}

/* =====================================================================
   KPI ROW
   ===================================================================== */
.kpi_row {
    display: flex;
    gap: 16px;
    padding: 24px 32px 12px;
}

.kpi_card {
    flex: 1;
    background: var(--card_bg);
    border: 1px solid var(--card_border);
    border-radius: var(--card_radius);
    box-shadow: var(--card_shadow);
    padding: 18px 22px;
    text-align: center;
    min-width: 120px;
    transition: box-shadow var(--transition_smooth), transform var(--transition_smooth);
    position: relative;
    overflow: hidden;
}

.kpi_card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border);
    transition: background var(--transition_smooth);
}

.kpi_card:hover {
    box-shadow: var(--card_shadow_hover);
    transform: translateY(-1px);
}

.kpi_value {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.kpi_label {
    font-size: 10px;
    color: var(--text_secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 6px;
    font-weight: 600;
}

/* KPI color classes — value color and top bar accent */
.kpi_brand   { color: var(--accent_brand); }
.kpi_danger  { color: var(--accent_brand); }
.kpi_warning { color: var(--accent_orange); }
.kpi_success { color: var(--accent_green); }
.kpi_info    { color: var(--accent_blue); }

/* KPI card top bar accent colors */
.kpi_card:nth-child(1)::before { background: var(--accent_blue); }
.kpi_card:nth-child(2)::before { background: var(--accent_brand); }
.kpi_card:nth-child(3)::before { background: var(--accent_brand); }
.kpi_card:nth-child(4)::before { background: var(--accent_orange); }
.kpi_card:nth-child(5)::before { background: var(--accent_green); }

/* =====================================================================
   CONTENT AREA
   ===================================================================== */
.content_area {
    padding: 16px 32px 40px;
}

/* ----- Graph Card ----- */
.graph_card {
    background: var(--card_bg);
    border-radius: var(--card_radius);
    border: 1px solid var(--card_border);
    box-shadow: var(--card_shadow);
    padding: 24px;
    margin-bottom: 20px;
    transition: box-shadow var(--transition_smooth);
}

.graph_card:hover {
    box-shadow: var(--card_shadow_hover);
}

/* ----- Context Card ----- */
.context_card {
    background: var(--card_bg);
    border-radius: var(--card_radius);
    border: 1px solid var(--card_border);
    box-shadow: var(--card_shadow);
    padding: 24px;
    margin-bottom: 20px;
    transition: box-shadow var(--transition_smooth);
}

.context_card:hover {
    box-shadow: var(--card_shadow_hover);
}

/* ----- Card Header ----- */
.card_header {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.card_header::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 40px;
    height: 2px;
    background: var(--accent_brand);
    border-radius: 2px;
}

.card_title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text_primary);
    margin: 0;
    letter-spacing: -0.2px;
}

.card_subtitle {
    font-size: 12px;
    color: var(--text_secondary);
    margin-top: 4px;
    font-weight: 400;
}

/* =====================================================================
   CONTEXT PANEL
   ===================================================================== */
.context_grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.context_section {
    padding: 16px;
    background: #fafbfc;
    border-radius: 8px;
    border: 1px solid #f0f2f5;
    transition: border-color var(--transition_fast);
}

.context_section:hover {
    border-color: var(--border);
}

.context_label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--accent_brand);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.context_label::before {
    content: "";
    display: inline-block;
    width: 3px;
    height: 12px;
    background: var(--accent_brand);
    border-radius: 2px;
}

.context_text {
    font-size: 13px;
    color: var(--text_primary);
    line-height: 1.7;
}

.context_stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.context_stat {
    display: inline-block;
    background: #eef2f7;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 12px;
    color: var(--text_primary);
    font-weight: 500;
    border: 1px solid #e3e8ef;
    transition: all var(--transition_fast);
}

.context_stat:hover {
    background: var(--accent_brand_light);
    border-color: rgba(232, 72, 63, 0.2);
}

/* =====================================================================
   DATA NOT FOUND (fallback)
   ===================================================================== */
.data_not_found {
    text-align: center;
    padding: 100px 40px;
    color: var(--text_secondary);
}

.data_not_found_title {
    font-size: 26px;
    color: var(--text_primary);
    margin-bottom: 14px;
    font-weight: 700;
}

.data_not_found_text {
    font-size: 14px;
    line-height: 1.8;
    max-width: 520px;
    margin: 0 auto;
    color: var(--text_secondary);
}

.data_not_found_code {
    display: inline-block;
    background: #eef2f7;
    border-radius: 6px;
    padding: 3px 10px;
    font-family: "Consolas", "Fira Code", monospace;
    font-size: 13px;
    color: var(--accent_brand);
    border: 1px solid #e3e8ef;
}

/* =====================================================================
   PLOTLY OVERRIDES
   ===================================================================== */

/* Force light theme on Plotly graphs */
.js-plotly-plot {
    background-color: white !important;
}

/* Ensure all Dash components use light theme */
._dash-loading {
    color: var(--text_primary);
}

/* Plotly modebar styling */
.js-plotly-plot .modebar {
    top: 4px !important;
    right: 4px !important;
}

.js-plotly-plot .modebar-btn {
    font-size: 16px !important;
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 1200px) {
    .context_grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    :root {
        --sidebar_width: 220px;
    }

    .kpi_row {
        flex-wrap: wrap;
    }

    .kpi_card {
        min-width: 130px;
    }

    .content_area {
        padding: 14px 18px 32px;
    }

    .top_bar {
        padding: 0 18px;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar_width: 0px;
    }

    .sidebar {
        display: none;
    }

    .main_content {
        margin-left: 0;
    }

    .kpi_row {
        padding: 16px;
        gap: 10px;
    }

    .kpi_card {
        min-width: 100px;
    }
}
