/* ============================================================
   COMPOZIT V2 — design system « 2026 vibrant »
   Verre dépoli + dégradés cyan→indigo sur identité bleu ciel.
   Thèmes clair & sombre via [data-theme]. Identité badges conservée.
   ============================================================ */

:root {
    color-scheme: light;

    /* Encre & texte */
    --ink: #16202B;
    --ink-strong: #0B1622;
    --muted: #5B6776;

    /* Fond applicatif (mesh dégradé) */
    --app-bg:
        radial-gradient(1100px 620px at 8% -12%, #DCF1FF 0%, transparent 60%),
        radial-gradient(1000px 680px at 112% 8%, #E9E4FF 0%, transparent 55%),
        linear-gradient(180deg, #F6FBFF 0%, #F1F6FC 100%);

    /* Surfaces */
    --surface: #FFFFFF;
    --surface-glass: rgba(255, 255, 255, .66);
    --surface-glass-strong: rgba(255, 255, 255, .82);
    --glass-border: rgba(255, 255, 255, .6);
    --blur: 16px;

    --border: rgba(17, 42, 70, .10);
    --border-input: rgba(17, 42, 70, .18);
    --hover-row: rgba(60, 140, 220, .07);

    /* Accents vibrants */
    --accent: #2F86E0;
    --accent-grad: linear-gradient(135deg, #3FC1F0 0%, #4F9BF0 48%, #6C7BFF 100%);
    --accent-soft: rgba(79, 155, 240, .14);

    /* Sidebar (verre teinté ciel) */
    --sidebar-grad: linear-gradient(180deg, rgba(196, 236, 255, .88) 0%, rgba(214, 238, 255, .55) 100%);
    --sidebar-item-active: linear-gradient(135deg, #A6DBFF 0%, #C6E9FF 100%);
    --sidebar-line: rgba(29, 31, 37, .14);

    /* Ombres & halos */
    --glow: 0 10px 26px rgba(79, 140, 230, .30);
    --shadow-card: 0 8px 26px rgba(20, 50, 90, .09), inset 0 1px 0 rgba(255, 255, 255, .55);
    --shadow-pop: 0 32px 80px rgba(15, 30, 60, .30);

    /* Badges (identité Airtable conservée) */
    --badge-ink: #173249;
    --badge-en-cours: #BCE2F5;
    --badge-archive: #DCE3EA;
    --badge-categorie: #C4ECFF;
    --badge-particulier: #B1E0DC;
    --badge-professionnel: #C1F5F0;
    --diff-positive: #D7507F;
    --diff-negative: #2FA15A;
    --charge-bg: #CFF5D1;

    --radius: 10px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-modal: 18px;
}

[data-theme="dark"] {
    color-scheme: dark;

    --ink: #E6ECF3;
    --ink-strong: #F5F8FC;
    --muted: #93A1B3;

    --app-bg:
        radial-gradient(1100px 620px at 8% -12%, #15314C 0%, transparent 60%),
        radial-gradient(1000px 680px at 112% 8%, #221C49 0%, transparent 55%),
        linear-gradient(180deg, #0C1119 0%, #090D13 100%);

    --surface: #161D27;
    --surface-glass: rgba(28, 37, 50, .60);
    --surface-glass-strong: rgba(30, 40, 54, .80);
    --glass-border: rgba(255, 255, 255, .08);

    --border: rgba(255, 255, 255, .09);
    --border-input: rgba(255, 255, 255, .16);
    --hover-row: rgba(120, 180, 255, .08);

    --accent: #5AA8F5;
    --accent-soft: rgba(90, 168, 245, .18);

    --sidebar-grad: linear-gradient(180deg, rgba(30, 48, 72, .72) 0%, rgba(18, 26, 40, .55) 100%);
    --sidebar-item-active: linear-gradient(135deg, rgba(79, 155, 240, .50) 0%, rgba(108, 123, 255, .38) 100%);
    --sidebar-line: rgba(255, 255, 255, .12);

    --glow: 0 10px 28px rgba(60, 130, 230, .45);
    --shadow-card: 0 10px 30px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .04);
    --shadow-pop: 0 32px 90px rgba(0, 0, 0, .62);

    --badge-ink: #0E1B27;
    --charge-bg: rgba(110, 200, 140, .20);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--ink);
    background: var(--app-bg) fixed;
}

a { color: inherit; }

::selection { background: var(--accent-soft); }

/* Scrollbars discrètes */
* { scrollbar-width: thin; scrollbar-color: rgba(120, 150, 190, .45) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(120, 150, 190, .4); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }

/* ---------- Layout ---------- */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 244px;
    flex-shrink: 0;
    background: var(--sidebar-grad);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
    backdrop-filter: blur(var(--blur)) saturate(140%);
    border-right: 1px solid var(--glass-border);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar .brand {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -.01em;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 18px;
}

.sidebar .section {
    font-weight: 700;
    font-size: 12.5px;
    letter-spacing: .02em;
    text-transform: uppercase;
    opacity: .75;
    padding: 12px 10px 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar a.item {
    display: block;
    padding: 8px 10px 8px 30px;
    text-decoration: none;
    color: var(--ink);
    border-left: 2px solid var(--sidebar-line);
    border-radius: 0 999px 999px 0;
    margin-left: 14px;
    transition: background .16s ease, transform .16s ease, box-shadow .16s ease;
}

.sidebar a.item:hover { background: rgba(255, 255, 255, .45); transform: translateX(2px); }

.sidebar a.item.active {
    background: var(--sidebar-item-active);
    font-weight: 600;
    border-left-color: transparent;
    box-shadow: 0 6px 16px rgba(79, 140, 230, .22);
}

.sidebar .spacer { flex: 1; }

.theme-toggle {
    margin: 6px 8px 4px;
    padding: 9px 12px;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: var(--surface-glass);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: var(--ink);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: transform .15s ease, box-shadow .15s ease;
}
.theme-toggle:hover { transform: translateY(-1px); box-shadow: var(--shadow-card); }

.sidebar .user-box {
    font-size: 12px;
    padding: 12px 10px 4px;
    color: var(--ink);
    border-top: 1px solid var(--sidebar-line);
    margin-top: 4px;
}

.sidebar .user-box a { font-weight: 600; }

.content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
}

.breadcrumb { color: var(--muted); }
.breadcrumb .sep { margin: 0 6px; color: var(--muted); }
.breadcrumb .current { color: var(--ink); font-weight: 600; }

.topbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.page-body { padding: 0 28px 36px; }

h1.page-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--ink-strong);
    margin: 12px 0 20px;
}

/* ---------- Boutons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius);
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    background: none;
    font-family: inherit;
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease, background .15s ease;
}

.btn-primary { background: var(--accent-grad); color: #fff; box-shadow: var(--glow); }
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-color: var(--border-input);
    color: var(--ink);
}
.btn-secondary:hover { background: var(--surface); transform: translateY(-1px); box-shadow: var(--shadow-card); }

.btn-danger { background: var(--surface); border-color: #E5B8C5; color: #C0436B; }
.btn-danger:hover { background: rgba(214, 80, 127, .10); }

.btn-link { color: var(--accent); text-decoration: none; border: none; background: none; cursor: pointer; padding: 8px 0; font-size: 13px; font-weight: 600; }
.btn-link:hover { text-decoration: underline; }

/* ---------- Filtres ---------- */

.filters {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 4px 0 16px;
    flex-wrap: wrap;
}

.filters .right { margin-left: auto; display: flex; gap: 10px; align-items: center; }

select.filter, input.filter {
    border: 1px solid var(--border-input);
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}
select.filter:focus, input.filter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Tableaux ---------- */

.table-wrap {
    overflow-x: auto;
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(var(--blur));
    backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

table.data th {
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: .02em;
    text-transform: uppercase;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.data td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .14s ease; }
table.data tbody tr:hover { background: var(--hover-row); }
table.data tbody tr.clickable { cursor: pointer; }

table.data td.num, table.data th.num { text-align: right; }

.table-footer { color: var(--muted); font-size: 12.5px; padding: 12px 4px; }

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 999px;
    padding: 3px 11px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--badge-ink);
    white-space: nowrap;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35);
}

.badge-en_cours { background: var(--badge-en-cours); }
.badge-archive { background: var(--badge-archive); }
.badge-a_venir { background: #FFE9C7; }
.badge-categorie { background: var(--badge-categorie); }
.badge-particulier { background: var(--badge-particulier); }
.badge-professionnel { background: var(--badge-professionnel); }
.badge-chip { background: #EDF4FA; }

.diff-pos { color: var(--diff-positive); font-weight: 700; }
.diff-neg { color: var(--diff-negative); }
.diff-zero { color: var(--diff-negative); }

/* ---------- Formulaires ---------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; max-width: 860px; }
.form-grid .full { grid-column: 1 / -1; }

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-weight: 600; font-size: 13px; }
.form-row label.required::after { content: ' *'; color: var(--diff-positive); }

.form-row input[type=text], .form-row input[type=number], .form-row input[type=email],
.form-row input[type=date], .form-row input[type=tel], .form-row input[type=password],
.form-row input[type=file], .form-row select, .form-row textarea {
    border: 1px solid var(--border-input);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 13.5px;
    font-family: inherit;
    width: 100%;
    background: var(--surface);
    color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-row .help { color: var(--muted); font-size: 12px; }
.form-errors { color: var(--diff-positive); font-size: 12.5px; }

/* ---------- Modal ---------- */

dialog.modal {
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-modal);
    padding: 0;
    width: min(820px, calc(100vw - 48px));
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(28px) saturate(150%);
    backdrop-filter: blur(28px) saturate(150%);
    color: var(--ink);
    box-shadow: var(--shadow-pop);
}

dialog.modal::backdrop {
    background: rgba(10, 16, 28, .55);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.modal-inner { padding: 30px 36px 20px; position: relative; }
.modal-inner h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--ink-strong); margin: 4px 0 22px; }

.modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    border: none;
    background: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--muted);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    transition: background .15s ease;
}
.modal-close:hover { background: var(--hover-row); }

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    padding: 16px 36px;
}

