/* Auth, dashboard (partagé), modales, profil — sur les tokens Phase G
   (css/tokens.css, chargé avant ce fichier). Plus de palette locale :
   le thème clair/sombre est entièrement piloté par les tokens. */

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

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
}

#app { min-height: 100vh; }

/* ── Page générique ─────────────────────────────────────────────────────────── */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Loading ─────────────────────────────────────────────────────────────────── */
.page--loading {
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Boutons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 140ms, transform 80ms, box-shadow 140ms;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:not(:disabled):active { transform: scale(0.97); }

.btn--primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--color-primary) 25%, transparent);
}
.btn--primary:not(:disabled):hover { background: var(--color-primary-hover); }

.btn--ghost {
  background: color-mix(in srgb, var(--color-primary) 7%, transparent);
  color: var(--color-primary-text);
  border: 1px solid var(--color-border);
}
.btn--ghost:not(:disabled):hover { background: color-mix(in srgb, var(--color-primary) 14%, transparent); }

.btn--danger {
  background: #c0392b;
  color: #fff;
}
.btn--danger:not(:disabled):hover { background: #a93226; }

.btn--full   { width: 100%; }
.btn--sm     { padding: 6px 14px;  font-size: 0.82rem; }
.btn--icon   { min-width: 44px; min-height: 44px; padding: 8px 12px; }

/* ── Alertes ─────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
}
.alert[hidden] { display: none; }
.alert--error   { background: rgba(192, 57, 43, 0.1); color: #c0392b; border: 1px solid rgba(192,57,43,0.2); }
.alert--success { background: var(--color-primary-tint); color: var(--color-primary-text); border: 1px solid var(--color-border); }

/* ── Formulaires ─────────────────────────────────────────────────────────────── */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field__label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-primary-text);
}

.form-field__input {
  min-height: 44px;
  padding: 11px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color 140ms, box-shadow 140ms;
  width: 100%;
}
.form-field__input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--color-primary) 45%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 10%, transparent);
}

.form-field__textarea { resize: vertical; min-height: 70px; }

.form-field__pw-wrap { position: relative; }
.form-field__pw-wrap .form-field__input { padding-right: 44px; }

.btn-eye {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.form-field__error {
  font-size: 0.78rem;
  color: #c0392b;
  min-height: 1em;
}

/* HomePage : reconstruite sur les tokens Phase G, voir css/home.css */

/* ── Auth card ────────────────────────────────────────────────────────────────── */
.page--auth {
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, var(--color-bg) 0%, var(--color-sand) 140%);
  position: relative;
}

/* Theme toggle dans les pages auth : positionné en haut à droite */
.page--auth .theme-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 36px 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: -12px 0 -8px -4px;
  padding: 0 4px;
  font-size: 0.82rem;
  color: var(--color-muted);
  text-decoration: none;
}
.auth-back:hover { color: var(--color-primary-text); }

.auth-card__title { margin: 0; font-size: 1.5rem; font-weight: 800; color: var(--color-primary-text); }
.auth-card__sub   { margin: 0; font-size: 0.88rem; color: var(--color-muted); }

.auth-form  { display: flex; flex-direction: column; gap: 16px; }

.auth-card__footer {
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-muted);
  margin: 0;
}

.auth-link {
  color: var(--color-primary-text);
  font-weight: 700;
  text-decoration: none;
}
.auth-link:hover { text-decoration: underline; }

/* ── Modales ─────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 16px;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  padding: 28px 24px 24px;
  width: min(460px, 100%);
  box-shadow: 0 24px 64px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal--sm { max-width: 360px; }

.modal__title  { margin: 0; font-size: 1.2rem; font-weight: 800; color: var(--color-primary-text); }
.modal__body   { margin: 0; font-size: 0.9rem; color: var(--color-muted); line-height: 1.5; }
.modal__form   { display: flex; flex-direction: column; gap: 14px; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

/* ── Skeleton shimmer ────────────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.sk-shimmer,
.sk-line {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--color-border) 35%, var(--color-surface)) 25%,
    color-mix(in srgb, var(--color-border) 70%, var(--color-surface)) 50%,
    color-mix(in srgb, var(--color-border) 35%, var(--color-surface)) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.sk-line {
  height: 10px;
  border-radius: 5px;
  margin-bottom: 8px;
}
.sk-line--40 { width: 40%; }
.sk-line--60 { width: 60%; }
.sk-line--80 { width: 80%; }

/* ── Page profil ──────────────────────────────────────────────────────────────── */

.page--profile {
  min-height: 100vh;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.profile-header__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-primary-text);
}

.profile-main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 40px 24px;
}

.profile-card {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 36px 32px;
  width: min(480px, 100%);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.profile-avatar {
  display: flex;
  justify-content: center;
}

.profile-avatar__img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-border);
}

.profile-avatar__initials {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-size: 1.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.profile-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

.profile-signout {
  display: flex;
  justify-content: center;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}

.btn--danger-ghost {
  color: #c0392b;
  font-size: 0.9rem;
}

.btn--danger-ghost:hover { background: rgba(192, 57, 43, 0.07); }

.auth-card__forgot {
  margin: 0;
  text-align: right;
  font-size: 0.85rem;
}
