/* ================================================
   PYRITE — peau « l'or dans la roche » (charte du 16/09/2026, direction A choisie par Agathe)
   Chargée APRÈS app.css quand la peau active est 'pyrite' (current_skin()).
   Elle ne fait que redéfinir des tokens et retoucher quelques composants :
   la structure, la logique et les classes restent celles de app.css.
   Polices auto-hébergées (assets/fonts/), aucune dépendance externe.
   ================================================ */

@font-face {
    font-family: "Outfit";
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url("fonts/outfit-variable.woff2") format("woff2");
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url("fonts/manrope-variable.woff2") format("woff2");
}

/* ------------------------------------------------
   Tokens
   ------------------------------------------------ */
:root {
    /* Roche : anthracite neutre à peine chaud, jamais de noir pur, jamais sépia (retour d'Agathe du 16/09) */
    --bg-primary: #101010;
    --bg-secondary: #171716;
    --bg-elevated: #1f1f1d;
    --bg-hover: #282826;
    --bg: #171716;
    --bg-light: #1f1f1d;

    --border: #2a2a27;
    --border-light: #38382f;

    --text-primary: #f8f5ec;
    --text-secondary: #a9a697;
    --text-tertiary: #6f6d62;
    --text: #f8f5ec;
    --text-muted: #a9a697;

    /* GRILLE DE COULEURS (Agathe, 16/09/2026) : or = l'argent qui va au pot commun · bleu = Vladimir ·
       rose = Agathe · lavande = entre vous deux (avances, règlements, solde) · ardoise = neutre ·
       vert / orange / rouge = états seulement. L'interface elle-même (boutons, onglet actif, focus) est en IVOIRE
       pour que l'or reste un signal. */
    --accent: #f4efe3;
    --accent-hover: #ffffff;
    --accent-dim: rgba(244, 239, 227, 0.12);
    --accent-faint: rgba(244, 239, 227, 0.06);
    --accent-glow: rgba(244, 239, 227, 0.25);

    /* Entre vous deux : bleu + rose = lavande */
    --between: #b39cf0;
    --between-bg: rgba(179, 156, 240, 0.14);
    --between-line: rgba(179, 156, 240, 0.5);
    --between-ink: #17122b;

    /* États : vifs, réservés aux états (validé, brouillon, couverture) */
    --success: #6fe39a;
    --success-bg: rgba(111, 227, 154, 0.14);
    --success-line: rgba(111, 227, 154, 0.4);
    --warning: #ffb02e;
    --warning-bg: rgba(255, 176, 46, 0.14);
    --warning-line: rgba(255, 176, 46, 0.4);
    --danger: #ff6b5c;
    --danger-bg: rgba(255, 107, 92, 0.14);
    --danger-line: rgba(255, 107, 92, 0.4);

    /* Personnes et pot commun (HEX obligatoires : lus par cssVar() dans les graphiques) */
    --user1: #5eb1ff;
    --user1-bg: rgba(94, 177, 255, 0.14);
    --user2: #ff7eb6;   /* rose : la couleur d'Agathe, à elle seule ; le corail/rouge reste aux alertes */
    --user2-bg: rgba(255, 126, 182, 0.14);
    --pot: #ffc53d;
    --pot-bg: rgba(255, 197, 61, 0.14);
    --pot-line: rgba(255, 197, 61, 0.5);
    --etendu: #b8b4a3;
    --virements: #f0d48a;        /* or clair : renflouements, ça va au pot */
    --remboursements: #b39cf0;   /* lavande : avances entre vous deux */
    --maison: #4fd1c5;           /* turquoise : la maison, un pot à part (24/10/2026, choix d'Atlas, à valider par Agathe ;
                                    autres candidates terre cuite #e8875b, cuivre #d4936b) */
    --maison-bg: rgba(79, 209, 197, 0.14);
    --maison-line: rgba(79, 209, 197, 0.5);

    /* Graphiques */
    --chart-grid: rgba(248, 245, 236, 0.07);
    --chart-tick: rgba(248, 245, 236, 0.5);
    --chart-point-border: #101010;
    --chart-font: "Manrope", system-ui, sans-serif;

    /* Paliers : seul le virement (palier 1) porte la couleur de la personne, le reste est neutre */
    --palier-1: var(--text-secondary);
    --palier-1-bg: var(--bg-elevated);
    --palier-1-line: var(--border-light);
    --palier-2: var(--border-light);
    --palier-2-bg: var(--bg-elevated);
    --palier-3: var(--border-light);
    --palier-3-bg: var(--bg-elevated);
    --palier-4: var(--border-light);
    --palier-4-bg: var(--bg-elevated);

    --btn-primary-ink: #171512;

    /* Typographie : Outfit (géométrique, moderne) pour la marque, les titres et les montants ; Manrope pour le texte */
    --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-display: "Outfit", "Manrope", system-ui, sans-serif;
    --font-num: "Outfit", "Manrope", system-ui, sans-serif;

    /* Formes : angles nets, filets fins */
    --radius: 4px;
    --radius-sm: 3px;
    --radius-lg: 6px;
}

