/* =====================================================================
   BTP SNAGGING — Design system
   Fichier : public/assets/css/app.css
   Source de vérité : charte de btpservices.pro (style.css v2026.09.27a)
   Les tokens ci-dessous reprennent À L'IDENTIQUE les variables du site
   vitrine. Ne pas modifier une valeur sans la modifier aussi sur le site.
   ===================================================================== */

/* ---------- Polices (auto-hébergées, identiques au site) ---------- */
@font-face { font-family: "Poppins"; src: url("../fonts/poppins-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("../fonts/poppins-bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

/* ---------- Tokens : thème sombre par défaut (comme le site) ---------- */
:root {
    /* Marque */
    --orange: #FEA104;          /* accent chantier principal */
    --orange-hover: #E59100;
    --black: #231F20;           /* noir du logo */
    --black-deep: #1A1718;
    --on-orange: #231F20;       /* texte posé sur l'orange */

    /* Surfaces & texte (sombre) */
    --bg: #231F20;
    --bg-alt: #2A2526;
    --surface: #302B2C;
    --text: #F2F2F2;
    --muted: #ABABAB;
    --border: #3B3536;
    --accent-text: #FEA104;     /* orange lisible sur le fond courant */

    /* Géométrie (site) */
    --radius: 12px;             /* cartes */
    --radius-btn: 8px;          /* boutons, champs */
    --radius-pill: 999px;       /* filtres, badges */
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
    --wrap: 1180px;
    --gutter: 20px;
    --header-h: 68px;
    --bottom-nav-h: 64px;

    /* Motif zellige (site) */
    --zellige: .30;
    --zellige-size: 180px;

    /* Métier : sévérités des réserves (high & medium = valeurs du site) */
    --sev-low: #8A9AA6;
    --sev-medium: #E08E00;
    --sev-high: #D64533;
    --sev-critical: #8E1F14;

    /* Métier : statuts des réserves */
    --st-open: #D64533;
    --st-progress: #E08E00;
    --st-resolved: #2E9D5B;
    --st-closed: #7A7A7A;

    color-scheme: dark;
}

/* ---------- Thème clair (valeurs du site) — utile en plein soleil sur chantier ---------- */
[data-theme="light"] {
    --bg: #FFFFFF;
    --bg-alt: #F4F4F4;
    --surface: #FFFFFF;
    --text: #161616;
    --muted: #5C5C5C;
    --border: #E2E2E2;
    --shadow: 0 10px 30px rgba(0, 0, 0, .08);
    --accent-text: #9A5B00;
    --st-resolved: #1F7A44;
    color-scheme: light;
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg: #FFFFFF;
        --bg-alt: #F4F4F4;
        --surface: #FFFFFF;
        --text: #161616;
        --muted: #5C5C5C;
        --border: #E2E2E2;
        --shadow: 0 10px 30px rgba(0, 0, 0, .08);
        --accent-text: #9A5B00;
        --st-resolved: #1F7A44;
        color-scheme: light;
    }
}

/* ---------- Base ---------- */
/* Préflight minimal (preflight Tailwind désactivé) : les utilitaires `border` fonctionnent */
*, *::before, *::after { box-sizing: border-box; border-width: 0; border-style: solid; border-color: var(--border); }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
    margin: 0;
    font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 1rem; line-height: 1.6;
    background: var(--bg); color: var(--text);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .h1, .h2, .h3 { line-height: 1.15; letter-spacing: -.015em; margin: 0 0 .6rem; font-weight: 700; }
/* Dans l'application, titres plus compacts que sur le site vitrine */
h1, .h1 { font-size: clamp(1.5rem, 3.2vw, 2.1rem); }
h2, .h2 { font-size: clamp(1.2rem, 2.4vw, 1.5rem); }
h3, .h3 { font-size: 1.08rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent-text); }
img, svg { max-width: 100%; }
.accent { color: var(--accent-text); }
.eyebrow { display: block; margin: 0 0 .5rem; color: var(--accent-text); font-size: .78rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.lead { color: var(--muted); font-size: 1.05rem; max-width: 760px; }
.note, .meta { color: var(--muted); font-size: .85rem; }
/* Les enfants de grilles/flex ne doivent jamais élargir la page (tableaux, onglets) */
.grid > *, .flex > * { min-width: 0; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }

:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.skip-link { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 200; padding: 10px 16px; border-radius: 8px; background: var(--orange); color: var(--on-orange); font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---------- Boutons (copie conforme du site) ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    min-height: 48px; padding: 12px 22px; border-radius: var(--radius-btn);
    border: 2px solid transparent; font: inherit; font-weight: 700; font-size: .95rem;
    text-decoration: none; cursor: pointer; transition: background .2s, color .2s, border-color .2s, transform .2s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--orange); color: var(--on-orange); }
