﻿/* === BP Common Theme - Shared CSS Custom Properties and Base Classes === */

:root {
    /* --- Primary palette --- */
    --bp-header-bg: #f7f8fa;
    --bp-border: #e5e7eb;
    --bp-border-light: #f0f1f3;
    --bp-text: #1f2937;
    --bp-text-secondary: #374151;
    --bp-text-muted: #6b7280;
    --bp-text-disabled: #d1d5db;

    /* --- Row backgrounds --- */
    --bp-row-even: #ffffff;
    --bp-row-odd: #f9fafb;
    --bp-row-hover: #f3f4f6;

    /* --- Category colors --- */
    --bp-cat-int-bg: #eef2ff;
    --bp-cat-int-text: #3730a3;
    --bp-cat-int-border: #c7d2fe;
    --bp-cat-ext-bg: #fef9c3;
    --bp-cat-ext-text: #854d0e;
    --bp-cat-ext-border: #fde68a;

    /* --- Total / accent --- */
    --bp-total-bg: #f0fdf4;
    --bp-total-text: #065f46;
    --bp-total-head-bg: #ecfdf5;
    --bp-danger-bg: #fef2f2;
    --bp-danger-text: #991b1b;
    --bp-danger-border: #fecaca;

    /* --- Positive / Negative --- */
    --bp-positive: #059669;
    --bp-negative: #dc2626;
    --bp-blue-accent: #1e40af;
    --bp-amber-accent: #b45309;

    /* --- Total bar --- */
    --bp-bar-bg: #f7f8fa;
    --bp-bar-border: #e5e7eb;
}

/* Dark mode overrides */
.bp-dark-mode {
    --bp-header-bg: #1f2937;
    --bp-border: #374151;
    --bp-border-light: #374151;
    --bp-text: #f3f4f6;
    --bp-text-secondary: #e5e7eb;
    --bp-text-muted: #9ca3af;
    --bp-text-disabled: #4b5563;
    --bp-row-even: #111827;
    --bp-row-odd: #1a2332;
    --bp-row-hover: #1f2937;
    --bp-cat-int-bg: #1e1b4b;
    --bp-cat-int-text: #a5b4fc;
    --bp-cat-int-border: #312e81;
    --bp-cat-ext-bg: #422006;
    --bp-cat-ext-text: #fcd34d;
    --bp-cat-ext-border: #78350f;
    --bp-total-bg: #064e3b;
    --bp-total-text: #34d399;
    --bp-total-head-bg: #064e3b;
    --bp-danger-bg: #450a0a;
    --bp-danger-text: #fca5a5;
    --bp-danger-border: #7f1d1d;
    --bp-positive: #34d399;
    --bp-negative: #f87171;
    --bp-blue-accent: #93c5fd;
    --bp-amber-accent: #fcd34d;
    --bp-bar-bg: #1f2937;
    --bp-bar-border: #374151;
}

