/* ==========================================================================
   Direction artistique du portail Com'Ain, appliquée à l'éditeur de sites.
   Source : 1. Plateforme Espace Client (src/design/tokens.css, base.css, editor.css).
   Feuille commune : connexion, tableau de bord, éditeur, éditeur React.
   Chargée APRÈS styles.css, AVANT le thème propre à chaque page. Aucune logique.
   Règles : encre #33203B (jamais de noir pur), action rose #D92B83, sélection
   rose de marque #E93E8F, actions en pilule, panneaux 20 px, champs 12 px.
   ========================================================================== */

@import url("/fonts/ui/app.css");

:root {
  color-scheme: light;

  /* Marque */
  --rose: #e93e8f;
  --rose-btn: #d92b83;
  --rose-deep: #c4227a;
  --night: #33203b;
  --night-deep: #1d1220;

  /* Surfaces */
  --bg: #f5f2f7;
  --paper: #ffffff;
  --paper-2: #fbfafc;
  --soft: #f3eff6;
  --soft-2: #e9e3ee;
  --line: rgba(51, 32, 59, 0.09);
  --line-2: rgba(51, 32, 59, 0.16);
  --line-strong: rgba(51, 32, 59, 0.28);
  --scrim: rgba(29, 18, 32, 0.46);

  /* Texte */
  --ink: #33203b;
  --ink-2: #625070;
  --ink-3: #7a6b86;
  --ink-4: #a598ae;

  /* Actions */
  --btn-bg: var(--rose-btn);
  --btn-bg-hover: var(--rose-deep);
  --btn-ink: #ffffff;
  --btn-shadow: 0 10px 22px -12px rgba(217, 43, 131, 0.7);

  /* États */
  --ok-ink: #1b6b45; --ok-bg: #e3f4ea;
  --warn-ink: #8a4b00; --warn-bg: #fff0d9;
  --err-ink: #b3261e; --err-bg: #fdecea;
  --info-ink: #2f5a8c; --info-bg: #e8eff7;

  /* Rayons */
  --r-xs: 8px; --r-sm: 12px; --r: 16px; --r-lg: 20px; --r-xl: 28px; --r-pill: 999px;

  /* Ombres teintées aubergine */
  --sh-1: 0 1px 2px rgba(51, 32, 59, 0.05), 0 8px 24px -16px rgba(51, 32, 59, 0.22);
  --sh-2: 0 2px 6px rgba(51, 32, 59, 0.06), 0 24px 56px -28px rgba(51, 32, 59, 0.36);
  --sh-3: 0 30px 80px -30px rgba(29, 18, 32, 0.55);

  /* Typographie */
  --f-disp: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Figtree", "Segoe UI", system-ui, sans-serif;

  /* Mouvement */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 160ms;
  --t: 260ms;

  /* Accent de l'espace « Mon site » (bandeau, onglet actif, focus, icônes) */
  --acc: #2f5a8c;
  --acc-ink: #2f5a8c;
  --acc-bg: #e8eff7;

  /* Correspondance avec les variables historiques de styles.css */
  --cream: var(--bg);
  --peach: var(--soft);
  --lilac: var(--soft);
  --white: var(--paper);
  --ink-soft: var(--ink-3);
  --pink: var(--rose-btn);
  --orange: var(--rose-deep);
  --violet: var(--acc);
  --dark: var(--night-deep);
  --panel: var(--paper);
  --border: var(--line);
  --accent: var(--rose-btn);
  --warn: var(--rose-btn);
  --radius: var(--r-lg);
  --shadow: var(--sh-2);
  --font-display: var(--f-disp);
  --font-body: var(--f-body);
  --grad: var(--rose-btn);
  --grad-v: var(--rose-btn);
}

