:root {
    --primary: #e8590c;
    --primary-dark: #c94c08;
    --bg: #faf7f2;
    --card: #ffffff;
    --text: #2d2a26;
    --muted: #7a736a;
    --border: #e8e2d9;
    --green: #2f9e44;
    --red: #e03131;
    --amber: #f08c00;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---------- Barre de navigation ---------- */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { font-size: 1.25rem; font-weight: 700; text-decoration: none; color: var(--text); }
.brand span { color: var(--primary); }
.topbar nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; color: var(--text); font-weight: 500; }
.topbar nav a:hover { color: var(--primary); }
.nav-admin { color: var(--primary) !important; font-weight: 600 !important; }
.nav-user { color: var(--muted); }

/* ---------- Structure ---------- */
.container { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 1rem; border-top: 1px solid var(--border); }

h1 { margin: 0.5rem 0 1rem; font-size: 1.7rem; }
h2 { margin: 1.5rem 0 0.8rem; font-size: 1.25rem; }

/* ---------- Messages flash ---------- */
.flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-weight: 500; }
.flash-success { background: #d3f9d8; color: #1b6e2a; }
.flash-error { background: #ffe3e3; color: #a61e1e; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1.1rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn:hover { background: var(--primary-dark); }
.btn-small { padding: 0.35rem 0.8rem; font-size: 0.85rem; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #b02525; }

/* ---------- Cartes du menu ---------- */
.cat-title { margin: 2rem 0 1rem; padding-bottom: 0.4rem; border-bottom: 2px solid var(--primary); font-size: 1.3rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.2rem; }
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card h3 { font-size: 1.05rem; }
.card p { color: var(--muted); font-size: 0.9rem; flex: 1; }
.card .prix { font-weight: 700; color: var(--primary); font-size: 1.1rem; }
.card .compo { font-size: 0.8rem; color: var(--muted); font-style: italic; }

/* ---------- Formulaires ---------- */
.form-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    max-width: 460px;
    margin: 2rem auto;
}
.form-box h1 { text-align: center; margin-bottom: 1.2rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.3rem; font-size: 0.9rem; }
.field input, .field select, .field textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
    color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid var(--primary);
    border-color: transparent;
}
.form-note { text-align: center; color: var(--muted); font-size: 0.88rem; margin-top: 1rem; }
.form-note a { color: var(--primary); }
.form-inline { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: flex-end; }
.form-inline .field { margin-bottom: 0; flex: 1; min-width: 130px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: #f5f0e8; font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: none; }

/* ---------- Badges d'état ---------- */
.badge { display: inline-block; padding: 0.2rem 0.65rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.badge-encours { background: #fff3bf; color: #8a6d00; }
.badge-regle { background: #d0ebff; color: #1864ab; }
.badge-livre { background: #d3f9d8; color: #1b6e2a; }
.badge-annule { background: #ffe3e3; color: #a61e1e; }

/* ---------- Tableau de bord admin ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin: 1rem 0 2rem; }
.stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.1rem;
    text-align: center;
}
.stat .num { font-size: 1.9rem; font-weight: 800; color: var(--primary); }
.stat .lbl { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }

.admin-menu { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.admin-menu a {
    text-decoration: none;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 999px;
    padding: 0.4rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.admin-menu a:hover, .admin-menu a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.actions-cell { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.hero {
    background: linear-gradient(135deg, #fff4e6, #ffe8cc);
    border: 1px solid #ffd8a8;
    border-radius: 14px;
    padding: 1.6rem 2rem;
    margin-bottom: 1rem;
}
.hero h1 { margin: 0 0 0.4rem; }
.hero p { color: var(--muted); }
