/* ========================================================
   MLOPS Solutions Brand Theme
   Dark Navy (#0A0E27) + Coral Accent (#EE3F56 / #FF5733)
   Clean whites for cards, Inter typography
   ======================================================== */

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

:root {
    /* === MLOPS Brand Palette === */
    --brand-navy: #0A0E27;
    /* Deep navy - primary bg */
    --brand-navy-mid: #111535;
    /* Mid navy - sidebar */
    --brand-navy-card: #181D3A;
    /* Slightly lighter card in dark */
    --brand-coral: #EE3F56;
    /* Primary accent - coral/red */
    --brand-coral-hover: #FF5733;
    /* Lighter coral on hover */
    --brand-coral-light: #FFF0EB;
    /* Soft coral tint for badges */
    --brand-blue: #2979FF;
    /* Electric blue secondary accent */

    /* === Light Mode (default) === */
    --ui-bg: #F4F5FA;
    --sidebar-bg: var(--brand-navy-mid);
    --card-bg: #ffffff;
    --text-primary: #0A0E27;
    --text-secondary: #4A5568;
    --text-muted: #9AA5B4;
    --accent-primary: var(--brand-coral);
    --accent-hover: var(--brand-coral-hover);
    --border-color: #E8EAF0;
    --success: #10b981;
    --danger: #ef4444;

    --sidebar-width: 265px;
    --topbar-height: 64px;
    --shadow-card: 0 2px 8px rgba(10, 14, 39, 0.08);
    --shadow-hover: 0 8px 24px rgba(232, 68, 26, 0.15);
    --radius: 10px;
}

/* === Dark Mode === */
[data-theme="dark"] {
    --ui-bg: var(--brand-navy);
    --sidebar-bg: #080B1E;
    --card-bg: var(--brand-navy-card);
    --text-primary: #F0F2FF;
    --text-secondary: #8892AA;
    --border-color: #242A4A;
}

/* ===================== RESET ===================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background-color: var(--ui-bg);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* ===================== LAYOUT ===================== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 100;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo .icon {
    font-size: 1.4rem;
}

.logo .text {
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

/* Coral accent bar under logo */
.sidebar-header::after {
    display: none;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar-content::-webkit-scrollbar {
    width: 4px;
}

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

.sidebar-section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--brand-coral);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 12px;
    padding-left: 4px;
}

/* Sidebar CTA buttons */
.sidebar .btn-primary {
    background: var(--brand-coral);
    border: none;
    color: #fff;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.83rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: center;
}

.sidebar .btn-primary:hover {
    background: var(--brand-coral-hover);
    transform: translateY(-1px);
}

.sidebar .btn-outline-secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.75);
    padding: 9px 16px;
    border-radius: var(--radius);
    font-size: 0.83rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    text-align: center;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.sidebar .btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

/* ===== SLICERS ===== */
.slicer-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 10px;
}

.slicer-title {
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.85);
}

