/* ==========================================================
   Devica — styles globaux
   ========================================================== */

:root {
  --color-bg: #f7f9fc;
  --color-surface: #ffffff;
  --color-text: #0b1b3a;
  --color-text-muted: #6b7489;
  --color-text-soft: #4a5368;
  --color-border: #dde3ec;
  --color-border-strong: #c3ccd9;
  --color-primary: #0a7aff;
  --color-primary-hover: #0066e0;
  --color-primary-soft: rgba(10, 122, 255, 0.14);
  --color-danger: #d92d20;
  --color-danger-bg: #fef3f2;
  --color-danger-border: #fecdca;

  --radius: 8px;
  --field-height: 50px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Liens ---------- */

.link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
  border-radius: 4px;
}

.link:hover {
  text-decoration: underline;
}

.link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.link--strong {
  font-weight: 600;
}

/* ---------- Page d'authentification ---------- */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(32px, env(safe-area-inset-top)) 20px max(32px, env(safe-area-inset-bottom));
}

.auth {
  width: 100%;
  max-width: 400px;
}

.auth__brand {
  text-align: center;
  margin-bottom: 40px;
}

.auth__logo {
  display: block;
  width: auto;
  height: 96px;
  margin: 0 auto 14px;
}

.auth__title {
  margin: 0;
  font-size: 40px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.auth__tagline {
  margin: 10px 0 0;
  font-size: 17px;
  color: var(--color-text-muted);
}

.auth__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 14px;
  font-size: 14px;
}

.auth__footer {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: 15px;
  color: var(--color-text-muted);
}

.auth__footer .link {
  margin-left: 4px;
}

/* ---------- Champs ---------- */

.field {
  position: relative;
  display: block;
}

.field__icon {
  position: absolute;
  left: 16px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--color-text-soft);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.field input {
  width: 100%;
  height: var(--field-height);
  padding: 0 16px 0 48px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 16px; /* 16px évite le zoom automatique sur iOS */
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input::placeholder {
  color: #7d8599;
}

.field input:hover {
  border-color: var(--color-border-strong);
}

.field input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.field input[aria-invalid="true"] {
  border-color: var(--color-danger);
}

.field input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.14);
}

.field:has(.field__action) input {
  padding-right: 52px;
}

.field__action {
  position: absolute;
  right: 6px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-soft);
  cursor: pointer;
}

.field__action:hover {
  background: var(--color-bg);
}

.field__action:focus-visible {
  outline: 2px solid var(--color-primary);
}

.field__action svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.field__action .eye-open,
.field__action[aria-pressed="true"] .eye-closed {
  display: none;
}

.field__action[aria-pressed="true"] .eye-open {
  display: block;
}

/* ---------- Lignes de champs ---------- */

.auth__row--end {
  justify-content: flex-end;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field__hint {
  margin: -4px 0 0 2px;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ---------- Message de succès ---------- */

.success {
  text-align: center;
}

.success__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.success__icon svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.success__title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
}

.success__text {
  margin: 0 0 24px;
  color: var(--color-text-muted);
}

.success__icon--danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.success .btn {
  text-decoration: none;
}

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

.auth__submit {
  margin-top: 10px;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--field-height);
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  /* Un bouton peut être un lien : il ne doit pas en porter le soulignement. */
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

.btn:active:not(:disabled) {
  transform: scale(0.99);
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

.btn--primary {
  width: 100%;
  background: var(--color-primary);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn:disabled {
  cursor: default;
  opacity: 0.85;
}

.spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn.is-loading .btn__label {
  visibility: hidden;
}

.btn.is-loading .spinner {
  display: block;
  position: absolute;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Alertes ---------- */

.alert {
  padding: 12px 14px;
  border: 1px solid var(--color-danger-border);
  border-radius: var(--radius);
  background: var(--color-danger-bg);
  color: var(--color-danger);
  font-size: 14px;
}

.alert--success {
  border-color: #abefc6;
  background: #ecfdf3;
  color: #067647;
}

/* ---------- Mobile ---------- */

@media (max-width: 480px) {
  .auth__brand {
    margin-bottom: 32px;
  }

  .auth__logo {
    height: 84px;
  }

  .auth__title {
    font-size: 34px;
  }

  .auth__tagline {
    font-size: 16px;
  }

  .auth__tagline span {
    display: block;
  }

  .auth__row {
    font-size: 13px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .auth__footer {
    border-top: 0;
    padding-top: 0;
  }

  .auth__footer .link {
    display: block;
    margin: 4px 0 0;
  }
}

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

/* ==========================================================
   Menu déroulant de la langue (site vitrine, app, connexion)
   Le <select> natif est transparent par-dessus : on garde le
   sélecteur du système sur téléphone sans perdre le style.
   ========================================================== */

.lang-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--color-border);
  border-radius: 9px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 14.5px;
  font-weight: 500;
}

.lang-picker .icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.lang-picker__value {
  white-space: nowrap;
}

.lang-picker__chevron {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* Le vrai champ : invisible, mais c'est lui qui reçoit le clic et le focus. */
.lang-picker__select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  font: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.lang-picker:hover {
  border-color: #c7d2e4;
}

.lang-picker:has(.lang-picker__select:focus-visible) {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.lang-picker--compact {
  gap: 4px;
  height: 36px;
  padding: 0 6px 0 8px;
  font-size: 13.5px;
  font-weight: 600;
}

.lang-picker--compact .icon {
  width: 16px;
  height: 16px;
}

/* Menu de langue en haut à droite des pages de connexion. */
.lang-corner {
  position: fixed;
  z-index: 5;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
}
