/* Thèmes de l'application.
   - Classique : l'apparence d'origine (styles.css, data-theme="light" / "dark"), conservée telle quelle.
   - Famille « moderne » : Lumen (clair) / Nocturne (sombre), Lagon (clair) / Lagon sombre.
   Chaque thème ne fait que redéfinir des variables ; la finition commune est portée par
   [data-theme-family="moderne"]. Le choix est fait par le sélecteur ◐ (app.js, THEME_CATALOG). */

/* Police Inter, hébergée sur le serveur (fonts/, licence OFL 1.1) et réservée à la famille moderne :
   un nom de famille propre évite qu'elle remplace la police du thème Classique. */
@font-face {
  font-display: swap;
  font-family: "Inter Planning";
  font-style: normal;
  font-weight: 100 900;
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ===================================================================== */
/* Sélecteur de thème (raccourci ◐ en haut à droite), valable pour tous */
/* ===================================================================== */
.theme-menu { position: relative; }
.theme-popover { background: var(--surface-raised); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); color: var(--ink); display: grid; gap: 12px; padding: 14px; position: absolute; right: 0; top: calc(100% + 8px); width: 340px; z-index: 120; }
.theme-popover:not([hidden]) { animation: theme-popover-in .16s cubic-bezier(.2, .7, .2, 1); }
@keyframes theme-popover-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.theme-popover-heading { align-items: baseline; display: flex; justify-content: space-between; }
.theme-popover-heading strong { font-size: 14px; }
.theme-popover-heading span { color: var(--muted); font-size: 11px; }
.theme-style-grid { display: grid; gap: 8px; grid-template-columns: repeat(3, 1fr); }
.theme-tile { align-content: start; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; color: var(--ink); display: grid; gap: 3px; padding: 6px 6px 8px; text-align: left; transition: border-color .16s ease, box-shadow .16s ease, transform .12s ease; }
.theme-tile:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.theme-tile.active { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.theme-tile strong { font-size: 12px; margin-top: 4px; }
.theme-tile small { color: var(--muted); font-size: 10px; line-height: 1.25; }
/* Vignette : fond, rail, carte et touche d'accent du thème */
.theme-tile-preview { background: var(--p-bg); border-radius: 7px; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .18); display: block; height: 48px; overflow: hidden; position: relative; }
.theme-tile-preview i { background: var(--p-rail); bottom: 0; left: 0; position: absolute; top: 0; width: 13px; }
.theme-tile-preview b { background: var(--p-surface); border-radius: 4px; bottom: 6px; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); left: 19px; position: absolute; right: 6px; top: 6px; }
.theme-tile-preview em { background: var(--p-brand); border-radius: 3px; height: 7px; left: 25px; position: absolute; top: 13px; width: 26px; }
.theme-tile-preview em::after { background: var(--p-brand); border-radius: 3px; content: ""; height: 11px; left: 0; opacity: .35; position: absolute; top: 12px; width: 44px; }
.theme-appearance { display: grid; grid-template-columns: repeat(3, 1fr); }
.theme-appearance button { justify-content: center; }
.theme-reset { background: transparent; border: 0; color: var(--brand); font-size: 12px; font-weight: 600; justify-self: start; padding: 2px 0; }
.theme-reset:hover { text-decoration: underline; }
@media (max-width: 700px) { .theme-popover { position: fixed; right: 12px; left: 12px; top: calc(var(--topbar-height) + 6px); width: auto; } }

/* ===================================================================== */
/* Lumen : clair premium, net et aéré                                     */
/* ===================================================================== */
[data-theme="lumen"] {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #f2f4f7;
  --surface-hover: #eef0f4;
  --ink: #101828;
  --muted: #535d6e;
  --subtle: #8a93a3;
  --line: #e7e9ee;
  --line-strong: #d5d9e1;
  --brand: #3b5bdb;
  --brand-strong: #2f49c0;
  --brand-soft: #eef2ff;
  --brand-ink: #ffffff;
  --success: #12a36f;
  --danger: #d63c4d;
  --warning: #c27b12;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-soft: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px -8px rgba(16, 24, 40, .10);
  --shadow: 0 2px 6px rgba(16, 24, 40, .06), 0 24px 48px -16px rgba(16, 24, 40, .22);
  --card-shadow: 0 1px 2px rgba(16, 24, 40, .10), 0 4px 10px -4px rgba(16, 24, 40, .22);
  --card-shadow-hover: 0 2px 4px rgba(16, 24, 40, .12), 0 12px 24px -8px rgba(16, 24, 40, .32);
  --rail-bg: #ffffff;
  --rail-ink: #667085;
  --rail-hover: #f2f4f7;
  --rail-active-bg: #eef2ff;
  --rail-active-ink: #3b5bdb;
  --login-brand-bg: #101828;
  --login-brand-glow: rgba(99, 125, 255, .38);
  --tint-scale: .5;
}