body {
    font-family: var(--font-sans);
    font-variant-numeric: tabular-nums;
}

::selection {
    background: var(--accent);
    color: var(--btn-primary-ink);
}

/* ------------------------------------------------
   Ordre des blocs du dashboard (Agathe, 16/09/2026) :
   ce qu'on touche tous les jours en haut, ce qu'on consulte en bas.
   1 chiffres clés · 2 Données du mois (salaires, charges, remboursements, virements)
   · 3 Guide de répartition (mois validé) · 4 Répartition calculée · 5 graphique · 6 Santé
   Le HTML de manage.php ne bouge pas : la peau classique garde l'ordre historique.
   ------------------------------------------------ */
.container {
    display: flex;
    flex-direction: column;
}

.container > #alerts-container { order: 0; }
.container > .stats-grid      { order: 1; }
.container > #block-donnees   { order: 2; }
.container > .card-guide      { order: 3; }
.container > #block-repartition { order: 4; }
.container > #block-chart     { order: 5; }
.container > #block-sante     { order: 6; }

/* Chiffres clés : plus compacts, en 2 colonnes sur mobile */
.stats-grid {
    margin-bottom: var(--space-lg);
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-sm);
    }

    .stat-card {
        padding: var(--space-md);
    }

    .stat-value {
        font-size: 22px;
    }

    .stat-change {
        font-size: 11px;
    }

    /* Téléphone : nom et part sur la première ligne, montant en dessous, rien de tronqué */
    .split-row {
        grid-template-columns: 1fr auto;
        grid-template-areas: "name pct" "amount amount";
        gap: 2px 8px;
    }

    .split-row .split-name { grid-area: name; font-size: 10px; }
    .split-row small { grid-area: pct; }
    .split-row b { grid-area: amount; font-size: 17px; }

    .split-rows { gap: 8px; }

    /* Le texte reste au-dessus de la bande de la courbe */
    .stat-card-content { padding-bottom: 14px; }

    .split-bar {
        margin: 10px 0 8px;
    }

    /* La courbe reste sous le texte, jamais au travers */
    .stat-sparkline {
        height: 20%;
        opacity: 0.5;
    }
}

/* ------------------------------------------------
   Navbar et marque
   ------------------------------------------------ */
.navbar {
    background: var(--bg-primary);
}

.navbar-brand {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    gap: 10px;
}

.navbar-brand i {
    color: var(--pot);
    font-size: 15px;
}

/* Emblème : photo d'une vraie pyrite (deux cubes), assets/img/pyrite-emblem-*.png */
.navbar-emblem {
    height: 26px;
    width: 26px;
    object-fit: contain;
    filter: drop-shadow(0 0 6px rgba(255, 197, 61, 0.45));
}

