/* -----------------------------------------------------------------------------
   bi-dashboards.css

   Shared layout for the Business Intelligence module (the dashboards are
   separate Blazor components, so their common layout classes live here as global
   styles rather than per-component scoped CSS). All colours are theme tokens, so
   the module reads correctly in light / soft / dark / ai.

   Project : AspireAIApp.Web
   Author  : Theodor Harmse (Teddy)
   Created : 2026-06-25
----------------------------------------------------------------------------- */

.bi-dash {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bi-dash__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.85rem;
}

.bi-dash__title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
}

.bi-dash__lead {
    margin: 0.15rem 0 0;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.bi-dash__controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.bi-dash__control-label {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.bi-dash__controls .form-select {
    width: auto;
    min-width: 9.5rem;
}

.bi-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
    gap: 0.85rem;
}

.bi-dash__detail {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.6rem 2.2rem 0.6rem 0.85rem;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--module-accent-bi) 35%, var(--glass-line-soft));
    background: color-mix(in srgb, var(--module-accent-bi) 10%, var(--glass-surface-strong));
    color: var(--text-primary);
    font-size: 0.875rem;
}

.bi-dash__detail-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--module-accent-bi);
    flex: 0 0 auto;
}

.bi-dash__detail-close {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
}

.bi-dash__detail-close:hover {
    color: var(--text-primary);
}

.bi-dash__note {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
}

/* "Needs attention" pills (Executive Summary) */
.bi-attn {
    --attn: var(--module-accent-bi);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-primary);
    border: 1px solid color-mix(in srgb, var(--attn) 45%, var(--glass-line-soft));
    background: color-mix(in srgb, var(--attn) 14%, var(--glass-surface-strong));
    transition: transform 0.15s ease;
}

.bi-attn:hover {
    transform: translateY(-1px);
    color: var(--text-primary);
}

.bi-attn--danger { --attn: var(--color-danger); }
.bi-attn--warning { --attn: var(--color-warning); }

/* Overview landing grid */
.bi-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 1rem;
}

.bi-overview-card {
    --card-accent: var(--module-accent-bi);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1.05rem 1.1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-line-soft);
    text-decoration: none;
    color: var(--text-primary);
    min-height: 7.5rem;
    background:
        radial-gradient(ellipse at 70% 115%, color-mix(in srgb, var(--card-accent) 12%, transparent), transparent 55%),
        linear-gradient(150deg, color-mix(in srgb, var(--glass-surface-strong) 88%, transparent), color-mix(in srgb, var(--glass-surface) 84%, transparent));
    box-shadow: 0 10px 22px color-mix(in srgb, var(--glass-shadow) 45%, transparent);
    backdrop-filter: blur(16px) saturate(1.04);
    transition: transform var(--transition-duration, 0.2s) var(--transition-timing, ease), box-shadow var(--transition-duration, 0.2s) var(--transition-timing, ease);
}

.bi-overview-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 30px color-mix(in srgb, var(--glass-shadow) 58%, transparent);
    color: var(--text-primary);
}

.bi-overview-card__title {
    font-size: 1.02rem;
    font-weight: 700;
}

.bi-overview-card__desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.bi-overview-card__cta {
    margin-top: auto;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--module-accent-bi);
}

/* Detail data tables (so the records behind the charts are visible) */
.bi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.bi-table th {
    text-align: left;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--glass-line-soft);
    padding: 0.4rem 0.6rem;
    position: sticky;
    top: 0;
}

.bi-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--glass-line-soft);
    color: var(--text-primary);
}

.bi-table tbody tr:hover td {
    background: color-mix(in srgb, var(--module-accent-bi) 7%, transparent);
}

.bi-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.bi-table__scroll {
    max-height: 22rem;
    overflow: auto;
}

/* Scope filter + single-subject banner + assessment summary text */
.bi-scope-select {
    min-width: 16rem;
    max-width: 26rem;
}

.bi-scope-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.85rem;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--module-accent-bi) 35%, var(--glass-line-soft));
    background: color-mix(in srgb, var(--module-accent-bi) 10%, var(--glass-surface-strong));
    color: var(--text-primary);
    font-size: 0.875rem;
}