/* ===================================================================== */
/* Nocturne : sombre profond (variante sombre de Lumen)                   */
/* ===================================================================== */
[data-theme="nocturne"] {
  color-scheme: dark;
  --bg: #0a0c10;
  --surface: #111419;
  --surface-raised: #171b22;
  --surface-muted: #0e1015;
  --surface-hover: #1d222b;
  --ink: #e8ebf1;
  --muted: #9aa3b3;
  --subtle: #6f7889;
  --line: #1f242d;
  --line-strong: #2b313c;
  --brand: #8b9dff;
  --brand-strong: #a8b6ff;
  --brand-soft: #1b2040;
  --brand-ink: #0a0c10;
  --success: #3ccf95;
  --danger: #ff7a8a;
  --warning: #f0b45a;
  --shadow-xs: 0 1px 0 rgba(255, 255, 255, .03) inset;
  --shadow-soft: 0 0 0 1px rgba(255, 255, 255, .02), 0 12px 32px -12px rgba(0, 0, 0, .6);
  --shadow: 0 0 0 1px rgba(255, 255, 255, .05), 0 28px 60px -18px rgba(0, 0, 0, .78);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 6px 14px -6px rgba(0, 0, 0, .6);
  --card-shadow-hover: 0 2px 4px rgba(0, 0, 0, .5), 0 14px 28px -10px rgba(0, 0, 0, .75);
  --rail-bg: #0a0c10;
  --rail-ink: #7d8696;
  --rail-hover: #171b22;
  --rail-active-bg: #1b2040;
  --rail-active-ink: #a8b6ff;
  --login-brand-bg: #0d1017;
  --login-brand-glow: rgba(139, 157, 255, .30);
  --tint-scale: 1.1;
  --now-color: #ff6b78;
}

/* ===================================================================== */
/* Lagon : tons turquoise, rail sarcelle                                  */
/* ===================================================================== */
[data-theme="lagon"] {
  color-scheme: light;
  --bg: #eef4f3;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #f1f6f5;
  --surface-hover: #e7f0ef;
  --ink: #0f2a2a;
  --muted: #4f6767;
  --subtle: #839797;
  --line: #dfe9e7;
  --line-strong: #c9d8d6;
  --brand: #0b8a8a;
  --brand-strong: #087373;
  --brand-soft: #e2f5f4;
  --brand-ink: #ffffff;
  --success: #179b6e;
  --danger: #cf4458;
  --warning: #b9781a;
  --shadow-xs: 0 1px 2px rgba(10, 50, 50, .06);
  --shadow-soft: 0 1px 2px rgba(10, 50, 50, .05), 0 8px 24px -10px rgba(10, 60, 60, .16);
  --shadow: 0 2px 6px rgba(10, 50, 50, .07), 0 24px 48px -16px rgba(10, 60, 60, .26);
  --card-shadow: 0 1px 2px rgba(10, 50, 50, .10), 0 4px 10px -4px rgba(10, 50, 50, .22);
  --card-shadow-hover: 0 2px 4px rgba(10, 50, 50, .12), 0 12px 24px -8px rgba(10, 50, 50, .30);
  --rail-bg: #0d3b3e;
  --rail-ink: #9cc9c7;
  --rail-hover: rgba(255, 255, 255, .08);
  --rail-active-bg: rgba(51, 204, 204, .18);
  --rail-active-ink: #7fe3e0;
  --login-brand-bg: #0d3b3e;
  --login-brand-glow: rgba(51, 204, 204, .32);
  --tint-scale: .55;
}