.badge {
    border-radius: var(--radius-sm);
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.navbar-left {
    flex-wrap: wrap;
    row-gap: var(--space-sm);
}

/* Mobile : le menu ⋮ reste en haut à droite, seuls les badges passent à la ligne */
.navbar-content {
    flex-wrap: nowrap;
    align-items: flex-start;
}

.navbar-right {
    margin-left: auto;
    flex-shrink: 0;
}

/* ------------------------------------------------
   Boutons, formulaires, onglets, menus
   ------------------------------------------------ */
.btn {
    border-radius: var(--radius);
}

.btn-success {
    color: var(--btn-primary-ink);
}

.dropdown-menu {
    border-radius: var(--radius-lg);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.form-control,
.form-select,
.input-group-suffix {
    border-radius: var(--radius);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ------------------------------------------------
   Cartes et montants
   ------------------------------------------------ */
.card,
.stat-card,
.timeline-container,
.chart-card-small {
    border-radius: var(--radius-lg);
}

.chart-card {
    border-radius: 8px;
    background: var(--bg-secondary);
}

.modal-content {
    border-radius: 8px;
}

.card-header h3 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.01em;
}

.card-header h3 i {
    font-size: 13px;
}

.stat-label {
    font-weight: 600;
    letter-spacing: 0.08em;
    font-size: 11px;
}

.stat-value {
    font-weight: 500;
    font-size: 32px;
    letter-spacing: -0.02em;
}

/* Sparkline confinée au tiers bas de la carte : elle ne traverse plus le montant */
.stat-sparkline {
    top: auto;
    height: 36%;
    opacity: 0.7;
}

/* Carte du compte commun : la seule qui porte l'or */
.stat-card-pot {
    border-color: var(--pot-line);
    background: linear-gradient(160deg, var(--accent-faint) 0%, var(--bg-secondary) 60%);
}

.stat-card-pot .stat-label {
    color: var(--pot);
}

/* Carte « Répartition » : barre bleu/rose */
.split-bar {
    display: flex;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    margin: 14px 0 10px;
    background: var(--border);
}

.split-bar i {
    display: block;
    height: 100%;
    transition: width 400ms ease;
}

.split-bar .split-user1 { background: var(--user1); }
.split-bar .split-user2 { background: var(--user2); }

/* Une ligne par personne : nom · montant · part, alignés (retour d'Agathe sur téléphone, 16/09) */
.split-rows {
    display: grid;
    gap: 6px;
}

.split-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: baseline;
    gap: 10px;
}

.split-row .split-name {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.split-row b {
    font-family: var(--font-num);
    font-size: 18px;
    font-weight: 500;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.split-row small {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.8;
    min-width: 34px;
    text-align: right;
}

/* Carte « Entre vous » : lavande */
.stat-card-between {
    border-color: var(--between-line);
    background: linear-gradient(160deg, var(--between-bg) 0%, var(--bg-secondary) 60%);
}

.stat-card-between .stat-label,
.stat-card-between .stat-value {
    color: var(--between);
}

.stat-card-between .between-quiet {
    font-size: 24px;
    color: var(--text-primary);
}

/* Le lavande reste sur les DONNÉES « entre vous » (solde, série, règlements) ; les boutons sont de l'interface,
   donc ivoire comme le reste, pour que l'or reste la couleur dominante (Agathe, 16/09/2026, 1A) */
.btn[onclick*="openAddReglementModal"] {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.solde-result.pending {
    background: var(--between-bg);
    border-color: var(--between);
}

.solde-result.pending .solde-result-flow {
    color: var(--between);
}

.timeline-reglement .timeline-bubble {
    background: var(--between-bg);
    border-color: var(--between);
    color: var(--between);
}

.timeline-reglement .timeline-bubble-header,
.timeline-reglement .timeline-bubble-amount {
    color: var(--between);
}

.solde-detail-value[style*="--success"] {
    color: var(--between) !important;
}

/* Santé : la recommandation se lit en texte normal sur fond neutre, seul le libellé et le filet portent l'état
   (Agathe, 16/09/2026 : « l'écrit en jaune est visuellement imbitable ») */
#health-check-display .health-reco {
    background: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
    border-left: 3px solid var(--text-secondary);
    line-height: 1.55;
}

#health-check-display .health-reco strong {
    color: var(--text-primary);
}

/* Une phrase par ligne, aérée, jamais un pavé */
#health-check-display .health-reco-head {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

#health-check-display .health-reco-body {
    display: grid;
    gap: 6px;
    max-width: 62ch;
}

#health-check-display .health-reco-line {
    position: relative;
    padding-left: 14px;
    font-size: 13.5px;
}

#health-check-display .health-reco-line::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.62em;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-tertiary);
}

/* Téléphone : la table de Santé garde Mois · Total effectif · Couverture, le détail reste sur grand écran */
@media (max-width: 640px) {
    #health-check-display table {
        font-size: 12px;
    }

    #health-check-display th:nth-child(2),
    #health-check-display td:nth-child(2),
    #health-check-display th:nth-child(3),
    #health-check-display td:nth-child(3),
    #health-check-display th:nth-child(4),
    #health-check-display td:nth-child(4) {
        display: none;
    }

    #health-check-display .couv-bar {
        width: 56px;
    }

    /* Les 3 indicateurs tiennent sur une ligne compacte au lieu de trois écrans */
    #health-check-display .grid-3 {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 6px;
        align-items: start;
    }

    #health-check-display .grid-3 > div {
        padding: 0;
    }

    #health-check-display .grid-3 .stat-label {
        font-size: 9px;
        letter-spacing: 0.04em;
        margin-bottom: 4px;
    }

    #health-check-display .grid-3 .stat-value {
        font-size: 17px;
        margin-bottom: 2px;
    }

    #health-check-display .grid-3 small {
        font-size: 10px;
        line-height: 1.25;
        display: block;
    }
}