/* Mode nuit : activé par data-theme="dark" sur <html> (aucune bascule n'existe encore dans l'éditeur). */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #130d17; --paper: #1b1321; --paper-2: #1f1626; --soft: #251b2d; --soft-2: #2f2439;
  --line: rgba(255, 255, 255, 0.075); --line-2: rgba(255, 255, 255, 0.13); --line-strong: rgba(255, 255, 255, 0.24);
  --scrim: rgba(6, 3, 8, 0.62);
  --ink: #f5eff8; --ink-2: #cbbfd5; --ink-3: #a797b3; --ink-4: #75667f;
  --btn-bg-hover: #e6489a;
  --ok-ink: #7fd9a8; --ok-bg: rgba(78, 200, 140, 0.13);
  --warn-ink: #ffc56e; --warn-bg: rgba(255, 170, 60, 0.13);
  --err-ink: #ff9a90; --err-bg: rgba(255, 100, 90, 0.13);
  --info-ink: #9cc0ef; --info-bg: rgba(120, 170, 240, 0.13);
  --acc-ink: #93b8ec; --acc-bg: rgba(147, 184, 236, 0.12);
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 30px -18px rgba(0, 0, 0, 0.7);
  --sh-2: 0 2px 6px rgba(0, 0, 0, 0.35), 0 26px 60px -28px rgba(0, 0, 0, 0.8);
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--f-disp); font-weight: 700; letter-spacing: -0.02em; line-height: 1.12; color: var(--ink); }
::selection { background: var(--rose); color: #fff; }
:focus-visible { outline: 3px solid var(--acc-ink); outline-offset: 2px; }
.muted { color: var(--ink-3); font-size: 0.9rem; line-height: 1.55; }
.error { color: var(--err-ink); font-weight: 600; }
hr { border: 0; border-top: 1px solid var(--line); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: var(--r-pill); border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); background-clip: content-box; border: 2px solid transparent; }

/* ---------- Barre haute : blanche, pilules ---------- */
.topbar {
  background: var(--paper); color: var(--ink);
  border-bottom: 1px solid var(--line); box-shadow: 0 6px 20px -16px rgba(51, 32, 59, 0.35);
}
.topbar h1, .topbar .muted { color: var(--ink-2); }
.brand { text-decoration: none; }
.brand small {
  font: 600 0.78rem/1 var(--f-body); color: var(--ink-3); letter-spacing: 0;
  background: var(--soft); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 6px 12px;
}

/* ---------- Boutons : pilule, rose d'action ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 18px; border-radius: var(--r-pill); border: 1px solid transparent;
  background: var(--btn-bg); color: var(--btn-ink); box-shadow: var(--btn-shadow); filter: none;
  font-family: var(--f-body); font-weight: 700; font-size: 0.9rem; line-height: 1.1; text-decoration: none; cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.btn:hover { background: var(--btn-bg-hover); filter: none; box-shadow: var(--btn-shadow); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--paper); color: var(--ink); border: 1px solid var(--line-2); box-shadow: none; }
.btn.secondary:hover { background: var(--soft); border-color: var(--line-strong); }
.btn.danger { background: var(--paper); color: var(--err-ink); border: 1px solid color-mix(in srgb, var(--err-ink) 30%, transparent); box-shadow: none; }
.btn.danger:hover { background: var(--err-bg); }
.btn.secondary.active, .btn.secondary.active:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; filter: none; transform: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; flex: none;
  border-radius: 50%; border: 1px solid var(--line); background: var(--paper); color: var(--ink-2);
  font-size: 1rem; line-height: 1; cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover:not(:disabled) { background: var(--soft); border-color: var(--line-strong); color: var(--ink); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn svg, .btn svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Champs : 12 px ---------- */
label { font-size: 0.84rem; font-weight: 600; color: var(--ink-2); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 14px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--paper); color: var(--ink);
  font-family: var(--f-body); font-size: 0.95rem;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
textarea { line-height: 1.45; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--ink-4); }
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { outline: none; background: var(--paper); border-color: var(--acc-ink); box-shadow: 0 0 0 4px var(--acc-bg); }
select { appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m1 1.5 5 5 5-5' fill='none' stroke='%237a6b86' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
input[type="file"] { font-size: 0.85rem; color: var(--ink-3); min-height: 0; padding: 8px; border-style: dashed; background: var(--soft); }
input[type="file"]::file-selector-button {
  margin-right: 10px; padding: 7px 14px; border: 1px solid var(--line-2); border-radius: var(--r-pill);
  background: var(--paper); color: var(--ink); font: 700 0.84rem var(--f-body); cursor: pointer;
}
input[type="color"] { width: 44px; height: 40px; min-height: 0; padding: 3px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--paper); cursor: pointer; }
input[type="range"] { accent-color: var(--rose-btn); min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; }
input[type="range"]:focus { box-shadow: none; background: none; }

