/* ============================================================
   Tremeac — tremeac.golf-cup.fr
   Suivi des frais professionnels — thème sombre, mobile-first
   ============================================================ */

:root {
    --bg:        #161310;
    --card:      #221D17;
    --card-2:    #2A241C;
    --border:    #3A3229;
    --text:      #F2EAE1;
    --text-dim:  #B8AA9A;
    --primary:   #E2793D;
    --primary-2: #F2A65A;
    --ok:        #4ADE80;
    --warn:      #FBBF24;
    --danger:    #F87171;
    --radius:    16px;
    --radius-sm: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
}

a { color: var(--primary-2); text-decoration: none; }

.wrap {
    max-width: 560px;
    margin: 0 auto;
    padding: 1rem 1rem 0.5rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding-top: env(safe-area-inset-top);
}
.topbar h1 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    padding-top: 0.6rem;
}
.topbar .brand-logo {
    width: 26px; height: 26px;
    border-radius: 7px;
    vertical-align: -6px;
    margin-right: 0.1rem;
}

/* --- Carte générique --- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem;
    margin-bottom: 1rem;
}

/* --- Formulaires --- */
.field { display: block; margin-bottom: 0.9rem; }
.field > span {
    display: block;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 0.35rem;
    font-weight: 500;
}
input[type="text"], input[type="number"], input[type="date"], select, textarea {
    width: 100%;
    background: var(--card-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.8rem;
    font-size: 1rem;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* Sélecteur de bénéficiaire en puces (rapide au pouce) */
.chip-select { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card-2);
    color: var(--text-dim);
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
}
.chip.is-maison { border-style: dashed; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip.selected {
    background: rgba(226, 121, 61, 0.16);
    border-color: var(--primary);
    color: var(--primary-2);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.1rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn-primary { background: var(--primary); color: #1A130A; }
.btn-primary:active { background: var(--primary-2); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-danger { background: transparent; color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.85rem; }

.save-status {
    font-size: 0.82rem;
    text-align: center;
    min-height: 1.4em;
    margin-top: 0.4rem;
    transition: opacity 0.3s, color 0.3s;
    color: var(--text-dim);
}
.save-status[data-state="idle"] { opacity: 0; }
.save-status[data-state="saving"] { opacity: 1; }
.save-status[data-state="saved"] { opacity: 1; color: var(--ok); }
.save-status[data-state="error"] { opacity: 1; color: var(--danger); }

/* --- Photo justificatif --- */
.photo-input { display: flex; align-items: center; gap: 0.7rem; }
.photo-preview {
    width: 56px; height: 56px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border);
    background: var(--card-2);
    flex-shrink: 0;
}
.photo-thumb {
    width: 40px; height: 40px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

/* --- Liste des frais --- */
.frais-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
}
.frais-item:last-child { border-bottom: none; }
.frais-main { flex: 1; min-width: 0; }
.frais-title { font-weight: 600; font-size: 0.96rem; }
.frais-meta { font-size: 0.82rem; color: var(--text-dim); }
.frais-amount { font-weight: 700; white-space: nowrap; }
.frais-actions { display: flex; align-items: center; gap: 0.3rem; }

.toggle-check {
    width: 26px; height: 26px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    color: transparent;
    flex-shrink: 0;
    cursor: pointer;
    padding: 0;
}
.toggle-check.checked { background: var(--ok); border-color: var(--ok); color: #0A2313; }

.empty-state {
    text-align: center;
    color: var(--text-dim);
    padding: 2rem 1rem;
    font-size: 0.92rem;
}

/* --- Récap : résumé + sélecteur de mois --- */
.month-picker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.month-picker .label { font-weight: 700; font-size: 1.05rem; }
.month-picker button {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    width: 40px; height: 40px;
    font-size: 1.1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-bottom: 1rem;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.5rem;
    text-align: center;
}
.stat-card .v { font-size: 1.05rem; font-weight: 700; }
.stat-card .l { font-size: 0.72rem; color: var(--text-dim); margin-top: 0.1rem; }

.section-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-dim);
    font-weight: 600;
    margin: 1.4rem 0 0.5rem;
}

.benef-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}
.benef-row:last-child { border-bottom: none; }

/* --- Paramétrage --- */
.list-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row.inactive { opacity: 0.45; }
.list-row .name { flex: 1; font-weight: 600; }
.list-row .type-tag { font-size: 0.75rem; color: var(--text-dim); }
summary.list-row { list-style: none; }
summary.list-row::-webkit-details-marker { display: none; }

/* ============================================================
   Barre d'onglets (bas d'écran, style app iPhone)
   ============================================================ */
.tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    display: flex;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 0.35rem 0.4rem calc(0.35rem + env(safe-area-inset-bottom));
}
.tabitem {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.4rem 0.2rem;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: 0.72rem;
    font-weight: 600;
}
.tabitem i { font-size: 1.3rem; }
.tabitem.active { color: var(--primary-2); }

@media (min-width: 601px) {
    .tabbar { max-width: 560px; left: 50%; transform: translateX(-50%); border-radius: var(--radius) var(--radius) 0 0; }
}
