/* styles.css - Custom Styling for OES Executive Intelligence & BI Platform */

/* CSS Variables for Dynamic Color Theme */
:root {
    --oes-primary: #168260;
    --oes-primary-dark: #10644B;
    --oes-cyan: #1DC395;
    --oes-teal: #8BBD5A;
    --oes-navy: #102C25;
    --oes-navy-dark: #091C17;
    --oes-esg: #10B981;
    --oes-amber: #F59E0B;
    --oes-danger: #EF4444;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 4px;
}
.dark ::-webkit-scrollbar-thumb {
    background: #334155;
}

/* Base Body Styling */
body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* OES identity: light green / emerald logo, mint website accents. */
body { background-color: #F4F8F5; }
.dark body { background-color: #091C17; }
#oes-brand-header { background: linear-gradient(120deg, #10644B, #168260); }
.oes-logo-frame {
    position: relative; width: 94px; height: 48px; overflow: hidden;
    border-radius: 12px; background: #fff;
    box-shadow: 0 2px 10px rgba(9, 28, 23, 0.12);
}
.oes-logo-image {
    position: absolute; width: 122px; height: auto; max-width: none;
    left: -14px; top: -19px;
}
#sidebar.w-20 .oes-logo-frame { width: 56px; height: 40px; }
#sidebar.w-20 .oes-logo-image { width: 76px; left: -10px; top: -7px; }
main > header { min-height: 80px; border-top: 3px solid #1DC395; }
#sidebar-nav { background: linear-gradient(180deg, #FFFFFF, #F4FAF6); }
.dark #sidebar-nav { background: linear-gradient(180deg, #102C25, #091C17); }
.oes-card[data-details]:hover { box-shadow: 0 6px 18px rgba(22, 130, 96, 0.12); }

/* Card Styling with Subtle Glassmorphism & Borders */
.oes-card {
    background-color: #FFFFFF;
    border: 1px solid #E2E8F0;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.oes-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    border-color: #CBD5E1;
}

.dark .oes-card {
    background-color: #14382F;
    border: 1px solid #285044;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
}

.dark .oes-card:hover {
    border-color: #3A6959;
    box-shadow: 0 8px 12px -2px rgba(0, 0, 0, 0.4);
}

/* AI Insights & Early Warning System (EWS) Styling */
.insight-card {
    transition: all 0.2s ease;
}
.insight-card:hover {
    transform: translateY(-1px);
}

.insight-green {
    border-left: 4px solid #10B981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(16, 185, 129, 0.02) 100%);
    border-top: 1px solid rgba(16, 185, 129, 0.2);
    border-right: 1px solid rgba(16, 185, 129, 0.2);
    border-bottom: 1px solid rgba(16, 185, 129, 0.2);
}
.dark .insight-green {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.04) 100%);
    border-top: 1px solid rgba(16, 185, 129, 0.25);
    border-right: 1px solid rgba(16, 185, 129, 0.25);
    border-bottom: 1px solid rgba(16, 185, 129, 0.25);
}

.insight-red {
    border-left: 4px solid #EF4444;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(239, 68, 68, 0.02) 100%);
    border-top: 1px solid rgba(239, 68, 68, 0.2);
    border-right: 1px solid rgba(239, 68, 68, 0.2);
    border-bottom: 1px solid rgba(239, 68, 68, 0.2);
}
.dark .insight-red {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(239, 68, 68, 0.04) 100%);
    border-top: 1px solid rgba(239, 68, 68, 0.25);
    border-right: 1px solid rgba(239, 68, 68, 0.25);
    border-bottom: 1px solid rgba(239, 68, 68, 0.25);
}

.insight-blue {
    border-left: 4px solid #168260;
    background: linear-gradient(135deg, rgba(22, 130, 96, 0.08) 0%, rgba(29, 195, 149, 0.03) 100%);
    border-top: 1px solid rgba(22, 130, 96, 0.2);
    border-right: 1px solid rgba(22, 130, 96, 0.2);
    border-bottom: 1px solid rgba(22, 130, 96, 0.2);
}
.dark .insight-blue {
    border-left: 4px solid #1DC395;
    background: linear-gradient(135deg, rgba(29, 195, 149, 0.15) 0%, rgba(22, 130, 96, 0.05) 100%);
    border-top: 1px solid rgba(29, 195, 149, 0.25);
    border-right: 1px solid rgba(29, 195, 149, 0.25);
    border-bottom: 1px solid rgba(29, 195, 149, 0.25);
}

.insight-amber {
    border-left: 4px solid #F59E0B;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(245, 158, 11, 0.02) 100%);
    border-top: 1px solid rgba(245, 158, 11, 0.2);
    border-right: 1px solid rgba(245, 158, 11, 0.2);
    border-bottom: 1px solid rgba(245, 158, 11, 0.2);
}
.dark .insight-amber {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(245, 158, 11, 0.04) 100%);
    border-top: 1px solid rgba(245, 158, 11, 0.25);
    border-right: 1px solid rgba(245, 158, 11, 0.25);
    border-bottom: 1px solid rgba(245, 158, 11, 0.25);
}

.insight-purple {
    border-left: 4px solid #8B5CF6;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(139, 92, 246, 0.02) 100%);
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    border-right: 1px solid rgba(139, 92, 246, 0.2);
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}
.dark .insight-purple {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.04) 100%);
    border-top: 1px solid rgba(139, 92, 246, 0.25);
    border-right: 1px solid rgba(139, 92, 246, 0.25);
    border-bottom: 1px solid rgba(139, 92, 246, 0.25);
}

/* Pulsing Status Indicators */
.pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: relative;
}

.pulse-dot::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.pulse-emerald {
    background-color: #10B981;
}
.pulse-emerald::after {
    border: 2px solid #10B981;
}

