/**
 * css/views/pivot_view.css - V1.4.3
 * RÔLE : Isolation Absolue + Thème CooraViz Natif
 * - FIX : Utilisation stricte des variables --var du dashboard.
 * - FIX : Rétablissement de la visibilité des group-headers (thead).
 * - UI : Scrollbar assortie au thème.
 */

/* 1. LE CONTAINER (Cadre rigide) */
.pivot-view-container {
    width: 100% !important;
    min-width: 0 !important;
    position: relative;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border);
    min-height: 450px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 2. LE VIEWPORT MASK (Isolation Flexbox) */
.pivot-viewport-mask {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden;
}

/* 3. LE SCROLL WRAPPER */
.pivot-scroll-wrapper {
    width: 100%;
    height: 100%;
    overflow-x: auto !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 4. LA TABLE */
.pivot-table {
    display: table !important;
    width: max-content !important;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-card);
}

/* 5. SYSTÈME STICKY (Fixation des titres et colonnes) */

/* Colonnes de gauche (Dimensions) */
.pivot-table .sticky-col {
    position: sticky;
    left: 0;
    z-index: 10;
    background-color: var(--bg-card) !important;
    border-right: 2px solid var(--border);
}

/* En-têtes (Thead) */
.pivot-table thead th {
    position: sticky;
    top: 0;
    z-index: 20;
    background-color: var(--day-bg); /* Utilisation du gris de fond thème */
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    font-weight: 700;
}

/* Intersection haut-gauche */
.pivot-table thead th.sticky-col {
    z-index: 30;
    background-color: var(--day-bg) !important;
}

/* 6. HIÉRARCHIE VISUELLE (Thème) */

/* Titres des groupes (Ligne 1) */
.group-header {
    background-color: var(--day-bg);
    color: var(--text-main);
    text-align: center;
    border-bottom: 2px solid var(--border) !important;
}

/* Le Total Général (Primary) */
.total-group-header {
    background-color: var(--primary) !important;
    color: #ffffff !important;
    text-align: center;
    border-right: 3px solid var(--border) !important;
}

/* Titres des métriques (Ligne 2) */
.metric-header {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background-color: var(--bg-card);
}

.total-metric-header {
    background-color: var(--day-bg) !important;
    color: var(--primary);
}

/* 7. CELLULES DE DONNÉES */

.pivot-table td, .pivot-table th {
    padding: 12px 18px;
    white-space: nowrap !important;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

/* Colonne des totaux (Mise en évidence) */
.total-cell-highlight {
    background-color: var(--day-bg) !important;
    font-weight: 700;
    color: var(--primary);
    border-right: 3px solid var(--border) !important;
}

.dim-cell {
    font-weight: 600;
    color: var(--primary);
    min-width: 200px;
    text-align: left;
}

/* Pied de tableau (Grand Total) */
.grand-total-highlight {
    background-color: var(--primary) !important;
    color: #ffffff !important;
    font-weight: 700;
}

/* 8. SCROLLBAR (Assortie au Primary) */
.pivot-scroll-wrapper::-webkit-scrollbar {
    height: 12px;
    width: 12px;
}
.pivot-scroll-wrapper::-webkit-scrollbar-track {
    background: var(--day-bg);
}
.pivot-scroll-wrapper::-webkit-scrollbar-thumb {
    background: var(--border); /* Discret par défaut */
    border-radius: 10px;
}
.pivot-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--primary); /* S'illumine au survol */
}

/* Survol des lignes */
.pivot-table tbody tr:hover td {
    background-color: rgba(var(--primary-rgb), 0.05) !important;
}