/*
 * Exposure Risk Pipeline — Custom styles
 * Complements Tailwind CSS CDN for elements that need CSS selectors,
 * keyframes, or would be too verbose as inline utilities.
 */

/* ─── Gilroy font ─── */
@font-face {
    font-family: 'Gilroy';
    src: url('/static/fonts/Corporate_Font_Eng-Gilroy/Gilroy-Light.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Gilroy';
    src: url('/static/fonts/Corporate_Font_Eng-Gilroy/Gilroy-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Gilroy';
    src: url('/static/fonts/Corporate_Font_Eng-Gilroy/Gilroy-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Gilroy';
    src: url('/static/fonts/Corporate_Font_Eng-Gilroy/Gilroy-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Gilroy';
    src: url('/static/fonts/Corporate_Font_Eng-Gilroy/Gilroy-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Gilroy';
    src: url('/static/fonts/Corporate_Font_Eng-Gilroy/Gilroy-ExtraBold.ttf') format('truetype');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

/* ─── Status badges ─── */
.status-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-badge-lg {
    display: inline-block;
    padding: 6px 20px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-queued {
    background-color: #fef3c7;  /* yellow-100 */
    color: #92400e;             /* yellow-800 */
}

.status-running {
    background-color: #dbeafe;  /* blue-100 */
    color: #002D72;             /* peak-blue */
}

.status-completed {
    background-color: #d1fae5;  /* green-100 */
    color: #047857;             /* green-700 */
}

.status-failed {
    background-color: #fee2e2;  /* red-100 */
    color: #b91c1c;             /* red-700 */
}


/* ─── Tabs ─── */
.tab-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    color: #002D72;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -1px;
}

.tab-button:hover {
    color: #FF6600;
    background-color: #f9fafb;
}

.tab-button.active {
    color: #FF6600;
    background-color: white;
    border-bottom-color: #FF6600;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.tab-content {
    display: none;
    animation: fadeIn 0.25s ease-out;
}

.tab-content.active {
    display: block;
}


/* ─── Logs terminal ─── */
.logs {
    background-color: #1a1a2e;
    color: #d4d4d4;
    padding: 20px;
    border-radius: 8px;
    font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.7;
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #2d2d44;
}


/* ─── Data table (JS-generated) ─── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    background-color: #f8fafc;
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 12px;
    color: #002D72;
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 1;
    white-space: nowrap;
}

.data-table td {
    padding: 8px 14px;
    border-bottom: 1px solid #f1f5f9;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #374151;
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
}

.data-table tbody tr:nth-child(even) {
    background-color: #fafbfc;
}

.data-table tbody tr:nth-child(even):hover {
    background-color: #f0f4f8;
}


/* ─── Animations ─── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
    0%   { background-position: -1000px 0; }
    100% { background-position:  1000px 0; }
}

.skeleton {
    animation: shimmer 2s infinite;
    background: linear-gradient(to right, #f0f0f0 4%, #e0e0e0 25%, #f0f0f0 36%);
    background-size: 1000px 100%;
    border-radius: 4px;
}


/* ─── Focus ring consistency ─── */
select:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
textarea:focus {
    outline: none;
    box-shadow: 0 0 0 2px #FF6600;
    border-color: transparent;
}

input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 2px #FF6600;
}


/* ─── Scrollbar (dark terminal) ─── */
.logs::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.logs::-webkit-scrollbar-track {
    background: #1a1a2e;
}

.logs::-webkit-scrollbar-thumb {
    background: #4a4a6a;
    border-radius: 4px;
}

.logs::-webkit-scrollbar-thumb:hover {
    background: #5a5a7a;
}


/* ─── Risk band filter pills (Data Preview tab) ─── */
.band-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.band-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 14px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    background-color: #f1f5f9;
    color: #374151;
    user-select: none;
}

.band-filter-pill:hover {
    background-color: #e2e8f0;
    border-color: #cbd5e1;
}

.band-filter-pill.active {
    border-color: currentColor;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.08);
}

.band-filter-pill.pill-all.active   { background-color: #002D72; color: white; border-color: #002D72; }
.band-filter-pill.pill-low.active   { background-color: #dcfce7; color: #15803d; border-color: #16a34a; }
.band-filter-pill.pill-medium.active { background-color: #fef9c3; color: #a16207; border-color: #ca8a04; }
.band-filter-pill.pill-high.active  { background-color: #fee2e2; color: #b91c1c; border-color: #dc2626; }
.band-filter-pill.pill-unknown.active { background-color: #f1f5f9; color: #475569; border-color: #94a3b8; }

.band-filter-pill .pill-count {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 700;
    background: rgba(0,0,0,0.08);
    min-width: 18px;
    text-align: center;
}

/* ─── Risk band cell badges (in data table) ─── */
.risk-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.risk-badge-low     { background-color: #dcfce7; color: #15803d; }
.risk-badge-medium  { background-color: #fef9c3; color: #a16207; }
.risk-badge-high    { background-color: #fee2e2; color: #b91c1c; }
.risk-badge-unknown { background-color: #f1f5f9; color: #64748b; }

/* ─── Data Preview scrollable table viewport ─── */
.data-table-scroll {
    overflow-y: auto;
    overflow-x: auto;
    max-height: 580px;   /* roughly matches report tab's visible height */
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

/* Keep the sticky header working inside the scroll container */
.data-table-scroll .data-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: #f8fafc;
}

/* Thin scrollbar so it doesn't eat horizontal space */
.data-table-scroll::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.data-table-scroll::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}
.data-table-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.data-table-scroll::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ─── Clickable risk rows in embedded report ─── */
.report-band-clickable {
    cursor: pointer;
    transition: opacity 0.15s;
}
.report-band-clickable:hover {
    opacity: 0.75;
}

/* ─── Exposure Map tab ─── */

/* The map tab panel itself doesn't pad — the map fills edge to edge */
.map-tab-panel {
    /* override the p-6 padding of the parent .tab-content wrapper */
    margin: -24px;   /* negate the p-6 (1.5rem = 24px) */
    padding: 24px;   /* re-add padding only for the pill bar + status bar */
}

/* Wrapper for map canvas + overlays */
.map-container-wrapper {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    margin-bottom: 10px;
}

/* Mapbox canvas */
.map-canvas {
    width: 100%;
    height: 520px;
}

/* Legend overlay (bottom-right) */
.map-legend {
    position: absolute;
    bottom: 36px;
    right: 10px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12px;
    color: #374151;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    z-index: 10;
    min-width: 110px;
}

.map-legend-item {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin-bottom: 7px;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
}

.map-legend-item:last-child {
    margin-bottom: 0;
}

.map-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 2px;
}

.map-legend-sub {
    display: block;
    font-size: 10px;
    font-weight: 400;
    color: #6b7280;
    margin-top: 1px;
}

/* Status bar below the map */
.map-status-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 0;
    padding: 0 2px;
    min-height: 20px;
}

/* Mapbox popup styling */
.map-popup {
    font-family: inherit;
    font-size: 13px;
    color: #374151;
    min-width: 180px;
}

.map-popup-id {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    color: #002D72;
    margin-bottom: 6px;
    word-break: break-all;
}

.map-popup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12px;
}

.map-popup-label {
    color: #6b7280;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* Override Mapbox attribution bar to be less obtrusive */
.mapboxgl-ctrl-attrib {
    font-size: 10px !important;
    opacity: 0.7;
}

.mapboxgl-popup-content {
    padding: 12px 14px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border: 1px solid #e2e8f0;
}

.mapboxgl-popup-close-button {
    font-size: 16px;
    color: #6b7280;
    padding: 4px 6px;
}

/* Responsive: shrink map on small screens */
@media (max-width: 640px) {
    .map-canvas {
        height: 360px;
    }
    .map-legend {
        font-size: 11px;
        padding: 8px 10px;
        bottom: 32px;
    }
}

/* ─── Print styles ─── */
@media print {
    header, footer, .tab-button, #refreshBtn {
        display: none !important;
    }
    .tab-content {
        display: block !important;
    }
    body {
        background: white;
    }
}
