/* ============================================================
   Pages de connexion Com'Ain — base commune (admin / édition / devis)
   Chaque page choisit son thème via la classe du <body>.
   ============================================================ */
@import url('/fonts/ui/brand.css');

:root{
  --paper:#ffffff; --mist:#f2f4f6; --mist-2:#e3e7eb; --ink:#2a3038; --ink-soft:#6b7280;
  --ease-out:cubic-bezier(.2,.8,.2,1); --ease-spring:cubic-bezier(.34,1.56,.64,1);
}
body.theme-client{ --dark1:#1c2d47; --dark2:#2a3155; --accent:#fe4496; --accent-end:#fe7944; --glow:254,68,150; --halo:254,121,68; --em:#ffb3d0; --err:#c9186d; }
body.theme-admin { --dark1:#2a3155; --dark2:#3d1f45; --accent:#798bf2; --accent-end:#3f56c9; --glow:121,139,242; --halo:254,68,150; --em:#c3ccff; --err:#d9336f; }
body.theme-devis { --dark1:#1f3450; --dark2:#584a7d; --accent:#e6317a; --accent-end:#c41f63; --glow:230,49,122; --halo:230,49,122; --em:#ffc2da; --err:#c41f63; }

@view-transition{ navigation:auto; }

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0; font-family:'Poppins',system-ui,sans-serif; color:var(--ink); background:var(--mist);
  min-height:100vh; display:flex; align-items:center; justify-content:center; padding:32px 20px;
  overflow-x:hidden; position:relative;
}

/* Fond : deux halos qui dérivent lentement */
.bg{ position:fixed; inset:0; z-index:0; pointer-events:none; overflow:hidden; }
.bg i{ position:absolute; border-radius:50%; filter:blur(70px); opacity:.55; }
.bg i:nth-child(1){ width:620px; height:520px; left:-160px; top:-200px; background:rgba(var(--glow),.28); }
.bg i:nth-child(2){ width:560px; height:560px; right:-180px; bottom:-220px; background:rgba(var(--halo),.20); }
.bg i:nth-child(3){ width:260px; height:260px; right:22%; top:12%; background:rgba(var(--glow),.12); }

.stage{
  position:relative; z-index:1; width:100%; max-width:920px;
  display:grid; grid-template-columns:1.05fr 1fr; background:var(--paper);
  border-radius:28px; overflow:hidden;
  box-shadow:0 40px 90px -34px rgba(21,37,56,.42), 0 0 0 1px rgba(21,37,56,.04);
}

/* ---------- Panneau de marque ---------- */
.pitch{
  position:relative; color:#fff; padding:44px 40px; overflow:hidden;
  display:flex; flex-direction:column; justify-content:space-between;
  background:linear-gradient(160deg, var(--dark1) 0%, var(--dark2) 130%);
}
.pitch::before{
  content:''; position:absolute; inset:-20%; pointer-events:none;
  background:
    radial-gradient(320px 260px at 85% 10%, rgba(var(--halo),.32), transparent 65%),
    radial-gradient(260px 220px at 0% 95%, rgba(255,255,255,.08), transparent 60%);
}
.pitch-top, .pitch-foot{ position:relative; }
.pitch .logo{ height:52px; width:auto; display:block; filter:brightness(0) invert(1); opacity:.95; }
.pitch h1{ margin:26px 0 10px; font-family:'Fraunces',serif; font-weight:800; font-size:clamp(26px,3.4vw,33px); line-height:1.14; letter-spacing:-.4px; }
.pitch h1 em{ font-style:italic; font-weight:700; color:var(--em); }
.pitch p{ margin:0; max-width:310px; font-size:13.5px; font-weight:300; line-height:1.6; color:rgba(255,255,255,.74); }

.preview{
  margin-top:30px; background:rgba(255,255,255,.07); border:1px solid rgba(255,255,255,.14);
  border-radius:16px; padding:14px 18px; backdrop-filter:blur(3px);
}
.preview .row{ display:flex; align-items:center; gap:10px; font-size:12.5px; padding:8px 0; color:rgba(255,255,255,.86); }
.preview .row + .row{ border-top:1px dashed rgba(255,255,255,.16); }
.preview .ico{ width:28px; height:28px; border-radius:9px; background:rgba(255,255,255,.12); display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.preview .ico svg{ width:15px; height:15px; stroke:#fff; fill:none; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.preview .val{ margin-left:auto; font-weight:700; color:#fff; }
.preview .total{ display:flex; justify-content:space-between; align-items:baseline; padding-top:10px; margin-top:4px; border-top:1px solid rgba(255,255,255,.22); }
.preview .total small{ font-size:11px; color:rgba(255,255,255,.6); text-transform:uppercase; letter-spacing:.5px; }
.preview .total b{ font-family:'Fraunces',serif; font-size:22px; }
.pitch-foot{ margin-top:28px; font-size:11px; color:rgba(255,255,255,.55); line-height:1.5; display:flex; align-items:center; gap:8px; }
.pitch-foot svg{ width:14px; height:14px; stroke:currentColor; fill:none; stroke-width:2; flex-shrink:0; }

/* ---------- Formulaire ---------- */
.auth{ padding:50px 42px; display:flex; flex-direction:column; justify-content:center; }
.auth h2{ margin:0 0 8px; font-family:'Fraunces',serif; font-weight:800; font-size:27px; color:var(--dark1); letter-spacing:-.3px; }
.auth .lead{ margin:0 0 28px; font-size:13.5px; color:var(--ink-soft); line-height:1.55; }

.field + .field{ margin-top:16px; }
.field label{ display:block; font-size:12px; font-weight:600; color:var(--ink-soft); margin:0 0 6px; }
.control{ position:relative; }
.control > svg{
  position:absolute; left:14px; top:50%; width:17px; height:17px; transform:translateY(-50%);
  stroke:#9aa1ab; fill:none; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round;
  transition:stroke .2s ease; pointer-events:none;
}
.control input{
  width:100%; padding:13px 46px 13px 42px; border:1.5px solid var(--mist-2); border-radius:13px;
  background:var(--mist); color:var(--ink); font:inherit; font-size:14px;
  transition:border-color .2s ease, background .2s ease, box-shadow .25s var(--ease-out);
}
.control input:hover{ border-color:#d3d8de; }
.control input:focus{ outline:none; border-color:var(--accent); background:#fff; box-shadow:0 0 0 4px rgba(var(--glow),.15); }
.control:focus-within > svg{ stroke:var(--accent); }
.control input[aria-invalid="true"]{ border-color:var(--err); }

.pw-toggle{
  position:absolute; top:50%; right:6px; transform:translateY(-50%); width:36px; height:36px;
  display:flex; align-items:center; justify-content:center; background:none; border:none;
  border-radius:10px; cursor:pointer; color:#8b929c; transition:background .15s ease, color .15s ease;
}
.pw-toggle:hover{ background:var(--mist-2); color:var(--ink); }
.pw-toggle:focus-visible{ outline:2px solid var(--accent); outline-offset:1px; }
.pw-toggle svg{ width:18px; height:18px; stroke:currentColor; fill:none; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.pw-toggle .eye-off{ display:none; }
.pw-toggle[aria-pressed="true"] .eye{ display:none; }
.pw-toggle[aria-pressed="true"] .eye-off{ display:block; }

.caps{
  display:flex; align-items:center; gap:6px; margin-top:7px; font-size:11.5px; font-weight:600; color:#8a5a1e;
  max-height:0; opacity:0; overflow:hidden; transition:max-height .25s var(--ease-out), opacity .2s ease;
}
.caps.show{ max-height:24px; opacity:1; }

.submit{
  position:relative; width:100%; margin-top:26px; height:50px; border:none; border-radius:999px;
  color:#fff; font:600 14.5px 'Poppins',sans-serif; cursor:pointer; overflow:hidden;
  background:linear-gradient(100deg, var(--accent), var(--accent-end));
  box-shadow:0 14px 30px -12px rgba(var(--glow),.6);
  transition:transform .15s var(--ease-out), box-shadow .2s ease, filter .2s ease, width .3s var(--ease-out);
}
.submit::after{ /* reflet au survol */
  content:''; position:absolute; top:0; left:-60%; width:40%; height:100%; transform:skewX(-20deg);
  background:linear-gradient(90deg, transparent, rgba(255,255,255,.28), transparent); transition:left .6s ease;
}
.submit:hover{ filter:brightness(1.04); box-shadow:0 18px 36px -12px rgba(var(--glow),.7); }
.submit:hover::after{ left:120%; }
.submit:active{ transform:translateY(1px) scale(.995); }
.submit:focus-visible{ outline:3px solid rgba(var(--glow),.45); outline-offset:3px; }
.submit .label, .submit .spin, .submit .check{ position:absolute; inset:0; display:flex; align-items:center; justify-content:center; gap:8px; transition:opacity .2s ease, transform .3s var(--ease-out); }
.submit .label svg{ width:16px; height:16px; stroke:#fff; fill:none; stroke-width:2.2; transition:transform .2s ease; }
.submit:hover .label svg{ transform:translateX(3px); }
.submit .spin, .submit .check{ opacity:0; transform:scale(.6); }
.submit .spin i{ width:20px; height:20px; border-radius:50%; border:2.5px solid rgba(255,255,255,.35); border-top-color:#fff; animation:spin .7s linear infinite; }
.submit .check svg{ width:22px; height:22px; stroke:#fff; fill:none; stroke-width:3; stroke-linecap:round; stroke-linejoin:round; stroke-dasharray:30; stroke-dashoffset:30; }
.submit.loading{ cursor:progress; }
.submit.loading .label, .submit.success .label{ opacity:0; transform:translateY(-8px); }
.submit.loading .spin{ opacity:1; transform:none; }
.submit.success{ background:linear-gradient(100deg,#2fa876,#46c393); box-shadow:0 14px 30px -12px rgba(47,168,118,.6); }
.submit.success .check{ opacity:1; transform:none; }
.submit.success .check svg{ animation:draw .45s .05s var(--ease-out) forwards; }

.error{
  display:flex; align-items:flex-start; gap:8px; margin-top:14px; font-size:12.5px; font-weight:600; color:var(--err);
  line-height:1.45; min-height:0; opacity:0; transform:translateY(-4px); transition:opacity .2s ease, transform .25s var(--ease-out);
}
.error.show{ opacity:1; transform:none; }
.error svg{ width:16px; height:16px; flex-shrink:0; stroke:currentColor; fill:none; stroke-width:2; margin-top:1px; }

.auth-foot{ margin-top:24px; font-size:11.5px; color:var(--ink-soft); text-align:center; }
.auth-foot a{ color:var(--dark1); text-decoration:none; font-weight:600; border-bottom:1px solid transparent; transition:border-color .15s ease; }
.auth-foot a:hover{ border-color:currentColor; }

.sr-only{ position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

/* ---------- Mouvements ---------- */
@keyframes spin{ to{ transform:rotate(360deg); } }
@keyframes draw{ to{ stroke-dashoffset:0; } }
@keyframes rise{ from{ opacity:0; transform:translateY(18px) scale(.985); } to{ opacity:1; transform:none; } }
@keyframes fadeUp{ from{ opacity:0; transform:translateY(10px); } to{ opacity:1; transform:none; } }
@keyframes drift1{ 50%{ transform:translate(60px,40px) scale(1.08); } }
@keyframes drift2{ 50%{ transform:translate(-50px,-30px) scale(1.05); } }
@keyframes shake{ 10%,90%{ transform:translateX(-1px); } 20%,80%{ transform:translateX(3px); } 30%,50%,70%{ transform:translateX(-6px); } 40%,60%{ transform:translateX(6px); } }
@keyframes leave{ to{ opacity:0; transform:translateY(-14px) scale(.97); filter:blur(4px); } }

@media (prefers-reduced-motion:no-preference){
  .stage{ animation:rise .65s var(--ease-out) both; }
  .pitch .logo, .pitch h1, .pitch p, .preview, .pitch-foot,
  .auth h2, .auth .lead, .field, .submit, .auth-foot{ animation:fadeUp .55s var(--ease-out) both; }
  .pitch .logo{ animation-delay:.12s; } .pitch h1{ animation-delay:.18s; } .pitch p{ animation-delay:.24s; }
  .preview{ animation-delay:.32s; } .pitch-foot{ animation-delay:.42s; }
  .auth h2{ animation-delay:.16s; } .auth .lead{ animation-delay:.22s; }
  .field:nth-of-type(1){ animation-delay:.28s; } .field:nth-of-type(2){ animation-delay:.34s; }
  .submit{ animation-delay:.4s; } .auth-foot{ animation-delay:.48s; }
  .preview .row{ animation:fadeUp .45s var(--ease-out) both; }
  .preview .row:nth-child(1){ animation-delay:.42s; } .preview .row:nth-child(2){ animation-delay:.5s; }
  .preview .row:nth-child(3){ animation-delay:.58s; } .preview .row:nth-child(4){ animation-delay:.66s; }
  .bg i:nth-child(1){ animation:drift1 18s ease-in-out infinite; }
  .bg i:nth-child(2){ animation:drift2 22s ease-in-out infinite; }
  .bg i:nth-child(3){ animation:drift2 15s ease-in-out infinite reverse; }
  form.shake{ animation:shake .45s ease both; }
  body.leaving .stage{ animation:leave .45s var(--ease-out) forwards; }
}

/* ---------- Mobile ---------- */
@media (max-width:820px){
  body{ align-items:flex-start; padding:16px; }
  .stage{ grid-template-columns:1fr; max-width:460px; border-radius:24px; }
  .pitch{ padding:30px 26px; }
  .pitch p{ max-width:none; }
  .preview{ margin-top:20px; }
  .pitch-foot{ display:none; }
  .auth{ padding:32px 26px 36px; }
}
@media (max-width:380px){ .preview{ display:none; } }

/* ---------- Mobile : page entière, sans défiler ----------
   Sur téléphone, on garde l'essentiel (logo, accroche, formulaire) et on resserre tout pour
   que la page tienne dans la hauteur visible, même sur un petit écran (iPhone SE ≈ 550 px utiles). */
@media (max-width:820px){
  html, body{ height:100%; }
  body{ min-height:100dvh; height:100dvh; padding:12px; align-items:center; overflow:hidden; }
  .stage{ max-height:calc(100dvh - 24px); border-radius:22px; }
  .pitch{ padding:18px 22px 16px; flex-direction:row; align-items:center; }
  .pitch-top{ display:flex; align-items:center; gap:14px; }
  .pitch .logo{ height:30px; flex:none; }
  .pitch h1{ margin:0; font-size:19px; line-height:1.15; }
  .pitch h1 br{ display:none; }
  .pitch h1 em::before{ content:" "; }
  .pitch p, .preview, .pitch-foot{ display:none; }
  .auth{ padding:20px 22px 18px; justify-content:flex-start; }
  .auth h2{ font-size:22px; margin-bottom:4px; }
  .auth .lead{ margin:0 0 14px; font-size:13px; }
  .field + .field{ margin-top:10px; }
  .field label{ margin-bottom:4px; }
  .control input{ padding:11px 46px 11px 42px; font-size:16px; } /* 16 px : pas de zoom auto sur iPhone */
  .submit{ margin-top:16px; height:48px; }
  .error.show{ margin-top:10px; }
  .error:not(.show){ display:none; }
  .auth-foot{ margin-top:12px; }
}
@media (max-width:820px) and (max-height:600px){
  .pitch{ padding:12px 18px; }
  .pitch h1{ display:none; }
  .auth .lead{ display:none; }
  .auth h2{ margin-bottom:10px; }
}

/* Page de connexion de l'éditeur : entrée par le portail (« Se connecter avec mon espace Com'Ain »). */
.portal-sso[hidden]{ display:none; }
.portal-sso .submit{ display:block; text-decoration:none; position:relative; }
.portal-note{ margin:16px 0 0; font-size:12px; color:var(--ink-soft); line-height:1.5; text-align:center; }
.local-note{ margin:0 0 18px; font-size:11.5px; color:var(--ink-soft); }