#health-check-display .health-reco-increase { border-left-color: var(--warning); }
#health-check-display .health-reco-increase .fas,
#health-check-display .health-reco-increase .health-reco-label { color: var(--warning); }
#health-check-display .health-reco-ok { border-left-color: var(--success); }
#health-check-display .health-reco-ok .fas,
#health-check-display .health-reco-ok .health-reco-label { color: var(--success); }
#health-check-display .health-reco-decrease { border-left-color: var(--between); }
#health-check-display .health-reco-decrease .fas,
#health-check-display .health-reco-decrease .health-reco-label { color: var(--between); }

/* Le badge « Barème » n'est pas une alerte : neutre */
.badge-warning:has(.fa-percent) {
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

/* Valider le mois = un état : vert. Icônes de titres : neutres */
.card-header h3 i {
    color: var(--text-secondary);
}

/* Budget étendu : neutre, ce n'est pas un second accent */
.stat-card-accent {
    border-color: var(--border-light) !important;
    background: var(--bg-secondary);
}

.stat-card-accent .stat-value.text-accent {
    color: var(--text-primary);
}

.chart-value {
    font-weight: 500;
    font-size: 36px;
    letter-spacing: -0.02em;
}

.chart-value-label {
    letter-spacing: 0.08em;
    font-size: 11px;
    font-weight: 600;
}

.chart-tooltip {
    border-radius: var(--radius-lg);
}

.chart-tooltip .tooltip-amount,
.chart-tooltip .tooltip-total-amount,
.legend-value,
.solde-detail-value,
.chart-card-small-value {
    font-size: 15px;
    font-weight: 500;
}

.chart-tooltip .tooltip-total-amount {
    font-size: 17px;
}

.legend-dot {
    box-shadow: none;
}

.legend-dot::after {
    display: none;
}

.period-selector,
.chart-toggle {
    border-radius: var(--radius-lg);
}

.period-btn,
.chart-toggle-btn {
    border-radius: var(--radius);
}

.period-btn.active {
    color: var(--btn-primary-ink);
    box-shadow: none;
}

.chart-toggle-btn.active {
    background: var(--bg-primary);
    box-shadow: inset 0 0 0 1px var(--border-light);
}

/* Montants secondaires (solde, timeline, paliers) */
.solde-user-amount,
.solde-result-flow .amount,
.timeline-bubble-amount,
.palier-amount {
    font-weight: 500;
    letter-spacing: -0.02em;
}

.solde-user-amount,
.solde-result-flow .amount {
    font-size: 26px;
}

.timeline-bubble-amount {
    font-size: 22px;
}

.palier-amount {
    font-size: 19px;
}

.palier-4 .palier-amount {
    font-size: 22px;
}

/* ------------------------------------------------
   Guide de répartition et simulateur : une couleur par personne
   ------------------------------------------------ */
.card-guide {
    border-color: var(--border-light);
}

.card-guide .card-header {
    background: var(--bg-secondary);
}

.card-guide .card-header h3 {
    color: var(--text-primary);
}

.palier {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 3px solid var(--palier-color);
}

.guide-user.user1 h4 { color: var(--user1); }
.guide-user.user2 h4 { color: var(--user2); }

.guide-user.user1 .palier-1 { --palier-color: var(--user1); --palier-bg: var(--user1-bg); border-color: var(--user1); border-left-width: 3px; }
.guide-user.user2 .palier-1 { --palier-color: var(--user2); --palier-bg: var(--user2-bg); border-color: var(--user2); border-left-width: 3px; }

.palier-2 .palier-amount,
.palier-3 .palier-amount,
.palier-4 .palier-amount {
    color: var(--text-primary);
}

.palier-decomp {
    border-top-color: var(--border-light);
}

/* Pictos des paliers : cœur or comme le pot commun (pas rouge, ce n'est pas une alerte), les autres discrets */
.palier-icon {
    color: var(--text-secondary);
}

.palier-icon.palier-heart {
    color: var(--pot);
}

/* Répartition calculée : les montants intermédiaires redeviennent neutres,
   seuls le virement et le reste à vivre portent la couleur de la personne */
.rep-user strong.text-warning,
.rep-user strong.text-success {
    color: var(--text-primary);
}

.rep-user h5 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
}

