/* ============================================================
   AI Insights Panel — Advanced Executive-Summary Style
   ============================================================
   Drop-in addition to site.css. Applies only inside
   .ai-drawer--advanced so it does not affect the existing panel.
   ============================================================ */

/* ── Report context badge ── */
.ai-panel-section-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #99CB56;
    background: rgba(153, 203, 86, 0.08);
    border: 1px solid rgba(153, 203, 86, 0.22);
    border-radius: 20px;
    padding: 0.22rem 0.7rem;
    margin-bottom: 0.5rem;
}

.ai-panel-section-badge svg { flex-shrink: 0; }

/* ── Panel title ── */
.ai-panel-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--color-text);
    margin: 0 0 0.85rem;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

/* ============================================================
   KPI Callout Grid — 2×2 within drawer width
   ============================================================ */
.ai-panel-kpis {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    margin-bottom: 1rem;
}

.ai-kpi {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 0.65rem 0.75rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all 0.25s ease;
}

.ai-kpi:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Bottom accent line */
.ai-kpi::before {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
}

.ai-kpi--blue::before   { background: linear-gradient(90deg, #00AFE9, transparent); }
.ai-kpi--green::before  { background: linear-gradient(90deg, #99CB56, transparent); }
.ai-kpi--amber::before  { background: linear-gradient(90deg, #F0A500, transparent); }
.ai-kpi--muted::before  { background: linear-gradient(90deg, var(--color-text-muted), transparent); }
.ai-kpi--red::before    { background: linear-gradient(90deg, #e05c5c, transparent); }

.ai-kpi__value {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--color-text);
}

.ai-kpi--blue  .ai-kpi__value { color: #00AFE9; }
.ai-kpi--green .ai-kpi__value { color: #99CB56; }
.ai-kpi--amber .ai-kpi__value { color: #F0A500; }
.ai-kpi--red   .ai-kpi__value { color: #e05c5c; }

.ai-kpi__label {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.58rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    margin-top: 0.2rem;
}

/* Optional mini bar */
.ai-kpi__bar {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    margin-top: 0.4rem;
    overflow: hidden;
}

.ai-kpi__bar-fill {
    height: 100%;
    border-radius: 2px;
    background: currentColor;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-kpi--green .ai-kpi__bar-fill { background: #99CB56; }
.ai-kpi--muted .ai-kpi__bar-fill { background: var(--color-text-muted); }

/* Trend indicator */
.ai-kpi__trend {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-top: 0.3rem;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    display: inline-block;
}

.ai-kpi__trend--up {
    color: #99CB56;
    background: rgba(153, 203, 86, 0.1);
}

.ai-kpi__trend--down {
    color: #e05c5c;
    background: rgba(224, 92, 92, 0.1);
}

.ai-kpi__trend--flat {
    color: var(--color-text-muted);
    background: rgba(255, 255, 255, 0.04);
}

/* ============================================================
   Lead summary
   ============================================================ */
.ai-panel-lead {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.84rem;
    font-weight: 500;
    color: #bcc3cb;
    border-left: 4px solid #99CB56;
    padding-left: 0.85rem;
    margin-bottom: 1.1rem;
    line-height: 1.6;
}

/* ============================================================
   Detail sections
   ============================================================ */
.ai-panel-section {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.ai-panel-section:last-child {
    border-bottom: none;
}

.ai-panel-section__title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-accent);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ai-panel-section__title::before {
    content: '';
    width: 3px;
    height: 14px;
    background: var(--color-accent);
    border-radius: 2px;
    flex-shrink: 0;
}

.ai-panel-section__body {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.84rem;
    color: #bcc3cb;
    line-height: 1.6;
    margin-bottom: 0.6rem;
}

/* ============================================================
   Warning rows — SLA style with optional gauge
   ============================================================ */
.ai-panel-warning {
    background: rgba(240, 165, 0, 0.04);
    border-left: 3px solid rgba(240, 165, 0, 0.5);
    border-radius: 0 8px 8px 0;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.45rem;
    transition: background 0.2s ease;
}

.ai-panel-warning:hover {
    background: rgba(240, 165, 0, 0.07);
}

.ai-panel-warning--critical {
    border-left-color: rgba(224, 92, 92, 0.6);
    background: rgba(224, 92, 92, 0.04);
}

.ai-panel-warning--critical:hover {
    background: rgba(224, 92, 92, 0.07);
}

.ai-panel-warning__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.ai-panel-warning__label {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    color: #bcc3cb;
    line-height: 1.4;
}

.ai-panel-warning__value {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    color: #F0A500;
    white-space: nowrap;
    flex-shrink: 0;
}

.ai-panel-warning--critical .ai-panel-warning__value {
    color: #e05c5c;
}

/* Gauge bar with target marker */
.ai-panel-gauge {
    margin-top: 0.4rem;
}

.ai-panel-gauge__track {
    position: relative;
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: visible;
}

.ai-panel-gauge__fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #F0A500, rgba(240, 165, 0, 0.6));
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

.ai-panel-warning--critical .ai-panel-gauge__fill {
    background: linear-gradient(90deg, #e05c5c, rgba(224, 92, 92, 0.6));
}

.ai-panel-gauge__target {
    position: absolute;
    top: -3px;
    width: 2px;
    height: 11px;
    background: #99CB56;
    border-radius: 1px;
    z-index: 2;
    box-shadow: 0 0 4px rgba(153, 203, 86, 0.5);
}

.ai-panel-gauge__labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.25rem;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.55rem;
    font-weight: 600;
    color: var(--color-text-muted);
    letter-spacing: 0.03em;
}

.ai-panel-warning__detail {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.35rem;
    padding-top: 0.3rem;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    line-height: 1.5;
}

/* ============================================================
   Metric bars (e.g. spend by supplier, allocation %)
   ============================================================ */
.ai-panel-metric {
    margin-bottom: 0.6rem;
}

.ai-panel-metric__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.ai-panel-metric__label {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    color: #bcc3cb;
}

.ai-panel-metric__value {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
    margin-left: 0.5rem;
}

.ai-panel-metric__bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 3px;
    overflow: hidden;
}

.ai-panel-metric__bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-panel-metric__sublabel {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.68rem;
    color: var(--color-text-muted);
    margin-top: 0.15rem;
    line-height: 1.4;
}

/* ============================================================
   Action items — verb badge + text
   ============================================================ */
.ai-panel-action {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.5rem 0.65rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
    margin-bottom: 0.35rem;
    transition: background 0.2s ease;
}

.ai-panel-action:hover {
    background: rgba(255, 255, 255, 0.04);
}

.ai-panel-action__verb {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-top: 1px;
}

.ai-panel-action__verb--green {
    color: #99CB56;
    background: rgba(153, 203, 86, 0.1);
}

.ai-panel-action__verb--amber {
    color: #F0A500;
    background: rgba(240, 165, 0, 0.1);
}

.ai-panel-action__verb--red {
    color: #e05c5c;
    background: rgba(224, 92, 92, 0.1);
}

.ai-panel-action__verb--blue {
    color: #00AFE9;
    background: rgba(0, 175, 233, 0.1);
}

.ai-panel-action__text {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.82rem;
    color: #bcc3cb;
    line-height: 1.5;
}

/* ============================================================
   Collapsible full narrative
   ============================================================ */
.ai-panel-details {
    margin-top: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
}

.ai-panel-details summary {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.6rem 0.85rem;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.2s ease;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ai-panel-details summary::before {
    content: '\25B6';
    font-size: 0.55rem;
    transition: transform 0.2s ease;
}

.ai-panel-details[open] summary::before {
    transform: rotate(90deg);
}

.ai-panel-details summary:hover {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.04);
}

.ai-panel-details summary::-webkit-details-marker {
    display: none;
}

.ai-panel-details .ai-narrative {
    padding: 0.75rem 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* ============================================================
   Responsive — narrow viewports
   ============================================================ */
@media (max-width: 500px) {
    .ai-panel-kpis {
        grid-template-columns: 1fr;
    }
}