.bi-scope-banner__dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--module-accent-bi);
    flex: 0 0 auto;
}

.bi-scope-banner__clear {
    margin-left: auto;
    padding: 0;
    font-size: 0.875rem;
}

.bi-summary-text {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.55;
    white-space: pre-wrap;
}

/* Print / PDF — render the dashboard as a clean white report. ApexCharts is SVG so
   charts print; aspire-charts.js also switches to the light theme on beforeprint so
   chart text/grid are legible on white regardless of the on-screen theme. */
@media print {
    /* Lock to A4 portrait so layout is deterministic (aspire-charts.js sizes the chart SVGs to
       this content width before printing). */
    @page {
        size: A4 portrait;
        margin: 12mm;
    }

    /* Hide all app chrome (sidebar, top bar, floating assistant, controls, buttons). */
    .sidebar,
    .bi-export,
    .bi-dash__controls,
    .bi-chart-card__toolbar,
    .bi-scope-banner__clear,
    .notification-bell,
    header,
    nav,
    button,
    .btn,
    [class*="launcher"],
    [class*="chat-fab"],
    [class*="ai-chat"] {
        display: none !important;
    }

    html,
    body {
        background: #ffffff !important;
        color: #111111 !important;
    }

    /* Full page width; never keep the on-screen flex/sidebar offset. */
    .content,
    main,
    .bi-dash {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Collapse every multi-column layout to a single column so each chart gets the full page width
       (this is the main cause of the old overlap: Bootstrap .row columns + auto-fit grids stayed
       multi-column on the narrow print page while the chart SVG kept its wide on-screen width). */
    .bi-kpi-grid,
    .bi-overview-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
    }

    .row {
        display: block !important;
        margin: 0 !important;
    }

    .row > [class*="col-"] {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        padding: 0 !important;
        margin: 0 0 10px 0 !important;
    }

    /* Flatten glass surfaces to clean WHITE bordered cards (print is always a light report,
       independent of the on-screen theme). The theme paints the card's aurora gradient via
       `.card.panel-card { background-image: var(--surface-aurora) !important }` (specificity 0,2,0),
       so the print override is body-prefixed (0,2,1) to out-specify it AND explicitly clears
       background-image — otherwise cards print with the dark on-screen gradient. */
    body .bi-kpi,
    body .card,
    body .panel-card,
    body .card.panel-card,
    body .panel-card.card,
    body .bi-chart-card,
    body .card.bi-chart-card,
    body .card-header,
    body .card-footer,
    body .bi-scope-banner {
        background: #ffffff !important;
        background-color: #ffffff !important;
        background-image: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        border: 1px solid #cbd2da !important;
        color: #111111 !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
    }

    /* Belt-and-braces: kill any remaining gradient/shadow on descendants inside the dashboard. */
    body .bi-dash * {
        box-shadow: none !important;
        backdrop-filter: none !important;
        text-shadow: none !important;
    }

    /* Keep the chart canvas inside the page; ApexCharts re-renders to the print width on beforeprint. */
    .bi-chart-card__canvas,
    .apexcharts-canvas {
        width: 100% !important;
        max-width: 100% !important;
    }

    .bi-dash__title,
    .bi-dash__lead,
    .bi-chart-card__title,
    .bi-chart-card__subtitle,
    .bi-kpi__label,
    .bi-kpi__value,
    .bi-kpi__caption,
    .bi-summary-text,
    .bi-scope-banner,
    .bi-table th,
    .bi-table td,
    .bi-attn {
        color: #111111 !important;
    }

    .bi-table th {
        color: #444444 !important;
        border-bottom: 1px solid #cbd2da !important;
    }

    .bi-table td {
        border-bottom: 1px solid #e4e8ec !important;
    }

    .bi-table__scroll {
        max-height: none !important;
        overflow: visible !important;
    }

    .bi-table tr,
    .bi-attn {
        break-inside: avoid;
    }

    a {
        color: #111111 !important;
        text-decoration: none !important;
    }

    /* Print accent colours / chart fills as drawn. */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