/* Dark mode card background */
.bp-dark-mode .rz-card { background: #111827 !important; border-color: #374151 !important; color: #f3f4f6 !important; }
.bp-dark-mode .rz-text-h5, .bp-dark-mode .rz-text-h6, .bp-dark-mode .rz-text-subtitle1,
.bp-dark-mode .rz-text-subtitle2, .bp-dark-mode .rz-text-body1, .bp-dark-mode .rz-text-body2,
.bp-dark-mode .rz-text-caption, .bp-dark-mode .rz-text-overline { color: #e5e7eb !important; }
.bp-dark-mode .rz-color-secondary { color: #9ca3af !important; }

/* Dark mode toggle button */
.bp-dark-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    color: #374151;
    font-size: 0.8em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
}

.bp-dark-toggle:hover { background: #f3f4f6; }

.bp-dark-mode .bp-dark-toggle {
    background: #374151;
    border-color: #4b5563;
    color: #fbbf24;
}

.bp-dark-mode .bp-dark-toggle:hover { background: #4b5563; }

/* Smooth year card transition */
.bp-year-transition {
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}
.bp-year-transition:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* ======================================================================
   SHARED TABLE STYLES (centralized — do NOT duplicate in .razor.css)
   ====================================================================== */

/* --- Main table --- */
.bp-table {
    font-size: 0.85em;
    table-layout: auto;
    min-width: 1200px;
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    white-space: nowrap;
}

.bp-table thead th {
    padding: 0.5rem 0.6rem;
    vertical-align: middle;
    border-bottom: 2px solid var(--bp-border, #e5e7eb);
    background: var(--bp-header-bg, #f7f8fa) !important;
    font-weight: 600;
    font-size: 0.9em;
    white-space: nowrap;
    color: var(--bp-text-secondary, #374151);
}

.bp-table tbody td {
    padding: 0.4rem 0.6rem;
    vertical-align: middle;
    color: var(--bp-text, #1f2937);
    border-bottom: 1px solid var(--bp-border-light, #f0f1f3);
}

.bp-table tbody tr:nth-child(even) { background: var(--bp-row-even, #ffffff); }
.bp-table tbody tr:nth-child(odd)  { background: var(--bp-row-odd, #f9fafb); }
.bp-table tbody tr:hover { background: var(--bp-row-hover, #f3f4f6) !important; }

/* --- Table container --- */
.bp-table-container {
    position: relative;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--bp-border, #e5e7eb);
}

/* --- Left sticky column --- */
.bp-sticky {
    position: sticky;
    left: 0;
    min-width: var(--bp-sticky-width, 180px);
    width: var(--bp-sticky-width, 180px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-right: 2px solid #999;
    z-index: 10;
    box-shadow: 4px 0 8px rgba(0,0,0,0.12);
}

.bp-sticky-head { z-index: 11; background-color: var(--bp-header-bg, #f7f8fa) !important; }
.bp-sticky-cat  { background-color: var(--bp-cat-int-bg, #eef2ff) !important; }
.bp-sticky-row  { background-color: var(--bp-row-even, #ffffff) !important; }
.bp-sticky-total { background-color: var(--bp-total-head-bg, #ecfdf5) !important; }
.bp-sticky-tva  { background-color: var(--bp-row-odd, #f9fafb) !important; }
tbody tr:nth-child(odd) .bp-sticky-row,
.bp-row-odd .bp-sticky-row { background-color: var(--bp-row-odd, #f9fafb) !important; }
tbody tr:hover .bp-sticky-row,
.bp-row-even:hover .bp-sticky-row,
.bp-row-odd:hover .bp-sticky-row { background-color: var(--bp-row-hover, #f3f4f6) !important; }

/* --- Right sticky column --- */
.bp-sticky-right {
    position: sticky;
    right: 0;
    z-index: 10;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-left: 2px solid #999;
    box-shadow: -4px 0 8px rgba(0,0,0,0.12);
}
.bp-sticky-right-head { z-index: 11; background-color: var(--bp-header-bg, #f7f8fa) !important; }
.bp-sticky-right-cat  { background-color: var(--bp-cat-int-bg, #eff6ff) !important; }
.bp-sticky-right-row  { background-color: var(--bp-row-even, #ffffff) !important; }
.bp-sticky-right-total { background-color: var(--bp-positive, #059669) !important; color: #ffffff !important; }
.bp-sticky-right-tva  { background-color: var(--bp-row-odd, #f9fafb) !important; }
.bp-row-odd .bp-sticky-right-row { background-color: var(--bp-row-odd, #f9fafb) !important; }
.bp-row-even:hover .bp-sticky-right-row,
.bp-row-odd:hover .bp-sticky-right-row { background-color: var(--bp-row-hover, #f3f4f6) !important; }

/* --- Ext category sticky override --- */
.bp-cat-row-ext .bp-sticky-cat { background-color: var(--bp-cat-ext-bg, #fef9c3) !important; }

/* --- Amounts --- */
.bp-montant {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* --- Total column --- */
.bp-total-col {
    font-weight: 600;
    background: var(--bp-total-bg, #f0fdf4) !important;
    color: var(--bp-total-text, #065f46);
}
thead .bp-total-col {
    background: var(--bp-total-head-bg, #ecfdf5) !important;
    color: var(--bp-total-text, #065f46);
    font-weight: 700;
}

/* --- Zero values --- */
.bp-zero { color: var(--bp-text-disabled, #d1d5db) !important; }

/* --- Subtotal column --- */
.bp-subtotal-col { font-weight: 600; background: var(--bp-row-hover, #f3f4f6) !important; }

/* --- Actions column --- */
.bp-actions { text-align: center; white-space: nowrap; }

/* --- Category rows --- */
.bp-cat-row { background: var(--bp-cat-int-bg, #eef2ff) !important; font-weight: 600; color: var(--bp-cat-int-text, #3730a3); }
.bp-cat-row td { border-bottom: 1px solid var(--bp-cat-int-border, #c7d2fe) !important; }
.bp-cat-row-ext { background: var(--bp-cat-ext-bg, #fef9c3) !important; font-weight: 600; color: var(--bp-cat-ext-text, #854d0e); }
.bp-cat-row-ext td { border-bottom: 1px solid var(--bp-cat-ext-border, #fde68a) !important; }

/* --- Section titles --- */
.bp-section-title { font-weight: 700; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.5rem; }
.bp-section-title-int { color: var(--bp-blue-accent, #1e40af); }
.bp-section-title-ext { color: var(--bp-cat-ext-text, #854d0e); }

/* --- Total bar --- */
.bp-total-bar { background: var(--bp-bar-bg, #f7f8fa); border: 1px solid var(--bp-bar-border, #e5e7eb); border-radius: 8px; padding: 1rem 1.5rem; }
.bp-total-value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* --- Sortable headers --- */
.bp-sortable { cursor: pointer; user-select: none; transition: background 0.15s; }
.bp-sortable:hover { background: var(--bp-row-hover, #eef0f4) !important; }

/* --- Comparison table --- */
.bp-comp-table { width: 100%; border-collapse: collapse; font-size: 0.88em; }
.bp-comp-table thead th { padding: 0.6rem 0.75rem; text-align: right; font-weight: 600; color: var(--bp-text-secondary, #374151); background: var(--bp-header-bg, #f7f8fa); border-bottom: 2px solid var(--bp-border, #e5e7eb); }
.bp-comp-table th:first-child { text-align: left; }
.bp-comp-table td { padding: 0.5rem 0.75rem; text-align: right; border-bottom: 1px solid var(--bp-border-light, #f3f4f6); color: var(--bp-text, #1f2937); }
.bp-comp-table td:first-child { text-align: left; font-weight: 500; }
.bp-comp-table tbody tr:hover { background: var(--bp-row-odd, #f9fafb); }
.bp-comp-total-row { font-weight: 700; background: var(--bp-danger-bg, #fef2f2) !important; }
.bp-comp-total-row td { color: var(--bp-danger-text, #991b1b); border-top: 2px solid var(--bp-danger-border, #fecaca); }

/* ======================================================================
   DARK MODE — TABLE OVERRIDES
   ====================================================================== */
.bp-dark-mode .bp-table thead th,
.bp-dark-mode .bp-comp-table thead th { background: var(--bp-header-bg) !important; color: var(--bp-text-secondary); border-bottom-color: var(--bp-border); }
.bp-dark-mode .bp-table tbody td,
.bp-dark-mode .bp-comp-table td { color: var(--bp-text); border-bottom-color: var(--bp-border); }
.bp-dark-mode .bp-table tbody tr:nth-child(even) { background: var(--bp-row-even); }
.bp-dark-mode .bp-table tbody tr:nth-child(odd) { background: var(--bp-row-odd); }
.bp-dark-mode .bp-table tbody tr:hover { background: var(--bp-row-hover) !important; }
.bp-dark-mode .bp-table-container,
.bp-dark-mode .bp-table-wrap { border-color: var(--bp-border); }

/* Dark sticky */
.bp-dark-mode .bp-sticky { border-right-color: var(--bp-border); box-shadow: 4px 0 8px rgba(0,0,0,0.3); }
.bp-dark-mode .bp-sticky-right { border-left-color: var(--bp-border); box-shadow: -4px 0 8px rgba(0,0,0,0.3); }
.bp-dark-mode .bp-sticky-head { background-color: var(--bp-header-bg) !important; }
.bp-dark-mode .bp-sticky-row { background-color: var(--bp-row-even) !important; }
.bp-dark-mode tbody tr:nth-child(odd) .bp-sticky-row,
.bp-dark-mode .bp-row-odd .bp-sticky-row { background-color: var(--bp-row-odd) !important; }
.bp-dark-mode tbody tr:hover .bp-sticky-row,
.bp-dark-mode .bp-row-even:hover .bp-sticky-row,
.bp-dark-mode .bp-row-odd:hover .bp-sticky-row { background-color: var(--bp-row-hover) !important; }
.bp-dark-mode .bp-sticky-cat { background-color: var(--bp-cat-int-bg) !important; }
.bp-dark-mode .bp-cat-row-ext .bp-sticky-cat { background-color: var(--bp-cat-ext-bg) !important; }

/* Dark cat rows */
.bp-dark-mode .bp-cat-row { background: var(--bp-cat-int-bg) !important; color: var(--bp-cat-int-text); }
.bp-dark-mode .bp-cat-row td { border-bottom-color: var(--bp-cat-int-border) !important; }
.bp-dark-mode .bp-cat-row-ext { background: var(--bp-cat-ext-bg) !important; color: var(--bp-cat-ext-text); }
.bp-dark-mode .bp-cat-row-ext td { border-bottom-color: var(--bp-cat-ext-border) !important; }

/* Dark total/amounts */
.bp-dark-mode .bp-total-col { background: var(--bp-total-bg) !important; color: var(--bp-total-text); }
.bp-dark-mode thead .bp-total-col { background: var(--bp-total-bg) !important; color: var(--bp-total-text); }
.bp-dark-mode .bp-total-bar { background: var(--bp-bar-bg); border-color: var(--bp-bar-border); }
.bp-dark-mode .bp-montant { color: var(--bp-text); }
.bp-dark-mode .bp-zero { color: var(--bp-text-disabled) !important; }
.bp-dark-mode .bp-comp-table tbody tr:hover { background: var(--bp-row-hover); }
.bp-dark-mode .bp-comp-total-row { background: var(--bp-danger-bg) !important; }
.bp-dark-mode .bp-comp-total-row td { color: var(--bp-danger-text); border-top-color: var(--bp-danger-border); }
