/* ══════════════════════════════════════════════════════════════
   AG Grid Quartz — Biomed Design System Overrides
   ══════════════════════════════════════════════════════════════ */

/* ── Light Mode ────────────────────────────────────────────── */

.ag-theme-quartz.biomed-grid {
    --ag-background-color: var(--biomed-card-bg);
    --ag-foreground-color: var(--biomed-text);
    --ag-header-background-color: var(--biomed-table-header-bg);
    --ag-header-foreground-color: var(--biomed-table-header-color);
    --ag-border-color: var(--biomed-border);
    --ag-row-border-color: var(--biomed-border);
    --ag-secondary-border-color: var(--biomed-border);
    --ag-odd-row-background-color: var(--biomed-card-bg);
    --ag-row-hover-color: var(--biomed-card-bg-hover);
    --ag-selected-row-background-color: var(--primary-50);
    --ag-range-selection-background-color: var(--primary-50);
    --ag-header-cell-hover-background-color: var(--biomed-primary-light);
    --ag-input-focus-border-color: var(--biomed-accent);
    --ag-checkbox-checked-color: var(--biomed-accent);
    --ag-font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    --ag-font-size: 0.82rem;
    --ag-row-height: 36px;
    --ag-header-height: 38px;
    --ag-grid-size: 4px;
    --ag-cell-horizontal-padding: 12px;
    --ag-wrapper-border-radius: 8px;
    --ag-card-shadow: var(--biomed-shadow-sm);
    --ag-icon-size: 14px;

    border-radius: 8px;
    overflow: hidden;
}

/* Header typography */
.ag-theme-quartz.biomed-grid .ag-header-cell-text {
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.3px;
    font-weight: 600;
}

/* Floating filter input */
.ag-theme-quartz.biomed-grid .ag-floating-filter-input {
    font-size: 0.78rem;
}

/* Cell text */
.ag-theme-quartz.biomed-grid .ag-cell {
    line-height: 36px;
}

/* No rows overlay */
.ag-theme-quartz.biomed-grid .ag-overlay-no-rows-wrapper {
    padding: 40px 20px;
}

.ag-theme-quartz.biomed-grid .ag-overlay-no-rows-center {
    font-size: 0.88rem;
    color: var(--biomed-text-light);
    font-weight: 500;
}

/* ── Dark Mode ─────────────────────────────────────────────── */

[data-bs-theme="dark"] .ag-theme-quartz.biomed-grid {
    --ag-background-color: var(--biomed-card-bg);
    --ag-foreground-color: var(--biomed-text);
    --ag-header-background-color: var(--biomed-table-header-bg);
    --ag-header-foreground-color: var(--biomed-table-header-color);
    --ag-border-color: var(--biomed-border);
    --ag-row-border-color: var(--biomed-border);
    --ag-secondary-border-color: var(--biomed-border);
    --ag-odd-row-background-color: var(--biomed-card-bg);
    --ag-row-hover-color: var(--biomed-card-bg-hover);
    --ag-selected-row-background-color: rgba(96, 165, 250, 0.15);
    --ag-range-selection-background-color: rgba(96, 165, 250, 0.15);
    --ag-header-cell-hover-background-color: var(--gray-700);
    --ag-input-focus-border-color: var(--biomed-accent);
    --ag-checkbox-checked-color: var(--biomed-accent);
    --ag-control-panel-background-color: var(--gray-800);
    --ag-subheader-background-color: var(--gray-800);
    --ag-input-border-color: var(--gray-600);
}

/* ── Compact Variant ───────────────────────────────────────── */

.ag-theme-quartz.biomed-grid.biomed-grid-compact {
    --ag-row-height: 32px;
    --ag-header-height: 34px;
    --ag-font-size: 0.78rem;
    --ag-cell-horizontal-padding: 8px;
}

.ag-theme-quartz.biomed-grid.biomed-grid-compact .ag-header-cell-text {
    font-size: 0.68rem;
}

/* ══════════════════════════════════════════════════════════════
   Badge & Renderer CSS Classes
   ══════════════════════════════════════════════════════════════ */

/* ── Generic Badge ─────────────────────────────────────────── */

.badge-custom {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.70rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    line-height: 1.4;
    white-space: nowrap;
}

/* ── ABC Curve ─────────────────────────────────────────────── */

.badge-custom.abc-a {
    background: var(--success-100);
    color: var(--success-700);
}

.badge-custom.abc-b {
    background: var(--warning-100);
    color: var(--warning-600);
}

.badge-custom.abc-c {
    background: var(--gray-100);
    color: var(--gray-600);
}