.pulse-blue {
    background-color: #168260;
}
.pulse-blue::after {
    border: 2px solid #168260;
}

.pulse-cyan {
    background-color: #1DC395;
}
.pulse-cyan::after {
    border: 2px solid #1DC395;
}

.pulse-amber {
    background-color: #F59E0B;
}
.pulse-amber::after {
    border: 2px solid #F59E0B;
}

.pulse-red {
    background-color: #EF4444;
}
.pulse-red::after {
    border: 2px solid #EF4444;
}

@keyframes pulse-ring {
    0% {
        transform: scale(0.9);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.8);
        opacity: 0;
    }
    100% {
        transform: scale(0.9);
        opacity: 0;
    }
}

/* Smart Filter Drawer */
.smart-filter-drawer {
    max-height: 500px;
    opacity: 1;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

.smart-filter-drawer.collapsed {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    border-bottom-width: 0;
}

/* Focus Mode Fullscreen Modal */
.focus-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(7, 11, 25, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.focus-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.focus-modal-container {
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 1.5rem;
    width: 100%;
    max-width: 1100px;
    height: 80vh;
    display: flex;
    flex-col: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.dark .focus-modal-container {
    background: #14382F;
    border-color: #285044;
}

/* Data Table Row Hover */
.table-row-hover {
    transition: background-color 0.15s ease;
}
.table-row-hover:hover {
    background-color: rgba(22, 130, 96, 0.04);
}
.dark .table-row-hover:hover {
    background-color: rgba(29, 195, 149, 0.06);
}

/* Accessible drill-through interactions and detail dialog. */
[data-details] { cursor: pointer; }
[data-details]:focus-visible { outline: 3px solid #1DC395; outline-offset: 3px; }
.oes-card[data-details]:hover { border-color: #1DC395; }
td[data-details]:hover { background: rgba(29, 195, 149, 0.12); text-decoration: underline; }
/* Warnings remain identifiable in both themes and open their source records. */
.alert-row { background: rgba(239, 68, 68, 0.035); }
.alert-row:hover { background: rgba(239, 68, 68, 0.07); }
td.alert-cell, td.alert-cell span:not(.pulse-dot) { color: #B91C1C !important; }
td.alert-cell { background: #FEF2F2; text-decoration: underline dotted; text-underline-offset: 4px; }
td.alert-cell span:not(.pulse-dot) { background-color: #FEE2E2 !important; }
td.alert-cell .pulse-dot { background-color: #EF4444; }
td.alert-cell .pulse-dot::after { border-color: #EF4444; }
td.alert-cell:hover { background: #FEE2E2; }
.dark td.alert-cell { background: rgba(127, 29, 29, 0.2); }
.dark td.alert-cell, .dark td.alert-cell span:not(.pulse-dot) { color: #FCA5A5 !important; }
.dark td.alert-cell span:not(.pulse-dot) { background-color: rgba(127, 29, 29, 0.4) !important; }
.dark td.alert-cell:hover { background: rgba(127, 29, 29, 0.35); }
.details-alert { padding: 14px; margin: 14px 0; border: 1px solid #FECACA; border-radius: 12px; background: #FEF2F2; color: #991B1B; font-size: 13px; line-height: 1.6; }
.details-alert strong { display: block; margin-bottom: 4px; }
#metric-details.has-alert .details-value, #metric-details.has-alert .details-caption { color: #B91C1C; }
.dark .details-alert { background: rgba(127, 29, 29, 0.2); border-color: #7F1D1D; color: #FCA5A5; }
.dark #metric-details.has-alert .details-value, .dark #metric-details.has-alert .details-caption { color: #FCA5A5; }
#metric-details {
    margin: auto;
    width: min(1100px, calc(100vw - 32px)); max-height: 85vh;
    padding: 0; border: 1px solid #E2E8F0; border-radius: 20px;
    background: #fff; color: #1E293B; box-shadow: 0 25px 60px #0005;
}
#metric-details::backdrop { background: rgba(7, 11, 25, 0.7); backdrop-filter: blur(4px); }
#metric-details header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px; border-bottom: 1px solid #E2E8F0; }
#metric-details h2 { font-size: 18px; font-weight: 700; }
.details-caption { font-size: 10px; letter-spacing: 0.1em; color: #168260; margin-bottom: 4px; }
.details-close { font-size: 28px; line-height: 1; padding: 8px 12px; border-radius: 8px; }
.details-close:hover { background: #E2E8F0; }
.details-body { padding: 20px; }
.details-value { font-size: 32px; font-weight: 800; color: #168260; }
.details-note, .details-scope { font-size: 13px; line-height: 1.6; margin: 12px 0; }
.details-scope { color: #64748B; }
.details-count { font-size: 12px; font-weight: 700; margin: 16px 0 8px; }
.details-table-wrap { overflow-x: auto; }
#metric-details table { width: 100%; text-align: left; font-size: 12px; border-collapse: collapse; }
#metric-details th, #metric-details td { padding: 12px; border-bottom: 1px solid #E2E8F0; white-space: nowrap; }
#metric-details th { background: #F1F5F9; }
#metric-details td:only-child { white-space: normal; min-width: 240px; line-height: 1.6; }
.dark #metric-details { background: #14382F; color: #E2E8F0; border-color: #285044; }
.dark #metric-details header, .dark #metric-details td, .dark #metric-details th { border-color: #285044; }
.dark #metric-details th, .dark .details-close:hover { background: #102C25; }
.dark .details-value, .dark .details-caption { color: #1DC395; }
.dark .details-scope { color: #94A3B8; }
@media (max-width: 640px) {
    #metric-details header, .details-body { padding: 16px; }
    #metric-details h2 { font-size: 16px; }
}