/* ===================================================================== */
/* Lagon sombre : profondeurs sarcelle, accent turquoise lumineux         */
/* ===================================================================== */
[data-theme="lagon-sombre"] {
  color-scheme: dark;
  --bg: #061516;
  --surface: #0b1e1f;
  --surface-raised: #10292a;
  --surface-muted: #081a1b;
  --surface-hover: #143233;
  --ink: #e2f2f1;
  --muted: #94b6b4;
  --subtle: #62817f;
  --line: #16302f;
  --line-strong: #21403f;
  --brand: #3fd1cc;
  --brand-strong: #74e1dd;
  --brand-soft: #0e3837;
  --brand-ink: #04191a;
  --success: #45d39f;
  --danger: #ff8193;
  --warning: #f2b75e;
  --shadow-xs: 0 1px 0 rgba(255, 255, 255, .03) inset;
  --shadow-soft: 0 0 0 1px rgba(127, 255, 250, .03), 0 12px 32px -12px rgba(0, 0, 0, .6);
  --shadow: 0 0 0 1px rgba(127, 255, 250, .05), 0 28px 60px -18px rgba(0, 0, 0, .78);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 6px 14px -6px rgba(0, 0, 0, .6);
  --card-shadow-hover: 0 2px 4px rgba(0, 0, 0, .5), 0 14px 28px -10px rgba(0, 0, 0, .75);
  --rail-bg: #041011;
  --rail-ink: #7fb3b0;
  --rail-hover: #0f2627;
  --rail-active-bg: #0e3837;
  --rail-active-ink: #74e1dd;
  --login-brand-bg: #041011;
  --login-brand-glow: rgba(63, 209, 204, .26);
  --tint-scale: 1.1;
  --now-color: #ff7a88;
}

/* ===================================================================== */
/* Finition commune de la famille moderne                                 */
/* ===================================================================== */
[data-theme-family="moderne"] {
  --radius: 12px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font-ui: "Inter Planning", "Segoe UI Variable Text", "Segoe UI Variable", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
[data-theme-family="moderne"] body { letter-spacing: -.003em; }
[data-theme-family="moderne"] :focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[data-theme-family="moderne"] ::selection { background: color-mix(in srgb, var(--brand) 26%, transparent); }

/* Typographie : hiérarchie plus nette, graisses plus légères */
[data-theme-family="moderne"] :is(h1, h2) { font-weight: 700; letter-spacing: -.015em; }
[data-theme-family="moderne"] h3 { font-weight: 650; }
[data-theme-family="moderne"] .eyebrow { font-weight: 700; letter-spacing: .1em; }
[data-theme-family="moderne"] :is(label, .segmented button, .secondary-button, .rail-button small, .selection-toolbar button) { font-weight: 600; }
[data-theme-family="moderne"] .topbar-datetime, [data-theme-family="moderne"] .time-ruler { font-variant-numeric: tabular-nums; }

/* Connexion */
[data-theme-family="moderne"] .login-brand { background: var(--login-brand-bg); }
[data-theme-family="moderne"] .login-brand::before { background: radial-gradient(circle at center, var(--login-brand-glow), transparent 68%); }

/* Rail latéral : suit le thème */
[data-theme-family="moderne"] .side-rail { background: var(--rail-bg); border-right: 1px solid var(--line); color: var(--rail-ink); }
[data-theme="lagon"] .side-rail { border-right-color: transparent; }
[data-theme-family="moderne"] .rail-button { border-radius: 10px; color: var(--rail-ink); transition: background .18s var(--ease), color .18s var(--ease); }
[data-theme-family="moderne"] .rail-button:hover { background: var(--rail-hover); color: var(--rail-active-ink); }
[data-theme-family="moderne"] .rail-button.active { background: var(--rail-active-bg); color: var(--rail-active-ink); }
[data-theme-family="moderne"] .avatar-button { background: var(--brand-soft); box-shadow: 0 0 0 2px var(--rail-bg), 0 0 0 3px color-mix(in srgb, var(--rail-ink) 40%, transparent); color: var(--brand); }
[data-theme="lagon"] .avatar-button { background: #33cccc; color: #0d3b3e; }

/* Barre du haut translucide */
[data-theme-family="moderne"] .topbar { backdrop-filter: saturate(1.6) blur(14px); background: color-mix(in srgb, var(--surface) 84%, transparent); border-bottom-color: var(--line); }

/* Boutons et champs : rayons doux, bordures fines, transitions fluides */
[data-theme-family="moderne"] :is(.primary-button, .secondary-button, .icon-button, .danger-button, input, select, textarea) { border-radius: 9px; transition: background .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease), color .18s var(--ease), transform .12s var(--ease); }
[data-theme-family="moderne"] :is(.primary-button, .secondary-button, .icon-button, .danger-button):active:not(:disabled) { transform: translateY(1px) scale(.99); }
[data-theme-family="moderne"] .primary-button { box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 6px 16px -6px color-mix(in srgb, var(--brand) 70%, transparent); color: var(--brand-ink); font-weight: 600; }
[data-theme-family="moderne"] :is(.secondary-button, .icon-button) { border-color: var(--line); box-shadow: var(--shadow-xs); }
[data-theme-family="moderne"] :is(.secondary-button, .icon-button):hover { border-color: var(--line-strong); }
[data-theme-family="moderne"] :is(input, select, textarea) { border-color: var(--line-strong); }
[data-theme-family="moderne"] :is(input, select, textarea):hover:not(:focus):not(:disabled) { border-color: color-mix(in srgb, var(--brand) 35%, var(--line-strong)); }
[data-theme-family="moderne"] :is(input, select, textarea):focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
[data-theme-family="moderne"] .button-pair .icon-button:first-child { border-radius: 9px 0 0 9px; }
[data-theme-family="moderne"] .button-pair .icon-button:last-child { border-radius: 0 9px 9px 0; }
[data-theme-family="moderne"] .segmented { background: var(--surface-muted); border-color: transparent; border-radius: 10px; }
[data-theme-family="moderne"] .segmented button { border-radius: 8px; transition: color .18s var(--ease), background .18s var(--ease), box-shadow .18s var(--ease); }
[data-theme-family="moderne"] .segmented button:hover:not(.active) { color: var(--ink); }
[data-theme-family="moderne"] .segmented button.active { background: var(--surface-raised); box-shadow: var(--shadow-xs), 0 0 0 1px var(--line); }
[data-theme-family="moderne"] .badge-palette-chip { border-radius: 999px; }

/* Fenêtres, menus et info-bulles */
[data-theme-family="moderne"] .modal { border-color: var(--line); border-radius: 16px; }
[data-theme-family="moderne"] .modal[open] { animation: modal-in .2s var(--ease); }
[data-theme-family="moderne"] .modal::backdrop { background: rgba(8, 12, 20, .42); backdrop-filter: blur(4px); }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(.985); } }
[data-theme-family="moderne"] :is(.account-popover, .planning-tooltip) { border-radius: 12px; }
[data-theme-family="moderne"] .admin-card { border-radius: 14px; }

