/* ── Variables & resets ─────────────────────────────────────────── */
:root {
    --tab-height: 3rem;
    --fab-size: 3.5rem;
    --fab-bottom: calc(var(--tab-height) + 1rem);
    --row-alt-bg: #f5f5f5;
}

[data-theme=dark] {
    --row-alt-bg: #1f2630;
}

body {
    padding-bottom: calc(var(--tab-height) + 1rem);
}

/* ── Navigation onglets (barre basse) ───────────────────────────── */
header nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--tab-height);
    background: var(--pico-background-color);
    border-top: 1px solid var(--pico-muted-border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    padding: 0 1rem;
}

header nav ul {
    display: flex;
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

header nav a {
    font-size: 0.875rem;
    text-decoration: none;
    color: var(--pico-muted-color);
    padding: 0.25rem 0.5rem;
}

header nav a.tab-active {
    color: var(--pico-primary);
    font-weight: 600;
    border-bottom: 2px solid var(--pico-primary);
}

/* ── FAB (bouton flottant) ──────────────────────────────────────── */
.fab {
    position: fixed;
    bottom: var(--fab-bottom);
    right: 1.25rem;
    width: var(--fab-size);
    height: var(--fab-size);
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    cursor: pointer;
    border: none;
    background: var(--pico-primary);
    color: white;
    z-index: 90;
    min-width: 44px;
    min-height: 44px;
}

/* ── Cartes de dépense ──────────────────────────────────────────── */
.expense-card {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: var(--pico-border-radius);
    border: 1px solid var(--pico-muted-border-color);
}

.expense-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.expense-amount {
    font-weight: 600;
    font-size: 1rem;
}

.expense-meta {
    font-size: 0.8rem;
    color: var(--pico-muted-color);
    margin-top: 0.25rem;
}

.expense-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.expense-actions button,
.expense-actions [type="submit"] {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    min-height: 44px;
}

/* ── Tableau de soldes ───────────────────────────────────────────── */
tr.credit td:last-child { color: var(--pico-ins-color, #1a7f3c); font-weight: 600; }
tr.debit  td:last-child { color: var(--pico-del-color, #c0392b); font-weight: 600; }
tr.neutral td:last-child { color: var(--pico-muted-color); }
[data-page="balances"] td:last-child { text-align: right; }

/* ── Suggestions de remboursement ───────────────────────────────── */
.settlement-suggestion {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    flex-wrap: wrap;
}

.settlement-suggestion .small {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    min-height: 44px;
}

.settled {
    color: var(--pico-muted-color);
    text-align: center;
    padding: 1rem;
}

/* ── Feuille modale (bottom sheet) ──────────────────────────────── */
.modal-sheet {
    position: fixed;
    bottom: var(--tab-height);
    left: 0;
    right: 0;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--pico-background-color);
    border-top: 1px solid var(--pico-muted-border-color);
    border-radius: 1rem 1rem 0 0;
    padding: 1.5rem 1rem;
    z-index: 80;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
}

.modal-sheet.hidden {
    display: none;
}

/* ── Accueil — liste des groupes ───────────────────────────────── */
.home-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.home-header h1 {
    margin: 0;
}

.group-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.group-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    text-decoration: none;
    color: var(--pico-color);
    transition: border-color 0.15s, background 0.15s;
}

.group-card:hover {
    border-color: var(--pico-primary);
    background: var(--pico-card-background-color, var(--pico-background-color));
}

.group-card__name {
    font-weight: 600;
    font-size: 1rem;
}

.group-card__meta {
    font-size: 0.8rem;
    color: var(--pico-muted-color);
}

/* ── Lignes membres (formulaire nouveau groupe) ─────────────────── */
#member-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.member-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    background-color: var(--row-alt-bg);
}

.member-row > label:first-child {
    flex: 1;
    margin: 0;
}

.member-row > label:first-child input[type="text"] {
    margin: 0;
}

.member-row label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.8rem;
    color: var(--pico-muted-color);
    margin: 0;
    white-space: nowrap;
}

.member-row label input[type="number"] {
    margin: 0;
}

.member-row [data-remove-member] {
    flex-shrink: 0;
    padding: 0.2rem 0.5rem;
    font-size: 1rem;
    line-height: 1;
    background: none;
    border: 1px solid var(--pico-muted-border-color);
    color: var(--pico-muted-color);
    border-radius: var(--pico-border-radius);
}

.member-row [data-remove-member]:not(:disabled):hover {
    border-color: var(--pico-del-color, #c0392b);
    color: var(--pico-del-color, #c0392b);
}

/* ── Cards membres (page Membres) ───────────────────────────────── */
.member-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.member-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    background-color: var(--pico-card-background-color, #fff);
}

.member-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.member-weight {
    font-size: 0.8rem;
    color: var(--pico-muted-color);
    white-space: nowrap;
}

.member-actions {
    display: flex;
    gap: 0.5rem;
}

.member-actions button,
.member-actions form button {
    flex: 1;
    margin: 0;
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
}

/* ── Partage de lien ─────────────────────────────────────────────── */
[data-fragment="share-link"] button {
    width: auto;
    display: inline-block;
}

/* ── Divers ──────────────────────────────────────────────────────── */
.muted { color: var(--pico-muted-color); }
.error { color: var(--pico-del-color, #c0392b); font-weight: 600; }

#expense-preview {
    font-size: 0.85rem;
    color: var(--pico-muted-color);
    margin: 0.25rem 0 0.5rem;
    min-height: 1.2rem;
}

/* Cibles tactiles ≥ 44px sur petits appareils */
@media (max-width: 480px) {
    button, [type="submit"], [type="button"], select, input[type="checkbox"] {
        min-height: 44px;
    }
}

/* ── Bouton de bascule thème (lune / soleil) ────────────────────── */
.theme-toggle {
    position: fixed;
    top: 0.75rem;
    right: 0.75rem;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--pico-muted-border-color);
    background: var(--pico-card-background-color);
    color: var(--pico-color);
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 99;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    min-width: unset;
    min-height: unset;
}

/* ── Desktop (≥ 768px) ──────────────────────────────────────────── */
@media (min-width: 768px) {

    /* Corps : annuler le padding réservé à la barre basse */
    body {
        padding-bottom: 0;
    }

    /* Navigation : déplacer en haut, sticky */
    header nav {
        position: sticky;
        top: 0;
        bottom: auto;
        height: auto;
        padding: 0.5rem 1.5rem;
        border-top: none;
        border-bottom: 1px solid var(--pico-muted-border-color);
        justify-content: space-between;
    }

    /* Feuille modale → dialogue centré */
    .modal-sheet {
        bottom: auto;
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        max-width: 32rem;
        width: calc(100% - 2rem);
        max-height: 90vh;
        border-radius: var(--pico-border-radius);
        border: 1px solid var(--pico-muted-border-color);
        box-shadow: 0 8px 32px rgba(0,0,0,0.18);
        z-index: 110; /* au-dessus du header sticky (z-index: 100) */
    }


    /* FAB : réajuster par rapport à la barre désormais absente en bas */
    .fab {
        bottom: 1.5rem;
        right: 1.5rem;
    }

    /* Bouton thème : passer en bas à gauche (le haut est pris par la nav sticky) */
    .theme-toggle {
        top: auto;
        right: auto;
        bottom: 1.5rem;
        left: 1.5rem;
    }
}
