/* ============================================================
   components.css — cartes, boutons, champs, tableaux, modale,
   toasts, jauges, puces, segmented control
   ============================================================ */

/* ── Cartes ─────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}
.card-pad-lg { padding: 22px; }
.card-head {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 14px;
}
.card-head h2, .card-head h3 { margin-right: auto; }
.card-title { font-size: .82rem; font-weight: 650; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .05em; }

/* Tuile de statistique */
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .label {
    font-size: .78rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .04em;
}
.stat .value { font-family: var(--font-mono); font-size: 1.7rem; font-weight: 600; letter-spacing: -.03em; }
.stat .sub { font-size: .8rem; color: var(--text-faint); }
.stat.accent { border-left: 3px solid var(--accent); padding-left: 15px; }

/* ── Boutons ────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-weight: 600; font-size: .875rem;
    transition: background .12s, border-color .12s, transform .04s;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger { color: var(--neg); border-color: var(--border-strong); }
.btn.danger:hover { background: var(--neg-soft); border-color: var(--neg); }
.btn.sm { padding: 5px 10px; font-size: .8rem; }
.btn.icon { padding: 8px; }
.btn:disabled { opacity: .5; pointer-events: none; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ── Segmented control (Consolidé / Perso / Pro) ─────────── */
.segmented {
    display: inline-flex; padding: 3px;
    background: var(--surface-3); border-radius: 10px;
    border: 1px solid var(--border);
}
.segmented button {
    padding: 6px 14px; border-radius: 8px;
    font-size: .82rem; font-weight: 600; color: var(--text-muted);
    transition: background .12s, color .12s;
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented button.active[data-scope="perso"] { color: var(--perso); }
.segmented button.active[data-scope="pro"] { color: var(--pro); }

/* ── Champs de formulaire ───────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.field .hint { font-size: .74rem; color: var(--text-faint); }
.input, .select, textarea.input {
    width: 100%;
    padding: 9px 11px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color .12s, background .12s;
}
.input:focus, .select:focus, textarea.input:focus {
    border-color: var(--accent); background: var(--surface); outline: none;
}
.input.mono { font-family: var(--font-mono); }
textarea.input { resize: vertical; min-height: 64px; }
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .affix { position: absolute; right: 11px; color: var(--text-faint); font-family: var(--font-mono); font-size: .85rem; }
.input-affix .input { padding-right: 30px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* ── Puces / badges ─────────────────────────────────────── */
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 9px; border-radius: 999px;
    font-size: .74rem; font-weight: 650;
    background: var(--surface-3); color: var(--text-muted);
}
.chip.perso { background: var(--perso-soft); color: var(--perso); }
.chip.pro { background: var(--pro-soft); color: var(--pro); }
.chip.pos { background: var(--pos-soft); color: var(--pos); }
.chip.neg { background: var(--neg-soft); color: var(--neg); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

/* ── Tableaux ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.data th, table.data td { padding: 10px 14px; text-align: left; white-space: nowrap; }
table.data thead th {
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-faint); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--surface); z-index: 1;
}
table.data tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
table.data tbody tr:last-child { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.amount { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.data td.actions { text-align: right; }
.row-click { cursor: pointer; }

/* ── Jauge de budget ────────────────────────────────────── */
.gauge { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.gauge > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .3s; }
.gauge.ok > span { background: var(--pos); }
.gauge.warning > span { background: var(--warn); }
.gauge.over > span { background: var(--neg); }

/* ── Modale ─────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(10, 14, 20, .5);
    display: grid; place-items: center; padding: 20px;
    animation: fade .12s ease;
}
.modal {
    width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    animation: pop .14s ease;
}
.modal.lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin-right: auto; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 20px; border-top: 1px solid var(--border); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ── Toasts ─────────────────────────────────────────────── */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
    display: flex; align-items: center; gap: 9px;
    padding: 11px 15px; border-radius: var(--radius-sm);
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow-md); font-size: .875rem; font-weight: 550;
    animation: slidein .18s ease; max-width: 360px;
}
.toast.success { border-left: 3px solid var(--pos); }
.toast.error { border-left: 3px solid var(--neg); }
.toast.info { border-left: 3px solid var(--accent); }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } }
@media (max-width: 820px) { .toasts { left: 12px; right: 12px; bottom: 84px; } .toast { max-width: none; } }

/* ── États vides ────────────────────────────────────────── */
.empty {
    text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.empty svg { width: 40px; height: 40px; margin: 0 auto 12px; opacity: .5; }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* ── Divers ─────────────────────────────────────────────── */
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
    background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.divider { height: 1px; background: var(--border); margin: 6px 0; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.tag-color { width: 12px; height: 12px; border-radius: 4px; display: inline-block; vertical-align: middle; }
