/* Connexion VisionIA — modèle fenêtre Kommandia */
:root {
  --bg: #e7e2d4;
  --ink: #1c2416;
  --muted: #5e6756;
  --logo: #6818d0;
  --logo-deep: #3d1098;
  --red: #9d342c;
  --sheet: #fff;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body.gate-body {
  min-height: 100%;
  color: var(--ink);
  font-family: Arial, Helvetica, "Segoe UI", sans-serif;
  font-size: 14px;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 255, 255, 0.55), transparent 60%),
    var(--bg);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.gate-stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  padding: 32px 16px;
}

.km-modal-box {
  position: relative;
  z-index: 1;
  background: var(--sheet);
  width: min(440px, calc(100vw - 48px));
  max-height: min(86vh, 860px);
  border-radius: 14px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(28, 36, 22, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.gate-box { width: min(440px, calc(100vw - 48px)); z-index: 1; }
.gate-box[hidden] { display: none !important; }
.gate-box.is-pinned { position: fixed; margin: 0; }
.gate-box .km-modal-header { cursor: grab; }
.gate-box.is-max .km-modal-header,
.gate-box.is-min .km-modal-header { cursor: default; }

.km-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: #f6f3ea;
  border-bottom: 1px solid #e6e0d2;
  user-select: none;
  flex-shrink: 0;
}
.km-modal-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  flex: 1;
  min-width: 0;
}
.km-modal-win {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
  flex-shrink: 0;
}
.km-win {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  box-shadow:
    0 2px 3px rgba(0, 0, 0, 0.28),
    0 1px 0 rgba(255, 255, 255, 0.45) inset,
    0 -1px 1px rgba(0, 0, 0, 0.18) inset;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.km-win:hover { transform: scale(1.1); filter: brightness(1.05); }
.km-win:active { transform: scale(0.96); filter: brightness(0.96); }
.km-win-min {
  background: radial-gradient(120% 90% at 30% 18%, #ffe27a 0%, #ffc53d 38%, #f5a623 72%, #d8890c 100%);
}
.km-win-max {
  background: radial-gradient(120% 90% at 30% 18%, #7dff8f 0%, #3fd65a 38%, #22c53e 72%, #14a32e 100%);
}
.km-win-close {
  background: radial-gradient(120% 90% at 30% 18%, #ff9a93 0%, #ff6b63 38%, #ff3b30 72%, #d92018 100%);
}
.km-win::before {
  content: "";
  position: absolute;
  left: 14%; right: 14%; top: 8%;
  height: 38%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.km-win::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: center / 11px 11px no-repeat;
  pointer-events: none;
}
.km-win-min::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.2 6h7.6' stroke='%231a1a1a' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
}
.km-win-max::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Crect x='2.6' y='2.6' width='6.8' height='6.8' rx='0.6' fill='none' stroke='%23fff' stroke-width='1.7'/%3E%3C/svg%3E");
}
.km-win-max.is-restore::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4.2 2.8h5v5' fill='none' stroke='%23fff' stroke-width='1.5'/%3E%3Crect x='2.4' y='4' width='5.2' height='5.2' rx='0.4' fill='none' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E");
}
.km-win-close::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 3l6 6M9 3L3 9' stroke='%23fff' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}
.km-modal-resize {
  position: absolute;
  right: 0; bottom: 0;
  width: 16px; height: 16px;
  cursor: nwse-resize;
  z-index: 2;
}
.km-modal-resize::after {
  content: "";
  position: absolute;
  right: 4px; bottom: 4px;
  width: 8px; height: 8px;
  border-right: 2px solid #b7b09e;
  border-bottom: 2px solid #b7b09e;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px 28px 26px;
  width: 100%;
  min-width: 0;
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.gate-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 8px;
}
.gate-mark {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  background: linear-gradient(145deg, #c084fc, #6818d0 55%, #3d1098);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.2), 0 8px 18px rgba(104, 24, 208, 0.28);
  position: relative;
}
.gate-mark::after {
  content: "";
  position: absolute; inset: 10px;
  border: 2px solid rgba(255,255,255,0.9);
  border-radius: 6px;
  clip-path: polygon(20% 0, 100% 0, 100% 80%, 80% 100%, 0 100%, 0 20%);
}
.gate-brand-name {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.gate-brand-name span { color: var(--logo); }
.gate-form > p { margin: 0; color: var(--muted); line-height: 1.45; }
.gate-error { margin: 0; color: var(--red); font-weight: 600; }

label.fld {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.03em;
}
label.fld input {
  border: 1px solid #cfcab8;
  background: #f7f9fc;
  padding: 10px 12px;
  border-radius: 8px;
  width: 100%;
  min-width: 0;
  color: var(--ink);
}
label.fld input:focus {
  outline: none;
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(104, 24, 208, 0.12);
  background: #fff;
}

.pass-wrap { position: relative; display: block; }
.pass-wrap input { width: 100%; padding-right: 40px; }
.pass-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #6b6558;
  padding: 4px;
  display: flex;
  border-radius: 6px;
}
.pass-eye:hover { color: var(--ink); background: #f4f1e6; }
.pass-eye .eye-off { display: none; }
.pass-eye.is-on .eye-on { display: none; }
.pass-eye.is-on .eye-off { display: block; }

.btn {
  border: 1px solid #b7b39a;
  background: #fff;
  padding: 7px 11px;
  font-size: 13px;
  border-radius: 3px;
}
.btn-primary {
  background: linear-gradient(180deg, #7c32e0, var(--logo));
  border-color: var(--logo-deep);
  color: white;
  font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.08); }
.gate-form .btn { align-self: flex-start; margin-top: 6px; padding: 10px 18px; }

.gate-box.is-max {
  position: fixed;
  inset: 12px;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  z-index: 20;
}
.gate-box.is-max .gate-form {
  flex: 1;
  justify-content: center;
  width: min(480px, 100%);
  margin-inline: auto;
}
.gate-box.is-max .km-modal-header { padding-right: 72px; }
.gate-box.is-max .km-modal-resize { display: none; }
.gate-box.is-min {
  position: fixed;
  left: 18px;
  bottom: 70px;
  width: auto;
  height: auto;
  max-height: none;
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}
.gate-box.is-min .gate-form,
.gate-box.is-min .km-modal-resize { display: none; }
.gate-box.is-min .km-modal-header {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
}

.gate-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}
.gate-hero[hidden] { display: none !important; }
.gate-hero .gate-mark { width: 72px; height: 72px; border-radius: 18px; }
.gate-hero .gate-mark::after { inset: 18px; }
.gate-hero .gate-brand-name { font-size: 2rem; }
.gate-hero .btn { padding: 12px 26px; font-size: 16px; }

/* —— TempIA : palette + clair / sombre —— */
body.gate-body {
  --bg: #050811;
  --ink: #e8eef8;
  --muted: #94a3b8;
  --logo: #a78bfa;
  --logo-deep: #7c3aed;
  --red: #f87171;
  --sheet: #12182a;
  --header: #0b1224;
  --line: rgba(167, 139, 250, 0.22);
  background:
    radial-gradient(900px 500px at 70% 18%, rgba(167,139,250,0.22), transparent 52%),
    radial-gradient(800px 480px at 25% 85%, rgba(139,92,246,0.14), transparent 55%),
    var(--bg);
  color: var(--ink);
}
html[data-theme="light"] body.gate-body {
  --bg: #f4f1fb;
  --ink: #122033;
  --muted: #5b6b82;
  --sheet: #ffffff;
  --header: #f3eefc;
  --line: #e4dcf6;
  --red: #b91c1c;
  background:
    radial-gradient(900px 500px at 70% 18%, rgba(167,139,250,0.18), transparent 52%),
    var(--bg);
}
.km-modal-box {
  background: var(--sheet);
  color: var(--ink);
  box-shadow: 0 24px 48px rgba(0,0,0,0.28), 0 0 0 1px var(--line);
}
.km-modal-header {
  background: var(--header);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
label.fld input {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--ink);
}
html[data-theme="light"] label.fld input {
  background: #f7f9fc;
}
.pass-eye { color: var(--muted); }
html[data-theme="light"] .pass-eye:hover { background: #efe9fb; color: var(--ink); }
.gate-box.is-min .km-modal-header {
  background: var(--sheet);
}
.btn-primary {
  background: linear-gradient(135deg, #c4b5fd, #a78bfa 40%, #8b5cf6);
  border-color: var(--logo-deep);
}
.gate-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 4px 0 8px;
}
.gate-brand-logo {
  display: block;
  height: 84px;
  width: auto;
  margin: 0 auto;
}
.gate-brand-logo--light { display: none; height: 78px; }
html[data-theme="light"] .gate-brand-logo--dark { display: none; }
html[data-theme="light"] .gate-brand-logo--light { display: block; }
.gate-foot {
  margin: 4px 0 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.gate-brand-name {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.gate-brand-name span { color: var(--logo); }
.gate-hero-logo {
  height: 120px;
  width: auto;
}
.gate-hero .gate-brand-logo--dark { display: block; height: 120px; }
.gate-hero .gate-brand-logo--light { display: none; height: 64px; }
html[data-theme="light"] .gate-hero .gate-brand-logo--dark { display: none; }
html[data-theme="light"] .gate-hero .gate-brand-logo--light { display: block; }
.gate-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 4px;
}
.gate-link:hover { color: var(--ink); }
.gate-error-box {
  margin: 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.35);
  border-radius: 8px;
  padding: 8px 10px;
}
.gate-form .btn-block {
  align-self: stretch;
  width: 100%;
  text-align: center;
  border-radius: 10px;
  padding: 12px 18px;
}