.rep-user.user1 h5,
.rep-user.user1 strong.rep-reste { color: var(--user1); }
.rep-user.user2 h5,
.rep-user.user2 strong.rep-reste { color: var(--user2); }

.rep-user strong.rep-reste {
    font-family: var(--font-num);
    font-weight: 500;
    letter-spacing: -0.02em;
    font-size: 20px !important;
}

/* ------------------------------------------------
   Timeline (remboursements) : bulle à la couleur de la personne
   ------------------------------------------------ */
.timeline-bubble {
    border-radius: 10px;
}

.timeline-message.user1 .timeline-bubble {
    background: var(--user1-bg);
    border: 1px solid var(--user1);
    color: var(--text-primary);
    border-bottom-left-radius: 3px;
}

.timeline-message.user1 .timeline-bubble-header {
    color: var(--user1);
    opacity: 1;
}

.timeline-message.user2 .timeline-bubble {
    background: var(--user2-bg);
    border: 1px solid var(--user2);
    color: var(--text-primary);
    border-bottom-right-radius: 3px;
}

.timeline-message.user2 .timeline-bubble-header {
    color: var(--user2);
    opacity: 1;
}

.timeline-message.user1 .timeline-delete,
.timeline-message.user2 .timeline-delete {
    background: var(--danger);
    color: var(--text-primary);
}

.timeline-reglement .timeline-bubble {
    border-radius: var(--radius-lg);
    border-width: 1px;
}

.solde-result {
    border-radius: var(--radius-lg);
}

/* ------------------------------------------------
   Alertes, toasts
   ------------------------------------------------ */
.alert,
.toast {
    border-radius: var(--radius);
}

.alert-info {
    background: var(--accent-dim);
    color: var(--text-primary);
    border-color: var(--border-light);
}

/* ------------------------------------------------
   Page de connexion (login.php, Bootstrap + styles inline) :
   on redéfinit ses tokens --cam-* et on retouche la carte.
   ------------------------------------------------ */
body.login-page {
    --cam-primary: #ffc53d;
    --cam-primary-dark: #e0a824;
    --cam-primary-light: #ffe3a0;
    --cam-secondary: #a9a697;
    --cam-bg-body: #101010;
    --cam-bg-surface: #171716;
    --cam-bg-card: #1f1f1d;
    --cam-border-color: #2a2a27;
    --cam-text-primary: #f8f5ec;
    --cam-text-secondary: #a9a697;
    --gradient-primary: linear-gradient(135deg, #ffd35c 0%, #e0a824 100%);
    --gradient-dark: #101010;
    font-family: var(--font-sans);
    color: var(--cam-text-primary);
}

body.login-page::before {
    background: radial-gradient(circle at 50% 35%, rgba(255, 197, 61, 0.12) 0%, transparent 45%),
                radial-gradient(circle at 80% 85%, rgba(94, 177, 255, 0.05) 0%, transparent 50%);
}

body.login-page .login-card {
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

/* Emblème : la vraie pierre, en photo détourée, posée sur un halo doré */
body.login-page .login-emblem {
    display: block;
    width: 180px;
    height: 150px;
    margin: 0 auto 1.25rem;
    object-fit: contain;
    filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 28px rgba(255, 197, 61, 0.3));
    transition: transform 0.4s ease;
}

body.login-page .login-emblem:hover {
    transform: translateY(-3px) scale(1.03);
}

body.login-page .login-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.9rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    margin-bottom: 0.35rem;
}

body.login-page .login-subtitle {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    color: var(--cam-text-secondary);
}

body.login-page .form-control {
    border-radius: var(--radius);
}

body.login-page .form-control:focus {
    box-shadow: 0 0 0 3px rgba(255, 197, 61, 0.18);
}

body.login-page .btn-login {
    border-radius: var(--radius);
    color: #171100;
    font-weight: 700;
}

body.login-page .btn-login:hover {
    box-shadow: 0 10px 30px rgba(255, 197, 61, 0.3);
}

body.login-page .spinner {
    border-color: rgba(23, 17, 0, 0.3);
    border-top-color: #171100;
}

body.login-page .alert-danger {
    background: var(--danger-bg);
    color: #e8b3a8;
    border-left-color: var(--danger);
}

body.login-page .footer-text {
    font-family: var(--font-display);
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.7rem;
}
