/*
 * Styles propres à Equifin, chargés après le thème (assets/css/style.css).
 * Ne pas modifier style.css (fichier du thème) : surcharger ici.
 */

/* ------------------------------------------------------------------ Typographie plus compacte
   Le thème dimensionne tout par variables : on les réduit (~12 %) plutôt que de toucher chaque vue. */
:root {
    --h1: clamp(1.6rem, 1.1rem + 2.4vw, 2.6rem);
    --h2: clamp(1.45rem, 1.05rem + 2vw, 2.2rem);
    --h3: clamp(1.3rem, 1rem + 1.5vw, 1.9rem);
    --h4: clamp(1.15rem, 0.98rem + 0.9vw, 1.55rem);
    --h5: clamp(1.05rem, 0.95rem + 0.5vw, 1.3rem);
    --h6: clamp(0.95rem, 0.9rem + 0.25vw, 1.08rem);
    --font-2xxl: 1.75rem;
    --font-2xl: 1.5rem;
    --font-xxl: 1.3rem;
    --font-xl: 1.12rem;
    --font-lg: 1rem;
    --font-md: 0.9rem;
    --font-sm: 0.8125rem;
    --font-xs: 0.6875rem;
    --font-xxs: 0.6rem;
}
body { font-size: 0.875rem; }
.fs-5 { font-size: 1.1rem !important; }
.fs-6 { font-size: 0.95rem !important; }
.text-lg { font-size: 1rem !important; }
.form-label, label { font-size: 0.8125rem; }
.form-control, .form-select { font-size: 0.875rem; }
.btn { font-size: 0.85rem; }
.badge { font-size: 0.72rem; font-weight: 600; }
.sidebar-menu li a, .sidebar-menu-group-title { font-size: 0.85rem; }
.card-body { padding: 1rem 1.15rem; }

/* ------------------------------------------------------------------ Tableaux responsives
   Tous les tableaux : défilement horizontal ET vertical sur petits écrans, en-tête figé. */
.table { font-size: 0.8375rem; }
.table > :not(caption) > * > * { padding: 0.5rem 0.6rem; }
.table thead th { font-weight: 600; white-space: nowrap; font-size: 0.8rem; }
.table-responsive, .tableau-defilant {
    max-height: 70vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.table-responsive > .table > thead th, .tableau-defilant > .table > thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: var(--white);
}

/* ------------------------------------------------------------------ En-tête : recherche globale */
.recherche-entete {
    gap: 0.4rem;
    background: var(--neutral-50, #f5f6fa);
    border: 1px solid var(--neutral-200, #e4e5ea);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    width: 260px;
}
.recherche-entete input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 0.85rem; color: inherit; }
[data-theme="dark"] .recherche-entete { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.12); }

