/* ── AI Analytics FAB ─────────────────────────────────────── */
.ai-fab {
    position: absolute;
    top: -5.5rem;
    right: 2.5rem;
    background: #6366f1;
    color: #fff;
    font-size: 1.25rem;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.5);
    z-index: 900;
    transition: transform 0.15s, box-shadow 0.15s;
}

.ai-fab:hover {
    transform: scale(1.1);
    background: #6366f1;
    color: #fff;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.65);
}

/* ── AI Analysis Bottom Drawer ─────────────────────────────── */
.ai-analysis-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    backdrop-filter: blur(16px);
    border-top-left-radius: 1rem;
    border-top-right-radius: 1rem;
    max-height: 70vh;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-analysis-drawer.open {
    transform: translateY(0);
}

/* Cards grid */
.ai-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
}

/* Metric card colour accents (top border) */
.ai-metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--bs-card-border-radius) var(--bs-card-border-radius) 0 0;
}

.ai-metric-card.card-indigo::before {
    background: linear-gradient(90deg, #6366f1, #818cf8);
}

.ai-metric-card.card-emerald::before {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.ai-metric-card.card-amber::before {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.ai-metric-card.card-rose::before {
    background: linear-gradient(90deg, #f43f5e, #fb7185);
}

.ai-metric-card.card-sky::before {
    background: linear-gradient(90deg, #0ea5e9, #38bdf8);
}

.ai-metric-card.card-violet::before {
    background: linear-gradient(90deg, #8b5cf6, #a78bfa);
}

.ai-metric-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
    transform: translateY(-1px);
}

/* Comparison badges */
.ai-cmp-badge {
    font-size: .65rem;
    font-weight: 600;
    padding: .15rem .45rem;
    line-height: 1.3;
    gap: .15rem;
}

.ai-cmp-badge.positive {
    background: #d1fae5;
    color: #065f46;
}

.ai-cmp-badge.negative {
    background: #fee2e2;
    color: #991b1b;
}

.ai-cmp-badge.neutral {
    background: #f3f4f6;
    color: #6b7280;
}

/* Level toggle pills */
.ai-level-pill {
    font-size: .62rem;
    font-weight: 600;
    padding: .15rem .55rem;
    border-radius: 20px;
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    color: var(--bs-secondary-color);
    cursor: pointer;
    transition: all .15s ease;
    line-height: 1.4;
}

.ai-level-pill:hover {
    background: #eef2ff;
    border-color: #a5b4fc;
    color: #4338ca;
}

.ai-level-pill.active {
    background: #6366f1;
    border-color: #6366f1;
    color: #fff;
}

/* Horizontal bar chart */
.ai-bar-chart {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.ai-bar-row {
    display: flex;
    align-items: center;
    gap: .4rem;
}

.ai-bar-label {
    font-size: .68rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
    min-width: 2.5rem;
    text-align: right;
    flex-shrink: 0;
}

.ai-bar-track {
    flex: 1;
    height: 14px;
    background: var(--bs-tertiary-bg);
    border-radius: 7px;
    overflow: hidden;
}

.ai-bar-fill {
    height: 100%;
    border-radius: 7px;
    transition: width .5s cubic-bezier(.4, 0, .2, 1);
    min-width: 2px;
}

.ai-bar-pct {
    font-size: .68rem;
    font-weight: 700;
    min-width: 2.5rem;
    text-align: left;
    flex-shrink: 0;
}

/* Responsive */
@media (max-width: 640px) {
    .ai-analysis-drawer {
        max-height: 85vh;
    }

    .ai-cards-grid {
        grid-template-columns: 1fr;
    }
}

/* Utility classes for card typography */
.ai-card-label {
    font-size: .7rem;
    letter-spacing: .04em;
}

.ai-card-unit {
    font-size: .7rem;
}

.ai-badge-xs {
    font-size: .65rem;
}

.ai-drawer-body {
    min-height: 0;
}