/* Planning : cadre en carte, grille discrète, colonnes moins saturées */
[data-theme-family="moderne"] .timeline-frame { border-color: var(--line); border-radius: 14px; box-shadow: var(--shadow-soft); }
[data-theme-family="moderne"] .day-banner { background: var(--surface-raised); font-weight: 650; }
[data-theme-family="moderne"] .day-group + .day-group { border-left: 1px solid var(--line-strong); }
/* En-têtes de membres : fond translucide, sauf les en-têtes colorés qui gardent la couleur du membre */
[data-theme-family="moderne"] .member-header { backdrop-filter: blur(8px); border-right-color: var(--line); }
[data-theme-family="moderne"] .member-header:not(.colored-header) { background: color-mix(in srgb, var(--surface) 92%, transparent); }
[data-theme-family="moderne"] .member-column:is(.column-style-soft, .column-style-solid) {
  /* Le réglage d'intensité de l'équipe reste respecté, pondéré par le thème */
  background-color: color-mix(in srgb, var(--member-color) calc(var(--column-color-intensity) * var(--tint-scale)), var(--surface));
}
[data-theme-family="moderne"] .appointment-card { border-radius: 8px; box-shadow: var(--card-shadow); transition: box-shadow .18s var(--ease), transform .18s var(--ease); }
[data-theme-family="moderne"] .appointment-card:hover { box-shadow: var(--card-shadow-hover); transform: translateY(-1px); }
[data-theme-family="moderne"] .appointment-card.dragging { transform: none; }
[data-theme-family="moderne"] .selection-toolbar { border-radius: 14px; box-shadow: var(--shadow); }
[data-theme-family="moderne"] .team-period-indicator button { border-radius: 999px; box-shadow: var(--shadow-soft); }

/* Sombres : un léger relief sur les cartes de rendez-vous */
:is([data-theme="nocturne"], [data-theme="lagon-sombre"]) .appointment-card { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), var(--card-shadow); }

/* Respect du réglage « réduire les animations » de l'ordinateur */
@media (prefers-reduced-motion: reduce) {
  [data-theme-family="moderne"] *, [data-theme-family="moderne"] *::before, [data-theme-family="moderne"] *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
  .theme-popover:not([hidden]) { animation: none; }
}

/* Éléments pleins à la couleur d'accent : texte contrasté, y compris dans les thèmes sombres */
[data-theme-family="moderne"] :is(.creation-time-cell-badge, .badge-drop-preview span, .slot-selection-label,
  .week-shortcut.active, .selection-toolbar button[data-selection-action="paint"].active, .month-day.today .month-number,
  .year-calendar-choice.selected, .title-helper button.active, .expense-dashboard-toolbar [data-new-expense]:hover) { color: var(--brand-ink); }