/* ------------------------------------------------------------------ Liste des projets */
.carte-projet { transition: box-shadow .15s, transform .15s; }
.carte-projet:hover { box-shadow: 0 6px 18px rgba(16, 24, 40, .08); transform: translateY(-2px); }
.carte-projet .piste { background: var(--neutral-200, #e9e8e3); border-radius: 4px; height: 6px; overflow: hidden; }
.carte-projet .piste > span { display: block; height: 100%; border-radius: 4px; }
[data-theme="dark"] .carte-projet .piste { background: #3a465b; }

/* ------------------------------------------------------------------ Petits écrans */
@media (max-width: 575.98px) {
    .card-body { padding: 0.85rem; }
    .dashboard-main-body { padding: 0.75rem !important; }
    .navbar-header .gap-3 { gap: 0.5rem !important; }
    .btn { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    h5, .h5 { font-size: 1.05rem; }
    /* En-tête : le raccourci calendrier est masqué (calendrier dans le menu) */
    .navbar-header a[title="Calendrier des échéances"] { display: none !important; }
    .navbar-header .w-40-px { width: 34px !important; height: 34px !important; }
    .navbar-header .d-flex.flex-wrap { flex-wrap: nowrap !important; }
    .navbar-header { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    .navbar-header > .row { flex-wrap: nowrap; margin-left: 0; margin-right: 0; }
    .navbar-header > .row > .col-auto { padding-left: 0; padding-right: 0; }
    .navbar-header .gap-4 { gap: 0.5rem !important; }
}

/* ================================================================== Couleur d'accent : rouge uni (aucun orange, aucun dégradé)
   Le bleu reste la couleur de la marque (menu, liens) ; rouge uni (jamais de dégradé) pour les actions,
   la pagination, les barres de progression, les icônes de titre et le survol des tableaux.
   Les nuances orange du thème (« warning ») sont aussi remplacées par du rouge. */
:root {
    --eq-rouge: #e5383b;
    --eq-rouge-fonce: #b91c1c;
    --eq-rouge-pale: rgba(229, 56, 59, 0.1);
    /* Thème : les couleurs « warning » (orange) deviennent rouges */
    --warning-600: #e5383b;
    --warning-700: #b91c1c;
    --warning-800: #991b1b;
    --warning-900: #7f1d1d;
    --warning-main: #e5383b;
    --warning-focus: rgba(229, 56, 59, 0.12);
}

/* ---- Textes */
.text-eq-rouge { color: var(--eq-rouge) !important; }
/* Icône du titre de chaque page */
.fs-5.fw-bold > iconify-icon:first-child,
.dashboard-main-body > .d-flex .fs-5 > iconify-icon:first-child { color: var(--eq-rouge) !important; }
/* Titres des groupes du menu : même bleu que l'élément actif du menu (var(--brand)) */
.sidebar-menu-group-title { color: var(--brand) !important; font-weight: 600; letter-spacing: .02em; }
/* Titres des cartes (h6) : petite barre d'accent */
.card-body > h6:first-child, .card-header h6 { position: relative; }
.card-body > h6:first-child > iconify-icon:first-child, .card-header h6 > iconify-icon:first-child { color: var(--eq-rouge); }

/* ---- Boutons */
.btn-eq-accent, a.btn-eq-accent {
    background: var(--eq-rouge) !important;
    color: #fff !important;
    border: 0 !important;
    box-shadow: 0 4px 12px rgba(229, 56, 59, 0.25);
}
.btn-eq-accent:hover, .btn-eq-accent:focus { background: var(--eq-rouge-fonce) !important; box-shadow: 0 6px 16px rgba(229, 56, 59, 0.35); color: #fff !important; }
.btn-eq-accent iconify-icon { color: #fff; }
/* Bouton « modifier » : icône seule, ronde, rouge */
.btn-eq-icone {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 0 !important; border-radius: 50%;
    background: var(--eq-rouge-pale); color: var(--eq-rouge) !important; border: 1px solid transparent;
    font-size: 1.05rem; transition: background .15s, color .15s;
}
.btn-eq-icone:hover { background: var(--eq-rouge); color: #fff !important; }
.btn-eq-icone.eq-danger { background: var(--eq-rouge-pale); color: var(--eq-rouge) !important; }
.btn-eq-icone.eq-danger:hover { background: var(--eq-rouge); color: #fff !important; }
/* Liens-icônes « Modifier » déjà présents dans les tableaux */
td a[title="Modifier"] { color: var(--eq-rouge) !important; }
td a[title="Modifier"]:hover { color: var(--eq-rouge-fonce) !important; }

/* ---- Barres de progression */
.progress-bar { background: var(--eq-rouge); }
.carte-projet .piste > span.bg-primary-600 { background: var(--eq-rouge) !important; }
.tb-projet .tb-piste > span { background: var(--eq-rouge); }
.tb-projet .tb-niveau-presque > span { background: var(--eq-rouge-fonce); }
.tb-projet .tb-niveau-depassee > span { background: #7f1d1d; }

/* ---- En-têtes de tableaux */
.table thead th { border-bottom: 2px solid rgba(229, 56, 59, 0.45) !important; }

/* ================================================================== DataTables (pagination, recherche, export Excel) */
.eq-datatable { font-size: 0.8125rem; }
.eq-datatable .dt-layout-row { margin: 0.5rem 0 !important; padding: 0 0.6rem; gap: 0.5rem; }
.eq-datatable .dt-layout-row.dt-layout-table { padding: 0; }
.eq-datatable .dt-search input {
    border: 1px solid var(--neutral-200, #e4e5ea) !important; border-radius: 999px !important;
    padding: 0.3rem 0.9rem !important; min-width: 220px; background: transparent; color: inherit; margin-left: 0 !important;
}
.eq-datatable .dt-search input:focus { outline: 0; border-color: var(--eq-rouge) !important; box-shadow: 0 0 0 3px var(--eq-rouge-pale); }
.eq-datatable .dt-length select { border-radius: 8px; padding: 0.15rem 0.4rem; border: 1px solid var(--neutral-200, #e4e5ea); background: transparent; color: inherit; margin-right: .3rem; }
.eq-datatable .dt-info { color: var(--text-secondary-light, #6b7280); }
.eq-datatable .dt-layout-start { gap: 1rem; flex-wrap: wrap; }
/* Bouton Excel */
.eq-datatable .dt-buttons .dt-button.btn-eq-excel, div.dt-buttons > .dt-button.btn-eq-excel {
    background: #1d7a46 !important; color: #fff !important; border: 0 !important; border-radius: 999px !important;
    padding: 0.3rem 0.9rem !important; font-size: 0.8rem; font-weight: 600; margin: 0 !important;
    box-shadow: 0 3px 8px rgba(29, 122, 70, 0.25);
}
.eq-datatable .dt-buttons .dt-button.btn-eq-excel:hover { background: #166536 !important; }
/* Pagination */
.eq-datatable .dt-paging .dt-paging-button {
    border-radius: 8px !important; border: 1px solid transparent !important; min-width: 32px; padding: 0.2rem 0.55rem !important;
    color: inherit !important; background: transparent !important; margin-left: 2px;
}
.eq-datatable .dt-paging .dt-paging-button:hover:not(.disabled) { background: var(--eq-rouge-pale) !important; color: var(--eq-rouge) !important; border-color: transparent !important; }
.eq-datatable .dt-paging .dt-paging-button.current, .eq-datatable .dt-paging .dt-paging-button.current:hover {
    background: var(--eq-rouge) !important; color: #fff !important; border: 0 !important; box-shadow: 0 3px 8px rgba(229, 56, 59, 0.3);
}
.eq-datatable .dt-paging .dt-paging-button.disabled { opacity: .4; }
/* Le style DataTables par défaut ne doit pas écraser celui du thème */
.eq-datatable table.dataTable { margin: 0 !important; width: 100% !important; }
.eq-datatable table.dataTable > thead > tr > th, .eq-datatable table.dataTable > thead > tr > td { padding: 0.5rem 0.6rem; }
.eq-datatable table.dataTable th.dt-type-numeric, .eq-datatable table.dataTable td.dt-type-numeric { text-align: inherit; }
.eq-datatable table.dataTable.table-hover > tbody > tr:hover > * { box-shadow: inset 0 0 0 9999px rgba(229, 56, 59, 0.05); }
.eq-datatable .dt-empty { color: var(--text-secondary-light, #6b7280); padding: 1.5rem !important; }
[data-theme="dark"] .eq-datatable .dt-search input, [data-theme="dark"] .eq-datatable .dt-length select { border-color: rgba(255, 255, 255, 0.15) !important; }
[data-theme="dark"] .eq-datatable .dt-length select option { background: #273142; }
@media (max-width: 575.98px) {
    .eq-datatable .dt-layout-row { flex-direction: column; align-items: stretch !important; }
    .eq-datatable .dt-search input { min-width: 0; width: 100%; }
}

/* Icône + texte sur une seule ligne dans les boutons */
a.btn:has(> iconify-icon), button.btn:has(> iconify-icon), .dt-button { display: inline-flex !important; align-items: center; justify-content: center; gap: .35rem; }
a.btn > iconify-icon, button.btn > iconify-icon, .dt-button iconify-icon { font-size: 1.05em; }
/* Page courante de la pagination : priorité sur le thème (div.dt-container …) */
div.dt-container.eq-datatable .dt-paging .dt-paging-button.current,
div.dt-container.eq-datatable .dt-paging .dt-paging-button.current:hover {
    background: var(--eq-rouge) !important; color: #fff !important; border: 0 !important;
}
div.dt-container.eq-datatable .dt-paging .dt-paging-button:hover:not(.current):not(.disabled) {
    background: var(--eq-rouge-pale) !important; color: var(--eq-rouge) !important;
}
.dt-button > span { display: inline-flex; align-items: center; gap: .35rem; }

/* ================================================================== Pagination serveur (pagination/equifin.blade.php) */
.eq-pagination { font-size: 0.8125rem; }
.eq-pagination-lignes { border-radius: 8px; padding: 0.15rem 0.4rem; border: 1px solid var(--neutral-200, #e4e5ea); background: transparent; color: inherit; }
.eq-pagination-liens { display: flex; flex-wrap: wrap; gap: 2px; list-style: none; margin: 0; padding: 0; }
.eq-pagination-liens li > a, .eq-pagination-liens li > span {
    display: inline-flex; align-items: center; justify-content: center; min-width: 32px; padding: 0.2rem 0.55rem;
    border-radius: 8px; color: inherit; text-decoration: none;
}
.eq-pagination-liens li > a:hover { background: var(--eq-rouge-pale); color: var(--eq-rouge); }
.eq-pagination-liens li.courant > span { background: var(--eq-rouge); color: #fff; box-shadow: 0 3px 8px rgba(229, 56, 59, 0.3); }
.eq-pagination-liens li.desactive > span { opacity: .4; }
[data-theme="dark"] .eq-pagination-lignes { border-color: rgba(255, 255, 255, 0.15); }
[data-theme="dark"] .eq-pagination-lignes option { background: #273142; }

/* ------------------------------------------------------------------ Lignes budgétaires : principales et sous-lignes */
tr.eq-ligne-principale > td { font-weight: 600; background-color: rgba(72, 127, 255, 0.08); }
td.eq-sous-ligne { padding-left: 2rem !important; }
td.eq-sous-ligne::before { content: "\21B3"; margin-right: .35rem; color: var(--text-secondary-light, #8a94a6); }

/* ------------------------------------------------------------------ Fiche d'une opération */
.eq-fiche-bandeau { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem;
    padding: 1.1rem 1.25rem; background: rgba(72, 127, 255, 0.06); border-bottom: 1px solid rgba(72, 127, 255, 0.15);
    border-top-left-radius: inherit; border-top-right-radius: inherit; }
.eq-fiche-montant { font-size: 1.6rem; font-weight: 700; color: var(--brand); line-height: 1.2; }
.eq-fiche-montant small { font-size: 0.85rem; font-weight: 600; color: #6b7280; }
.eq-pastille { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .75rem; border-radius: 999px; font-size: 0.8rem; font-weight: 500;
    background: #fff; color: var(--brand); border: 1px solid rgba(72, 127, 255, 0.25); }
.eq-pastille-neutre { color: #6b7280; border-color: #d1d5db; }
.eq-fiche-infos { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; }
.eq-fiche-info, .eq-fiche-note { padding: .7rem .85rem; border: 1px solid #e5e7eb; border-radius: 10px; }
.eq-fiche-libelle { display: flex; align-items: center; gap: .35rem; font-size: 0.75rem; color: #6b7280; text-transform: uppercase; letter-spacing: .02em; }
.eq-fiche-valeur { display: block; margin-top: .2rem; font-size: 0.875rem; font-weight: 600; word-break: break-word; }
.eq-table-imputation thead th { font-size: 0.75rem; text-transform: uppercase; color: #6b7280; background: rgba(72, 127, 255, 0.06); }
.eq-table-imputation tfoot th { border-top: 2px solid rgba(72, 127, 255, 0.25); }
.eq-fiche-commentaires .card-header { cursor: pointer; }
.eq-fiche-commentaires .eq-chevron { transition: transform .2s; }
.eq-fiche-commentaires .card-header:not(.collapsed) .eq-chevron { transform: rotate(180deg); }
