/* =====================================================================
   Waale — Planning des brassages
   Palette inspirée de la brasserie : malt torréfié, cuivre, papier kraft.
   Mobile-first, sans dépendance externe (compatible CSP self).
   ===================================================================== */

:root {
    --ink:        #211d18;   /* texte principal — malt torréfié      */
    --ink-soft:   #6b6258;   /* texte secondaire                     */
    --paper:      #f6f3ec;   /* fond — papier kraft clair            */
    --surface:    #ffffff;   /* cartes, tableaux                     */
    --line:       #e2dccf;   /* filets                               */
    --copper:     #b5713a;   /* accent principal — cuivre de cuve    */
    --copper-dk:  #94572a;
    --hop:        #4f9d5b;   /* succès / houblon                     */
    --warn:       #c98a17;
    --danger:     #b3402f;
    --radius:     8px;
    --shadow:     0 1px 2px rgba(33,29,24,.06), 0 4px 16px rgba(33,29,24,.05);
    --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--sans);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.5;
    font-size: 15px;
    color-scheme: light;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; letter-spacing: .01em; }
h2 { font-size: 1.15rem; }

a { color: var(--copper-dk); }

/* ---- Barre supérieure ---------------------------------------------- */
.topbar {
    display: flex; align-items: center; gap: 1rem;
    background: var(--ink);
    color: #f3ede2;
    padding: .55rem 1rem;
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: inherit; font-weight: 700; }
.brand-mark {
    display: grid; place-items: center;
    width: 30px; height: 30px; border-radius: 6px;
    background: var(--copper); color: #fff;
    font-weight: 800; font-size: 1rem;
}
.brand-text { letter-spacing: .14em; text-transform: uppercase; font-size: .8rem; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; color: #f3ede2; font-size: 1.6rem; cursor: pointer; }
.mainnav { display: flex; align-items: center; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.mainnav a {
    color: #d9d1c4; text-decoration: none; padding: .35rem .6rem;
    border-radius: 6px; font-size: .9rem;
}
.mainnav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-user { color: #8d8478; font-size: .82rem; padding: 0 .4rem; }
.nav-logout { color: #e0b59a !important; }

/* ---- Conteneur ----------------------------------------------------- */
.container { max-width: 1180px; margin: 0 auto; padding: 1.4rem 1rem 3rem; }
.footer { text-align: center; color: var(--ink-soft); font-size: .8rem; padding: 1.5rem; }

/* ---- En-tête de page ----------------------------------------------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }

/* ---- Messages flash ------------------------------------------------ */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; font-size: .92rem; }
.flash-info   { background: #eef4f7; border-color: #cfe0e8; color: #2c5468; }
.flash-success{ background: #eef6ef; border-color: #cfe6d2; color: #2f6b3a; }
.flash-warn   { background: #fdf4e3; border-color: #f0dcae; color: #8a6411; }
.flash-error  { background: #fbece9; border-color: #f0c9c1; color: #8f2f22; }

/* ---- Boutons ------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    background: var(--copper); color: #fff; border: 0;
    padding: .5rem .9rem; border-radius: 7px; font-size: .9rem;
    text-decoration: none; cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--copper-dk); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: #efeadf; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #922e22; }
.btn-sm { padding: .3rem .55rem; font-size: .8rem; }

/* ---- Cartes & tableaux --------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; margin-bottom: 1.1rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { background: #efeadf; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; font-size: .72rem; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fbf9f4; }

.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.badge-planned   { background: #e9eef2; color: #41637a; }
.badge-active    { background: #fbeede; color: #9a6418; }
.badge-done      { background: #e8f2ea; color: #356b40; }
.badge-cancelled { background: #f2e6e4; color: #8a3a2e; }
.badge-admin     { background: #f2e2cf; color: #8a5a26; }

.dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: middle; margin-right: .4rem; }

/* ---- Formulaires --------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.field input:not([type=checkbox]):not([type=radio]):not([type=color]), .field select, .field textarea {
    font: inherit; padding: .5rem .6rem; border: 1px solid var(--line);
    border-radius: 6px; background: #fff; color: var(--ink); width: 100%;
}
.field input:not([type=checkbox]):not([type=radio]):focus, .field select:focus, .field textarea:focus {
    outline: 2px solid var(--copper); outline-offset: 1px; border-color: var(--copper);
}
/* Cases à cocher / radios : rendu natif compact (corrige l'affichage Safari) */
.field input[type=checkbox], .field input[type=radio],
.checks input[type=checkbox], .checks input[type=radio] {
    width: auto; flex: 0 0 auto; margin: 0; padding: 0;
    background: none; border: 0; border-radius: 0;
    accent-color: var(--copper); cursor: pointer;
}
.field .hint { font-size: .76rem; color: var(--ink-soft); }
.form-actions { display: flex; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; }
legend { font-weight: 600; padding: 0 .4rem; color: var(--ink-soft); }
.checks { display: flex; flex-wrap: wrap; gap: .5rem; }
.checks label { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); padding: .35rem .6rem; border-radius: 6px; font-size: .85rem; font-weight: 500; color: var(--ink); background: #fff; cursor: pointer; }

/* ---- Connexion ----------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 1.6rem; }
.login-card .brand { color: var(--ink); margin-bottom: 1.2rem; }
.login-card .brand-text { color: var(--ink); }

/* =====================================================================
   Vue planning (Gantt)  — signature de l'application
   ===================================================================== */
.gantt { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.gantt-inner { min-width: 720px; }

.gantt-row { display: grid; grid-template-columns: 220px 1fr; border-bottom: 1px solid var(--line); }
.gantt-row.head { position: sticky; top: 0; z-index: 2; background: #efeadf; }
.gantt-row:last-child { border-bottom: 0; }

.gantt-label { padding: .6rem .7rem; border-right: 1px solid var(--line); }
.gantt-label .brew-name { font-weight: 600; }
.gantt-label .brew-meta { font-size: .76rem; color: var(--ink-soft); }

.gantt-track { position: relative; }
.gantt-scale { display: flex; }
.gantt-scale .tick { flex: 1 0 auto; font-size: .68rem; color: var(--ink-soft); padding: .5rem .3rem; border-left: 1px solid var(--line); text-align: left; white-space: nowrap; }

.gantt-bars { position: relative; height: 38px; }
.gantt-bars .gridline { position: absolute; top: 0; bottom: 0; border-left: 1px dashed #efe9dd; }
.bar {
    position: absolute; top: 7px; height: 24px;
    border-radius: 5px; color: #fff; font-size: .7rem;
    padding: 0 .35rem; display: flex; align-items: center; overflow: hidden;
    white-space: nowrap; box-shadow: inset 0 -2px 0 rgba(0,0,0,.12);
    cursor: default;
}
.bar.point { width: 14px !important; border-radius: 999px; padding: 0; justify-content: center; }
.bar .bar-temp { opacity: .85; margin-left: .3rem; font-variant-numeric: tabular-nums; }

.today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 1; }
.today-flag { position: absolute; top: -2px; font-size: .62rem; color: var(--danger); transform: translateX(-50%); }

/* ---- Légende ------------------------------------------------------- */
.legend { display: flex; flex-wrap: wrap; gap: .8rem; margin: .9rem 0; font-size: .82rem; }
.legend span { display: inline-flex; align-items: center; }

/* ---- Détail brassin (timeline verticale) --------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 16px 1fr; gap: .8rem; padding: .2rem 0; }
.timeline .tl-dot { width: 14px; height: 14px; border-radius: 4px; margin-top: .35rem; }
.timeline .tl-body { border-left: 2px solid var(--line); padding: 0 0 1rem .9rem; margin-left: -8px; }
.timeline .tl-title { font-weight: 600; }
.timeline .tl-meta { font-size: .82rem; color: var(--ink-soft); }

.empty { text-align: center; color: var(--ink-soft); padding: 2.5rem 1rem; }

.inline-form { display: inline; }

/* ---- Responsive ---------------------------------------------------- */
@media (max-width: 760px) {
    .nav-toggle { display: block; }
    .mainnav { display: none; width: 100%; flex-direction: column; align-items: flex-start; margin-top: .5rem; }
    body.nav-open .mainnav { display: flex; }
    .mainnav a, .nav-user { width: 100%; padding: .5rem .4rem; }
    .form-grid { grid-template-columns: 1fr; }
    .gantt-row { grid-template-columns: 140px 1fr; }
    .gantt-label .brew-meta { display: none; }
}

/* ---- Accessibilité ------------------------------------------------- */
:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