[data-bs-theme="dark"] .badge-custom.abc-a {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

[data-bs-theme="dark"] .badge-custom.abc-b {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

[data-bs-theme="dark"] .badge-custom.abc-c {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
}

/* ── Priority ──────────────────────────────────────────────── */

.badge-custom.priority-urgente {
    background: var(--danger-100);
    color: var(--danger-700);
}

.badge-custom.priority-alto {
    background: var(--warning-100);
    color: var(--warning-600);
}

.badge-custom.priority-medio {
    background: var(--primary-100);
    color: var(--primary-700);
}

.badge-custom.priority-baixo {
    background: var(--gray-100);
    color: var(--gray-600);
}

[data-bs-theme="dark"] .badge-custom.priority-urgente {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

[data-bs-theme="dark"] .badge-custom.priority-alto {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

[data-bs-theme="dark"] .badge-custom.priority-medio {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
}

[data-bs-theme="dark"] .badge-custom.priority-baixo {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
}

/* ── Nivel (critico/baixo/ok) ──────────────────────────────── */

.badge-custom.nivel-critico {
    background: var(--danger-100);
    color: var(--danger-700);
}

.badge-custom.nivel-baixo {
    background: var(--warning-100);
    color: var(--warning-600);
}

.badge-custom.nivel-ok {
    background: var(--success-100);
    color: var(--success-700);
}

[data-bs-theme="dark"] .badge-custom.nivel-critico {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

[data-bs-theme="dark"] .badge-custom.nivel-baixo {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

[data-bs-theme="dark"] .badge-custom.nivel-ok {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

/* ── Semantic Badges ───────────────────────────────────────── */

.badge-custom.badge-success {
    background: var(--success-100);
    color: var(--success-700);
}

.badge-custom.badge-info {
    background: var(--primary-100);
    color: var(--primary-700);
}

.badge-custom.badge-primary {
    background: var(--primary-100);
    color: var(--primary-700);
}

.badge-custom.badge-danger {
    background: var(--danger-100);
    color: var(--danger-700);
}

.badge-custom.badge-warning {
    background: var(--warning-100);
    color: var(--warning-600);
}

.badge-custom.badge-secondary {
    background: var(--gray-100);
    color: var(--gray-600);
}

[data-bs-theme="dark"] .badge-custom.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

[data-bs-theme="dark"] .badge-custom.badge-info,
[data-bs-theme="dark"] .badge-custom.badge-primary {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
}

[data-bs-theme="dark"] .badge-custom.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

[data-bs-theme="dark"] .badge-custom.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

[data-bs-theme="dark"] .badge-custom.badge-secondary {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
}

/* ── Status (ativo/inativo/irregular) ──────────────────────── */

.badge-custom.status-ativo {
    background: var(--success-100);
    color: var(--success-700);
}

.badge-custom.status-inativo {
    background: var(--gray-100);
    color: var(--gray-600);
}

.badge-custom.status-irregular {
    background: var(--danger-100);
    color: var(--danger-700);
}

[data-bs-theme="dark"] .badge-custom.status-ativo {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

[data-bs-theme="dark"] .badge-custom.status-inativo {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
}

[data-bs-theme="dark"] .badge-custom.status-irregular {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

/* ══════════════════════════════════════════════════════════════
   Coverage Bar
   ══════════════════════════════════════════════════════════════ */

.coverage-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.coverage-bar .bar {
    flex: 1;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

[data-bs-theme="dark"] .coverage-bar .bar {
    background: var(--gray-700);
}

.coverage-bar .bar .fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.coverage-bar .bar .fill.critical {
    background: var(--danger-500);
}

.coverage-bar .bar .fill.low {
    background: var(--warning-500);
}

.coverage-bar .bar .fill.ok {
    background: var(--success-500);
}

.coverage-bar .days-text {
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    min-width: 32px;
    text-align: right;
}

/* ══════════════════════════════════════════════════════════════
   Margin Bar
   ══════════════════════════════════════════════════════════════ */

.margin-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.margin-bar .track {
    flex: 1;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

[data-bs-theme="dark"] .margin-bar .track {
    background: var(--gray-700);
}

.margin-bar .fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.margin-bar .pct-text {
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    min-width: 38px;
    text-align: right;
}

/* ══════════════════════════════════════════════════════════════
   RFM Pips
   ══════════════════════════════════════════════════════════════ */

.rfm-pip {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 2px;
    opacity: 0.25;
}

.rfm-pip.active {
    opacity: 1;
}

.rfm-pip.r { background: var(--danger-500); }
.rfm-pip.f { background: var(--primary-500); }
.rfm-pip.m { background: var(--success-500); }

/* ── RFM Segment Badges ────────────────────────────────────── */

.badge-custom.seg-champions {
    background: var(--success-100);
    color: var(--success-700);
}

.badge-custom.seg-loyal {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-custom.seg-potential {
    background: #e0e7ff;
    color: #4338ca;
}

.badge-custom.seg-recent {
    background: #fef3c7;
    color: #b45309;
}

.badge-custom.seg-attention {
    background: var(--warning-100);
    color: var(--warning-600);
}

.badge-custom.seg-risk {
    background: var(--danger-50);
    color: var(--danger-600);
}

.badge-custom.seg-lost {
    background: var(--gray-100);
    color: var(--gray-600);
}

[data-bs-theme="dark"] .badge-custom.seg-champions {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

[data-bs-theme="dark"] .badge-custom.seg-loyal {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}

[data-bs-theme="dark"] .badge-custom.seg-potential {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
}

[data-bs-theme="dark"] .badge-custom.seg-recent {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

[data-bs-theme="dark"] .badge-custom.seg-attention {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

[data-bs-theme="dark"] .badge-custom.seg-risk {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

[data-bs-theme="dark"] .badge-custom.seg-lost {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
}