.slicer-list {
    max-height: 140px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

.slicer-item {
    font-size: 0.75rem;
    padding: 5px 0;
    color: rgba(255, 255, 255, 0.55);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: color 0.15s;
}

.slicer-item:hover {
    color: #fff;
}

.slicer-item input[type="checkbox"] {
    accent-color: var(--brand-coral);
}

/* ===== SIDEBAR FOOTER ===== */
.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.theme-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

.form-check-input:checked {
    background-color: var(--brand-coral) !important;
    border-color: var(--brand-coral) !important;
}

/* ===================== TOP BAR ===================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.top-bar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(10, 14, 39, 0.06);
    flex-shrink: 0;
}

[data-theme="dark"] .top-bar {
    background: var(--brand-navy-mid);
    border-color: var(--border-color);
}

#summaryTitle {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

#summaryDescription {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.top-bar-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 1rem;
}

.btn-icon:hover {
    background: var(--brand-coral-light);
    border-color: var(--brand-coral);
    color: var(--brand-coral);
}

/* ===================== VIEWPORT ===================== */
.dashboard-viewport {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

/* ===================== KPI CARDS ===================== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 22px 20px;
    box-shadow: var(--shadow-card);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    border-left: 4px solid var(--brand-coral);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 60px;
    height: 60px;
    background: var(--brand-coral-light);
    border-radius: 0 var(--radius) 0 60px;
    opacity: 0;
    transition: opacity 0.2s;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: var(--brand-coral);
}

.kpi-card:hover::before {
    opacity: 1;
}

.kpi-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.kpi-trend {
    font-size: 0.72rem;
    margin-top: 10px;
    color: var(--brand-coral);
    font-weight: 600;
}

/* ===================== CHARTS ===================== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-card);
    min-height: 360px;
    display: flex;
    flex-direction: column;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.chart-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    position: relative;
    padding-left: 12px;
}

.chart-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 100%;
    background: var(--brand-coral);
    border-radius: 2px;
}

.chart-body {
    flex: 1;
    position: relative;
}

/* ===================== LOADING ===================== */
.loading-overlay {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    flex-direction: column;
    gap: 16px;
    color: var(--text-secondary);
}

.spinner-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner-ring {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--brand-coral);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===================== MODAL ===================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 11, 30, 0.8);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 40px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content-wrapper {
    background: var(--card-bg);
    border-radius: 14px;
    width: 100%;
    max-width: 1200px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 60px rgba(8, 11, 30, 0.6);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

@keyframes slideUp {
    from {
        transform: translateY(24px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header-custom {
    padding: 20px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--brand-navy-mid);
    color: #fff;
    border-bottom: 3px solid var(--brand-coral);
}

.modal-header-custom h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.modal-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s, transform 0.15s;
}

.modal-close-btn:hover {
    background: var(--brand-coral);
    border-color: var(--brand-coral);
    transform: rotate(90deg);
}

.modal-body-custom {
    flex: 1;
    overflow-y: auto;
    background: var(--card-bg);
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.modal-body-custom::-webkit-scrollbar {
    width: 6px;
}

.modal-body-custom::-webkit-scrollbar-thumb {
    background: var(--brand-coral);
    border-radius: 3px;
    opacity: 0.5;
}

.modal-footer-custom {
    padding: 14px 28px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--ui-bg);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ===================== TABLE ===================== */
.enterprise-table {
    width: 100%;
    border-collapse: separate; /* Essential for sticky header */
    border-spacing: 0;
}

.enterprise-table thead th {
    position: sticky;
    top: 0;
    z-index: 100; /* Higher z-index */
    background: var(--brand-navy-mid) !important;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.75);
    border-bottom: 2px solid var(--brand-coral);
    padding: 13px 16px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}


.table-responsive {
    overflow: visible !important; /* Allow sticky header to stick to modal-body-custom scroll */
}

.enterprise-table tbody td {
    border-bottom: 1px solid var(--border-color);
    padding: 13px 16px;
    font-size: 0.875rem;
    color: #1e293b !important;
    background-color: #ffffff;
    transition: background 0.15s;
}


.enterprise-table tbody tr:hover td {
    background-color: var(--brand-coral-light) !important;
    color: var(--brand-navy) !important;
}

[data-theme="dark"] .enterprise-table tbody td {
    color: #e2e8f0 !important;
    background-color: var(--brand-navy-card);
}

[data-theme="dark"] .enterprise-table tbody tr:hover td {
    background-color: rgba(232, 68, 26, 0.12) !important;
    color: #fff !important;
}

[data-theme="dark"] .modal-body-custom {
    background-color: var(--brand-navy-card);
}

[data-theme="dark"] .modal-footer-custom {
    background: var(--brand-navy);
}

/* ===================== UPLOAD PAGE ===================== */
.upload-page {
    background: var(--ui-bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-card {
    background: var(--card-bg);
    padding: 36px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    max-width: 520px;
    width: 100%;
}

.file-drop-area {
    padding: 40px;
    border: 2px dashed var(--brand-coral);
    border-radius: var(--radius);
    text-align: center;
    background: var(--brand-coral-light);
    transition: background 0.2s;
}

.file-drop-area:hover {
    background: #ffe3da;
}

/* ===================== MISC ===================== */
.btn-outline-secondary {
    border: 1px solid var(--brand-coral);
    color: var(--brand-coral);
    background: transparent;
    padding: 7px 16px;
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

/* === STATUS BADGES === */
.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
    letter-spacing: 0.5px;
}

.status-active {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-delivered {
    /* Used for Contract Completed */
    background: rgba(41, 121, 255, 0.15);
    color: #2979FF;
    border: 1px solid rgba(41, 121, 255, 0.3);
}


/* === SHARE TOAST === */
.share-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--brand-coral);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 10px 25px rgba(238, 63, 86, 0.4);
    z-index: 9999;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    opacity: 0;
}

.share-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ===================== RESPONSIVE (Mobile Ready) ===================== */
@media (max-width: 768px) {
    html, body {
        height: auto;
        overflow: auto !important; /* Force allow scroll on mobile */
    }

    .app-container {
        flex-direction: column;
        height: auto;
        width: 100%;
        overflow-x: hidden;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 100%; /* Full screen sidebar on mobile for easier filtering */
        z-index: 9999;
        transition: left 0.3s ease;
    }

    .sidebar.active {
        left: 0;
    }

    .main-content {
        flex: 1;
        width: 100%;
        margin-left: 0 !important;
        display: block;
        height: auto;
        overflow: visible;
    }

    .top-bar {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: var(--ui-bg);
        border-bottom: 1px solid var(--border-color);
        padding: 10px 12px;
        height: auto;
        min-height: 70px;
    }

    .top-bar .container-fluid {
        flex-wrap: wrap;
        gap: 10px;
    }

    .dashboard-info {
        flex: 1;
        min-width: 0; /* Allow text truncate or wrap */
    }

    #summaryTitle {
        font-size: 1.1rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 150px;
    }

    #summaryDescription {
        font-size: 0.7rem !important;
        line-height: 1.2;
    }

    .top-bar-actions {
        display: flex;
        gap: 6px;
    }

    .btn-icon {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }


    .dashboard-viewport {
        padding: 15px;
        overflow: visible;
    }

    .kpi-row {

        grid-template-columns: 1fr;
        gap: 15px;
    }

    .charts-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .chart-card {
        padding: 15px;
        min-height: 300px;
    }

    .chart-title {
        font-size: 0.8rem;
    }

    /* Modal Mobile Overhaul */
    .modal-content-wrapper {
        width: 100%;
        height: 100%;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .modal-header-custom {
        padding: 15px;
    }

    .modal-body-custom {
        padding: 10px;
    }

    .table-responsive {
        width: 100%;
        overflow-x: auto !important;
        margin: 0;
    }

    .enterprise-table thead th {
        font-size: 0.65rem;
        padding: 10px;
    }

    .enterprise-table tbody td {
        font-size: 0.8rem;
        padding: 10px;
    }
}