.btn--primary:hover { background: var(--orange-hover); color: var(--on-orange); }
.btn--ghost { border-color: var(--accent-text); color: var(--accent-text); background: transparent; }
.btn--ghost:hover { background: var(--orange); border-color: var(--orange); color: var(--on-orange); }
.btn--ghost-light { border-color: #FFFFFF; color: #FFFFFF; background: transparent; }
.btn--ghost-light:hover { background: #FFFFFF; color: var(--black); }
/* Ajouts application */
.btn--quiet { background: var(--bg-alt); color: var(--text); border-color: var(--border); }
.btn--quiet:hover { border-color: var(--accent-text); }
.btn--danger { background: var(--sev-high); color: #FFFFFF; }
.btn--danger:hover { background: #B8392A; }
.btn--sm { min-height: 40px; padding: 8px 16px; font-size: .88rem; }
.btn--icon { min-height: 44px; min-width: 44px; padding: 0; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; cursor: progress; }

/* ---------- En-tête (toujours noir : fond du logo, comme le site) ---------- */
.app-header { position: sticky; top: 0; z-index: 100; background: var(--black); border-bottom: 1px solid #3B3536; color: #F2F2F2; }
.app-header__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: var(--header-h); }
.app-header__logo { display: flex; align-items: center; gap: 10px; color: #F2F2F2; text-decoration: none; font-weight: 700; }
.app-header__logo img { width: auto; height: 44px; border-radius: 4px; }
.app-header__product { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--orange); }
.app-nav { display: none; }
.app-nav ul { display: flex; gap: 2px; margin: 0; padding: 0; list-style: none; }
.app-nav a { display: block; padding: 8px 12px; border-radius: 6px; color: #BDBDBD; text-decoration: none; font-weight: 500; font-size: .93rem; }
.app-nav a:hover { color: #FFFFFF; background: rgba(255,255,255,.06); }
.app-nav a[aria-current="page"] { color: var(--orange); }
@media (min-width: 1024px) { .app-nav { display: block; } }

/* Barre de navigation basse (smartphone / tablette sur chantier) */
.bottom-nav { position: fixed; inset-inline: 0; bottom: 0; z-index: 100; height: var(--bottom-nav-h); padding-bottom: env(safe-area-inset-bottom); background: var(--black); border-top: 1px solid #3B3536; }
.bottom-nav ul { display: grid; grid-template-columns: repeat(5, 1fr); height: 100%; margin: 0; padding: 0; list-style: none; }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 100%; color: #BDBDBD; text-decoration: none; font-size: .7rem; font-weight: 500; }
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a[aria-current="page"] { color: var(--orange); }
.has-bottom-nav { padding-bottom: calc(var(--bottom-nav-h) + 16px); }
@media (min-width: 1024px) { .bottom-nav { display: none; } .has-bottom-nav { padding-bottom: 0; } }

/* Bandeau de page avec motif zellige (repris du site) */
.page-hero { position: relative; isolation: isolate; overflow: hidden; background: var(--black); color: #F2F2F2; padding: 28px 0 24px; border-bottom: 2px solid var(--orange); }
.page-hero::before {
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: url("../img/zellige.svg") center / var(--zellige-size) repeat;
    opacity: var(--zellige);
    -webkit-mask-image: radial-gradient(ellipse 60% 75% at 72% 50%, #000 0%, rgba(0,0,0,.55) 45%, transparent 78%);
            mask-image: radial-gradient(ellipse 60% 75% at 72% 50%, #000 0%, rgba(0,0,0,.55) 45%, transparent 78%);
}
.page-hero .meta { color: #BDBDBD; }
/* Zones toujours noires : l'orange vif reste lisible quel que soit le thème */
.app-header, .page-hero, .bottom-nav, .toast { --accent-text: var(--orange); }

/* ---------- Cartes (copie conforme du site : filet orange en tête) ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--orange); border-radius: var(--radius); padding: 22px; }
.card p { color: var(--muted); font-size: .93rem; margin: 0; }
.card--flat { border-top-width: 1px; border-top-color: var(--border); }
.card--media { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.card--media img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.card__body { padding: 18px 20px 22px; }
.link-arrow { color: var(--accent-text); font-weight: 700; text-decoration: none; }
.link-arrow::after { content: " →"; }
[dir="rtl"] .link-arrow::after { content: " ←"; }

/* KPI du tableau de bord */
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi__label { color: var(--muted); font-size: .8rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.kpi__value { font-size: 2.1rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi__trend { font-size: .82rem; color: var(--muted); }
.kpi--alert { border-inline-start: 4px solid var(--sev-high); }
.kpi--warn  { border-inline-start: 4px solid var(--orange); }

/* ---------- Badges : sévérité & statut ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--radius-pill); font-size: .74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; line-height: 1.5; white-space: nowrap; }
.sev--low      { background: var(--sev-low); color: #161616; }
.sev--medium   { background: var(--sev-medium); color: #231F20; }
.sev--high     { background: #C73A29; color: #FFFFFF; }
.sev--critical { background: var(--sev-critical); color: #FFFFFF; }

.status { background: transparent; border: 1px solid var(--border); color: var(--text); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status--open        { color: var(--st-open); }
.status--in_progress { color: var(--st-progress); }
.status--resolved    { color: var(--st-resolved); }
.status--closed      { color: var(--st-closed); }
.status--draft, .status--paused, .status--archived { color: var(--muted); }
.status--active    { color: var(--st-resolved); }
.status--completed { color: var(--accent-text); }

/* Pastille corps d'état (couleur injectée en style="--trade:#xxxxxx") */
.trade { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; }
.trade::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--trade, var(--muted)); }

/* ---------- Filtres en pilule (repris du rapport snagging du site) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-size: .88rem; font-weight: 700; min-height: 40px; padding: 8px 14px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.chip[aria-pressed="true"], .chip.is-active { background: var(--orange); border-color: var(--orange); color: var(--on-orange); }

/* ---------- Formulaires ---------- */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.label { font-size: .88rem; font-weight: 600; }
.label .req { color: var(--accent-text); }
.input, .select, .textarea {
    width: 100%; min-height: 48px; padding: 10px 14px; font: inherit; font-size: 1rem;
    color: var(--text); background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius-btn);
    transition: border-color .2s, box-shadow .2s;
}
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(254,161,4,.25); }
.input[aria-invalid="true"] { border-color: var(--sev-high); }
.help { font-size: .8rem; color: var(--muted); }
.error { font-size: .82rem; color: var(--sev-high); font-weight: 600; }

/* ---------- Onglets (vue projet) ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; padding: 12px 16px; min-height: 48px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); font: inherit; font-weight: 600; font-size: .93rem; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--orange); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: start; padding: 12px 14px; font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--bg-alt); border-bottom: 1px solid var(--border); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg-alt); }

/* ---------- Plan d'étage + épingles de réserves ----------
   Les coordonnées sont stockées en % (0–100) : la position reste juste
   quelle que soit la taille d'écran. */
.plan { position: relative; width: 100%; background: #FFFFFF; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; touch-action: manipulation; cursor: crosshair; }
.plan img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.plan-pin {
    position: absolute; transform: translate(-50%, -100%);
    width: 30px; height: 30px; border-radius: 50% 50% 50% 0; rotate: -45deg;
    background: var(--pin, var(--sev-high)); border: 2px solid #FFFFFF; box-shadow: 0 2px 6px rgba(0,0,0,.4);
    display: grid; place-items: center; cursor: pointer; padding: 0;
}
.plan-pin > span { rotate: 45deg; color: #FFFFFF; font-size: .68rem; font-weight: 700; }
.plan-pin--low      { --pin: var(--sev-low); }
.plan-pin--medium   { --pin: var(--sev-medium); }
.plan-pin--high     { --pin: var(--sev-high); }
.plan-pin--critical { --pin: var(--sev-critical); }
.plan-pin.is-resolved { opacity: .55; }
.plan-pin.is-active, .plan-pin:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; z-index: 2; }
.plan-pin--draft { --pin: var(--orange); animation: pin-pulse 1.2s ease-in-out infinite; }
@keyframes pin-pulse { 50% { box-shadow: 0 0 0 8px rgba(254,161,4,.25); } }
@media (prefers-reduced-motion: reduce) { .plan-pin--draft { animation: none; } }

/* ---------- Panneau latéral (formulaire réserve) ---------- */
.drawer { position: fixed; inset-block: 0; inset-inline-end: 0; z-index: 150; width: min(440px, 100%); background: var(--surface); border-inline-start: 1px solid var(--border); box-shadow: var(--shadow); overflow-y: auto; }
.drawer__head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; background: var(--surface); border-bottom: 1px solid var(--border); border-top: 3px solid var(--orange); }
.drawer__body { padding: 20px; }
.backdrop { position: fixed; inset: 0; z-index: 140; background: rgba(0,0,0,.55); }

/* ---------- Messagerie client ---------- */
.thread { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 14px; background: var(--bg-alt); border: 1px solid var(--border); font-size: .93rem; }
.msg--mine { align-self: flex-end; background: var(--orange); border-color: var(--orange); color: var(--on-orange); border-end-end-radius: 4px; }
.msg--theirs { align-self: flex-start; border-end-start-radius: 4px; }
.msg__meta { display: block; margin-top: 4px; font-size: .72rem; opacity: .75; }

/* ---------- Divers ---------- */
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--orange); color: var(--on-orange); font-weight: 700; font-size: .85rem; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.progress { height: 8px; border-radius: 999px; background: var(--bg-alt); border: 1px solid var(--border); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--orange); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.toast { position: fixed; inset-inline: 16px; bottom: calc(var(--bottom-nav-h) + 16px); z-index: 300; max-width: 420px; margin-inline: auto; padding: 12px 16px; border-radius: var(--radius-btn); background: var(--black); color: #F2F2F2; border-inline-start: 4px solid var(--orange); box-shadow: var(--shadow); }
.toast--error { border-inline-start-color: var(--sev-high); }
.divider { height: 1px; background: var(--border); border: 0; margin: 20px 0; }
[x-cloak] { display: none !important; }

@media print {
    .app-header, .bottom-nav, .tabs, .btn, .chips { display: none !important; }
    body { background: #FFFFFF; color: #161616; }
    .card { break-inside: avoid; border-color: #CCCCCC; }
}

/* =====================================================================
   Compléments L3 — menus, Gantt (Frappe Gantt 0.6.1 aux couleurs BTP)
   ===================================================================== */
summary.avatar::-webkit-details-marker { display: none; }
summary.avatar { list-style: none; }
details[open] > summary.avatar { box-shadow: 0 0 0 3px rgba(254,161,4,.35); }
.drawer { color: var(--text); }
button.card { font: inherit; display: block; }

.gantt-host { overflow-x: auto; background: var(--surface); }
.gantt-host svg { max-width: none; }            /* le SVG du Gantt dépasse volontairement : défilement horizontal */
.gantt-host .gantt-container { background: var(--surface); }
.gantt-host .gantt .grid-background { fill: none; }
.gantt-host .gantt .grid-header { fill: var(--bg-alt); stroke: var(--border); }
.gantt-host .gantt .grid-row { fill: var(--surface); }
.gantt-host .gantt .grid-row:nth-child(even) { fill: var(--bg-alt); }
.gantt-host .gantt .row-line, .gantt-host .gantt .tick { stroke: var(--border); }
.gantt-host .gantt .today-highlight { fill: rgba(254,161,4,.14); }
.gantt-host .gantt .lower-text, .gantt-host .gantt .upper-text { fill: var(--muted); font-family: "Poppins", system-ui, sans-serif; font-size: 12px; }
.gantt-host .gantt .upper-text { fill: var(--text); font-weight: 600; }
.gantt-host .gantt .bar { fill: #6B6264; stroke: none; }
.gantt-host .gantt .bar-progress { fill: var(--orange); }
.gantt-host .gantt .bar-label { fill: #FFFFFF; font-family: "Poppins", system-ui, sans-serif; font-size: 12px; font-weight: 600; }
.gantt-host .gantt .bar-label.big { fill: var(--text); }
.gantt-host .gantt .bar-wrapper:hover .bar { fill: #7C7274; }
.gantt-host .gantt .bar-wrapper.active .bar { fill: #7C7274; }
.gantt-host .gantt .is-phase .bar { fill: #3B3536; }
.gantt-host .gantt .is-phase .bar-progress { fill: #C98200; }
.gantt-host .gantt .is-late .bar { stroke: var(--sev-high); stroke-width: 2px; }
.gantt-host .gantt .is-milestone .bar { fill: var(--sev-high); rx: 12; }
.gantt-host .gantt .is-milestone .bar-progress { fill: var(--sev-high); }
.gantt-host .gantt .arrow { stroke: var(--muted); stroke-width: 1.4; }
.gantt-host .gantt .handle { fill: var(--orange); opacity: 0; }
.gantt-host .gantt .bar-wrapper:hover .handle { opacity: .9; }
.gantt-host.is-readonly .handle, .gantt-host.is-readonly .bar-progress + .handle { display: none; }
.gantt-host.is-readonly .bar-wrapper { pointer-events: none; }
.gantt-host .gantt-container .popup-wrapper { background: var(--black); color: #F2F2F2; border-radius: 8px; box-shadow: var(--shadow); }
.gantt-pop { display: grid; gap: 2px; padding: 10px 12px; font-size: .82rem; min-width: 200px; }
.gantt-pop strong { color: var(--orange); }
.gantt-host .gantt .bar-wrapper:hover .bar-progress, .gantt-host .gantt .bar-wrapper.active .bar-progress { fill: var(--orange-hover); }
.gantt-host .gantt .is-phase:hover .bar, .gantt-host .gantt .is-phase.active .bar { fill: #4A4344; }