/* ---------- Cartes et panneaux : 20 px ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: 28px; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); }
th { font-family: var(--f-body); font-weight: 700; font-size: 0.8rem; color: var(--ink-3); }

/* ---------- Puces d'état : un point, jamais la couleur seule ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--r-pill); font-size: 0.78rem; font-weight: 700; background: var(--soft); color: var(--ink-2); }
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill.danger { background: var(--err-bg); color: var(--err-ink); }

/* ---------- Fenêtres : 20 px, voile aubergine ---------- */
.modal-backdrop { background: var(--scrim); backdrop-filter: blur(4px); }
.modal {
  background: var(--paper); color: var(--ink); border-radius: var(--r-lg); border: 1px solid var(--line);
  box-shadow: var(--sh-3); padding: clamp(22px, 3vw, 30px); animation: portalPop 320ms var(--ease) both;
}
.modal h2 { margin: 0 0 8px; font-family: var(--f-disp); font-weight: 700; font-size: 1.45rem; letter-spacing: -0.02em; }
.modal label { display: block; margin: 16px 0 6px; font-size: 0.84rem; font-weight: 600; color: var(--ink-2); }
@keyframes portalPop { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }

/* ---------- Notifications ---------- */
.toast { background: var(--night); color: #fff; border-radius: var(--r); box-shadow: var(--sh-2); font-weight: 600; }
.toast.success { background: var(--ok-ink); }
.toast.error { background: var(--err-ink); }

/* ---------- Mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}

/* ==========================================================================
   Connexion (index.html uniquement : les pages admin et devis gardent leur thème)
   ========================================================================== */
body.theme-client {
  --dark1: var(--night); --dark2: #4b2a5f; --accent: var(--rose-btn); --accent-end: var(--rose-deep);
  --glow: 233, 62, 143; --halo: 233, 62, 143; --em: #ffb3d6; --err: var(--err-ink);
  --mist: var(--bg); --mist-2: var(--soft-2); --ink-soft: var(--ink-3);
  font-family: var(--f-body); background: var(--bg); color: var(--ink);
}
body.theme-client .bg i { filter: blur(80px); opacity: 0.5; }
body.theme-client .stage { border-radius: var(--r-xl); box-shadow: var(--sh-3); border: 1px solid var(--line); background: var(--paper); }
body.theme-client .pitch { background: linear-gradient(135deg, var(--night) 0%, #4b2a5f 100%); }
body.theme-client .pitch::before {
  background: radial-gradient(320px 260px at 90% 8%, rgba(233, 62, 143, 0.38), transparent 65%), radial-gradient(260px 220px at 0% 100%, rgba(255, 255, 255, 0.07), transparent 60%);
}
body.theme-client { --acc-ink: var(--rose-deep); --acc-bg: #fde3f0; }
body.theme-client .pitch h1 { color: #fff; font-family: var(--f-disp); font-weight: 800; letter-spacing: -0.03em; }
body.theme-client .pitch h1 em { font-style: normal; font-weight: 800; color: var(--em); }
body.theme-client .pitch p { font-weight: 400; }
body.theme-client .preview { border-radius: var(--r); background: rgba(255, 255, 255, 0.08); }
body.theme-client .auth h2 { font-family: var(--f-disp); font-weight: 700; font-size: 1.7rem; letter-spacing: -0.02em; color: var(--ink); }
body.theme-client .auth .lead { color: var(--ink-3); font-size: 0.95rem; }
body.theme-client .field label { font-size: 0.84rem; font-weight: 600; color: var(--ink-2); }
body.theme-client .control input { border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--paper); color: var(--ink); font-family: var(--f-body); }
body.theme-client .control input:focus { border-color: var(--acc-ink); box-shadow: 0 0 0 4px var(--acc-bg); }
body.theme-client .control:focus-within > svg { stroke: var(--acc-ink); }
body.theme-client .pw-toggle { border-radius: 50%; }
body.theme-client .submit {
  background: var(--btn-bg); border-radius: var(--r-pill); font-family: var(--f-body); font-weight: 700; box-shadow: var(--btn-shadow);
}
body.theme-client .submit:hover { background: var(--btn-bg-hover); filter: none; box-shadow: var(--btn-shadow); }
body.theme-client .submit.success { background: var(--ok-ink); box-shadow: none; }
body.theme-client .error { background: var(--err-bg); color: var(--err-ink); border-radius: var(--r-sm); }
body.theme-client .auth-foot { color: var(--ink-3); }
body.theme-client .auth-foot a { color: var(--ink); }

/* ---------- Retour au portail client (visible seulement pour une session venue de espace.comain.fr) ---------- */
.portal-pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none;
  font: 600 0.82rem/1 var(--f-body); color: var(--ink-2);
  background: var(--soft); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 9px 14px;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.portal-pill:hover { background: var(--paper); border-color: var(--line-strong); }
.portal-pill:focus-visible { outline: 2px solid var(--rose-btn); outline-offset: 2px; }
.portal-pill[hidden] { display: none; }