/* ---------- Trombinoscope ---------- */

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 18px;
}

.gallery .card {
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    text-decoration: none;
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(var(--blur));
    backdrop-filter: blur(var(--blur));
    box-shadow: var(--shadow-card);
    transition: transform .18s ease, box-shadow .18s ease;
}

.gallery .card:hover { transform: translateY(-4px); box-shadow: 0 16px 40px rgba(20, 50, 90, .16); }

.gallery .card .photo {
    aspect-ratio: 4 / 5;
    background: linear-gradient(135deg, #E8F4FF, #EEE9FF) center / cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    color: #9FB6D0;
}

.gallery .card .infos { padding: 12px 14px; }
.gallery .card .nom { font-weight: 700; }
.gallery .card .meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Dashboard ---------- */

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 24px; }

.panel {
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(var(--blur));
    backdrop-filter: blur(var(--blur));
    box-shadow: var(--shadow-card);
}

.panel h3 { margin: 0 0 2px; font-size: 15px; color: var(--ink-strong); }
.panel .subtitle { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.panel .chart-box { position: relative; height: 280px; }

/* ---------- Planification (Gantt hebdomadaire) ---------- */

.calendar-shell {
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 14px;
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(var(--blur));
    backdrop-filter: blur(var(--blur));
    box-shadow: var(--shadow-card);
}

.gantt-toolbar { display: flex; align-items: center; gap: 12px; margin: 8px 0 4px; }

.gantt-grille {
    display: grid;
    grid-template-columns: 160px repeat(7, 1fr);
    position: relative;
}

.gantt-entete .gantt-jour {
    text-align: left;
    padding: 6px 8px;
    color: var(--muted);
    font-size: 12px;
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.gantt-entete .gantt-jour strong { color: var(--ink); font-size: 14px; }
.gantt-entete .gantt-jour.aujourdhui strong { color: var(--accent); }

.gantt-label {
    padding: 8px 10px;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
}

.gantt-rangee { border-bottom: 1px solid var(--border); }

.gantt-cellule {
    border-left: 1px solid var(--border);
    position: relative;
}

.gantt-cellule.aujourdhui { background: var(--accent-soft); }

.gantt-charge-perso {
    position: absolute;
    bottom: 3px;
    right: 6px;
    font-size: 11px;
    color: var(--muted);
}

/* Couche des barres : recouvre les 7 colonnes de jours (pas le label) */
.gantt-couche {
    position: absolute;
    left: 160px;
    right: 0;
    top: 0;
    bottom: 22px;
    pointer-events: none;
}

.gantt-barre {
    position: absolute;
    height: 26px;
    background: linear-gradient(135deg, #8FCFF0 0%, #9FB4FF 100%);
    border: 1px solid rgba(79, 140, 230, .5);
    color: #15324A;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 24px;
    padding: 0 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: auto;
    cursor: pointer;
    box-sizing: border-box;
    box-shadow: 0 4px 12px rgba(79, 140, 230, .28);
}

.gantt-barre.editable { cursor: grab; }
.gantt-barre.editable:active { cursor: grabbing; }
.gantt-barre.continue-avant { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-style: dashed; }
.gantt-barre.continue-apres { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right-style: dashed; }

.gantt-poignee {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 10px;
    cursor: ew-resize;
    border-right: 3px solid rgba(29, 31, 37, .35);
    border-radius: 0 8px 8px 0;
}

.charge-row {
    display: grid;
    margin-top: 8px;
    background: var(--charge-bg);
    border-radius: var(--radius);
    overflow: hidden;
}

.gantt-grille-pied { grid-template-columns: 160px repeat(7, 1fr); }

.charge-row .cell {
    padding: 8px 10px;
    font-size: 12.5px;
    border-right: 1px solid rgba(0, 0, 0, .06);
}

.charge-row .cell.label { font-weight: 600; }

/* panneau "Voir projets" */
.projets-a-placer { margin-top: 14px; }
.projets-a-placer .pill {
    display: inline-block;
    background: var(--badge-categorie);
    color: var(--badge-ink);
    border-radius: 999px;
    padding: 5px 13px;
    margin: 0 6px 6px 0;
    font-size: 12.5px;
    font-weight: 600;
}

/* ---------- Chiffrage ---------- */

.chiffrage-grid { display: grid; grid-template-columns: 360px 1fr; gap: 24px; align-items: start; }

.chiffrage-table td input {
    width: 90px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    font-size: 13px;
    text-align: right;
    background: var(--surface);
    color: var(--ink);
}
.chiffrage-table td input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.chiffrage-totaux {
    margin-top: 12px;
    border-top: 2px solid var(--accent);
    padding-top: 10px;
    font-size: 14px;
}

.chiffrage-totaux .ligne { display: flex; justify-content: space-between; padding: 3px 0; }
.chiffrage-totaux .ligne.total { font-weight: 800; font-size: 16px; color: var(--ink-strong); }
.chiffrage-totaux .ligne.info { color: var(--muted); }

/* ---------- Login ---------- */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--app-bg) fixed;
    padding: 24px;
}

.login-card {
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(28px) saturate(150%);
    backdrop-filter: blur(28px) saturate(150%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-modal);
    padding: 38px 40px;
    width: min(420px, calc(100vw - 32px));
    box-shadow: var(--shadow-pop);
}

.login-card h1 { margin: 0 0 4px; font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--ink-strong); }
.login-card .sub { color: var(--muted); margin-bottom: 20px; font-size: 13px; }

/* ---------- Divers ---------- */

.flash {
    border-radius: var(--radius);
    padding: 12px 16px;
    margin: 10px 0;
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid transparent;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.flash-success { background: rgba(64, 190, 120, .16); border-color: rgba(64, 190, 120, .35); }
.flash-error { background: rgba(216, 80, 127, .14); border-color: rgba(216, 80, 127, .35); }
.flash-warning { background: rgba(245, 180, 60, .16); border-color: rgba(245, 180, 60, .38); }

.empty-state { color: var(--muted); padding: 36px 0; text-align: center; }

.fiche-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 28px; max-width: 980px; }
.fiche-grid .libelle { color: var(--muted); font-size: 12px; }
.fiche-grid .valeur { font-size: 14px; margin-top: 2px; }

.section-title { font-size: 16px; font-weight: 700; color: var(--ink-strong); margin: 28px 0 10px; }

.actions-chips { display: flex; gap: 6px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
