/* =========================================================
   cg-comptes.css — Écrans espace comptes & fiches pros
   ---------------------------------------------------------
   Cohérence avec le design system Caniguide (global.css = source
   des tokens --cg-* et des classes .cg-kicker / .cg-button /
   .cg-callout-*). Feuille AUTONOME : elle ne dépend PAS de
   contact.css. Les primitives de formulaire nécessaires sont
   redéclarées ici à partir des tokens, namespacées sous .cg-compte
   pour ne pas entrer en collision avec les .cg-form-* globaux.

   BRIQUE 1 : seule la carte d'auth (écran Connexion) est couverte.
   Les autres écrans seront propagés après validation visuelle.
   ========================================================= */

/* =========================================================
   Base écran compte (wrapper <main class="cg-compte">)
   ========================================================= */
.cg-compte {
  color: var(--cg-text);
}

/* =========================================================
   Carte d'authentification (connexion / + futurs inscription,
   mot de passe oublié, réinitialiser)
   ========================================================= */
.cg-compte.cg-auth {
  /* .ast-container est une grille Astra : on occupe toute la largeur
     (sinon le main est coincé dans une piste étroite et colle à gauche). */
  grid-column: 1 / -1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: clamp(520px, 70vh, 760px);
  margin: 0;
  padding: clamp(32px, 6vw, 64px) 16px;
  background: var(--cg-bg-soft);
}

.cg-auth__card {
  width: 100%;
  max-width: 440px;
  padding: clamp(24px, 4vw, 40px);
  background: var(--cg-bg);
  border: 1px solid var(--cg-border);
  border-radius: var(--cg-radius-lg);
  box-shadow: var(--cg-shadow-sm);
}

/* --- En-tête de carte : logo + sur-titre + H1 --------------- */
.cg-auth__head {
  margin-bottom: var(--cg-space-6);
  text-align: center;
}

.cg-auth__logo {
  margin-bottom: var(--cg-space-4);
}

.cg-auth__logo .custom-logo,
.cg-auth__logo img {
  display: block;
  width: auto;
  max-height: 46px;
  margin: 0 auto;
}

.cg-auth__title {
  margin: 0;
  font-size: var(--cg-text-3xl);
}

/* Texte d'introduction sous le titre (ex. mot de passe oublié). */
.cg-auth__intro {
  margin: 0 0 var(--cg-space-5);
  font-size: var(--cg-text-sm);
  line-height: var(--cg-leading-normal);
  color: var(--cg-text-soft);
}

/* =========================================================
   Primitives de formulaire (LOCALES, à partir des tokens)
   ========================================================= */
.cg-auth__form {
  margin: 0;
}

.cg-field {
  margin: 0 0 var(--cg-space-5);
}

.cg-field > label {
  display: block;
  margin-bottom: var(--cg-space-2);
  font-size: var(--cg-text-sm);
  font-weight: 700;
  color: var(--cg-primary);
}

/* Champs texte/email/password : pleine largeur de la carte, tactile (≥44px). */
.cg-compte .cg-input,
.cg-compte input[type="text"],
.cg-compte input[type="email"],
.cg-compte input[type="password"] {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--cg-border-strong);
  border-radius: var(--cg-radius-sm);
  background: var(--cg-bg);
  color: var(--cg-text);
  font-size: var(--cg-text-base);
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cg-compte .cg-input:hover,
.cg-compte input[type="text"]:hover,
.cg-compte input[type="email"]:hover,
.cg-compte input[type="password"]:hover {
  border-color: var(--cg-text-muted);
}

/* Focus orange léger (token partagé). Spécificité (0,2,1) > règles
   neutres de global.css (input:focus / input:focus-visible) → gagne. */
.cg-compte .cg-input:focus,
.cg-compte input[type="text"]:focus,
.cg-compte input[type="email"]:focus,
.cg-compte input[type="password"]:focus {
  outline: none;
  border-color: var(--cg-accent);
  box-shadow: var(--cg-focus-ring);
}

/* Case à cocher « Se souvenir de moi » */
.cg-check {
  display: inline-flex;
  align-items: center;
  gap: var(--cg-space-2);
  font-size: var(--cg-text-sm);
  color: var(--cg-text-soft);
  cursor: pointer;
}

.cg-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--cg-accent);
  cursor: pointer;
}

.cg-auth__remember {
  margin: 0 0 var(--cg-space-6);
}

/* Consentement CGU/confidentialité : case + texte multi-ligne (liens) alignés en tête. */
.cg-auth__consent {
  margin: 0 0 var(--cg-space-6);
}

.cg-auth__consent .cg-check {
  align-items: flex-start;
  line-height: 1.5;
}

.cg-auth__consent .cg-check input[type="checkbox"] {
  flex: 0 0 auto;
  margin-top: 2px;
}

.cg-auth__consent a {
  font-weight: 700;
}

/* Bouton de soumission : pleine largeur (réutilise .cg-button global). */
.cg-auth__form .cg-button {
  width: 100%;
}

/* =========================================================
   Liens secondaires sous le bouton
   ========================================================= */
.cg-auth__links {
  margin-top: var(--cg-space-6);
  padding-top: var(--cg-space-5);
  border-top: 1px solid var(--cg-border);
  text-align: center;
}

.cg-auth__links p {
  margin: 0 0 var(--cg-space-2);
  font-size: var(--cg-text-sm);
  color: var(--cg-text-soft);
}

.cg-auth__links p:last-child {
  margin-bottom: 0;
}

.cg-auth__links a {
  font-weight: 700;
}

/* =========================================================
   Encarts de feedback dans la carte (succès / erreurs)
   Réutilise .cg-callout / .cg-callout-* ; on resserre la marge
   pour le contexte « carte » (global.css pose margin:28px 0).
   ========================================================= */
.cg-auth__card .cg-callout {
  margin: 0 0 var(--cg-space-5);
  padding: var(--cg-space-3) var(--cg-space-4);
  font-size: var(--cg-text-sm);
}

.cg-auth__card .cg-callout ul {
  margin: 0;
  padding-left: 1.2rem;
}

.cg-auth__card .cg-callout-success {
  color: #155724;
}

.cg-auth__card .cg-callout-danger {
  color: var(--cg-danger);
}

/* =========================================================
   Responsive — sous 480px : carte pleine largeur, marges latérales,
   cibles tactiles conservées (≥44px).
   ========================================================= */
@media (max-width: 480px) {
  .cg-compte.cg-auth {
    min-height: 0;
    padding: var(--cg-space-7) var(--cg-space-4);
  }

  .cg-auth__card {
    max-width: 100%;
    padding: var(--cg-space-6) var(--cg-space-5);
  }

  .cg-auth__title {
    font-size: var(--cg-text-2xl);
  }
}

/* =========================================================
   Panneau carte générique (tableau de bord, confirmation)
   ========================================================= */
.cg-panel {
  background: var(--cg-bg);
  border: 1px solid var(--cg-border);
  border-radius: var(--cg-radius-lg);
  box-shadow: var(--cg-shadow-sm);
  padding: clamp(20px, 3vw, 28px);
}

.cg-panel + .cg-panel {
  margin-top: var(--cg-space-6);
}

.cg-panel > *:last-child {
  margin-bottom: 0;
}

/* =========================================================
   ÉCRAN « Mon compte » — largeur de contenu normale (pas la
   carte d'auth étroite). Cartes à l'intérieur.
   ========================================================= */
.cg-compte.cg-dashboard {
  /* Occupe toute la grille .ast-container, puis colonne de lecture centrée. */
  grid-column: 1 / -1;
  width: 100%;
  max-width: calc(var(--cg-container-sm) + 40px);
  margin-inline: auto;
  padding: clamp(28px, 4vw, 48px) 20px clamp(40px, 5vw, 64px);
}

.cg-dashboard > h1 {
  margin-bottom: var(--cg-space-6);
}

.cg-dashboard h2 {
  font-size: var(--cg-text-2xl);
  margin: var(--cg-space-8) 0 var(--cg-space-4);
}

/* --- Carte identité : lignes clé / valeur --------------------- */
.cg-id-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--cg-space-3);
}

.cg-id-row {
  display: flex;
  gap: var(--cg-space-3);
  font-size: var(--cg-text-base);
}

.cg-id-row__k {
  flex: 0 0 96px;
  color: var(--cg-text-muted);
  font-weight: 600;
}

.cg-id-row__v {
  color: var(--cg-text);
  word-break: break-word;
}

.cg-id-actions {
  margin-top: var(--cg-space-5);
  padding-top: var(--cg-space-5);
  border-top: 1px solid var(--cg-border);
}

/* --- Liste des fiches ---------------------------------------- */
.cg-fiche-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--cg-space-4);
}

.cg-fiche-card {
  display: flex;
  align-items: center;
  gap: var(--cg-space-4);
  padding: var(--cg-space-4);
  border: 1px solid var(--cg-border);
  border-radius: var(--cg-radius-md);
  background: var(--cg-bg);
}

.cg-fiche-card__logo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--cg-radius-sm);
  overflow: hidden;
  background: var(--cg-bg-soft);
  border: 1px solid var(--cg-border);
  color: var(--cg-text-muted);
}

.cg-fiche-card__logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cg-fiche-card__body {
  flex: 1 1 auto;
  min-width: 0;
}

.cg-fiche-card__name {
  display: block;
  margin: 0 0 2px;
  font-family: 'DM Sans', sans-serif;
  font-size: var(--cg-text-md);
  font-weight: 800;
  line-height: 1.3;
  color: var(--cg-primary);
  text-decoration: none;
}

.cg-fiche-card__name:hover {
  color: var(--cg-accent);
}

.cg-fiche-card__meta {
  margin: 0;
  font-size: var(--cg-text-sm);
  color: var(--cg-text-muted);
}

.cg-fiche-card__action {
  flex: 0 0 auto;
}

.cg-fiche-card__action .cg-button {
  min-height: 40px;
  padding: 8px 16px;
}

/* --- Badge de statut ----------------------------------------- */
.cg-fiche-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: var(--cg-radius-pill);
  font-size: var(--cg-text-xs);
  font-weight: 700;
  line-height: 1.4;
}

.cg-fiche-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.cg-fiche-badge--verified {
  color: var(--cg-success);
  background: var(--cg-success-bg);
}

.cg-fiche-badge--pending {
  color: var(--cg-warning);
  background: var(--cg-warning-bg);
}

.cg-fiche-badge--rejected {
  color: var(--cg-danger, #b32d2e);
  background: var(--cg-danger-bg, #fbeaea);
}

/* --- Sélecteur de métier (création de fiche, Temps 1) -------- */
.cg-metier-list {
  list-style: none;
  margin: var(--cg-space-5) 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--cg-space-3);
}

.cg-metier-list > li {
  margin: 0;
}

/* --- Entrée discrète « gérez un établissement ? » ------------ */
.cg-dashboard__hint {
  margin-top: var(--cg-space-7);
  font-size: var(--cg-text-sm);
  color: var(--cg-text-muted);
}

.cg-dashboard__hint a {
  font-weight: 700;
}

@media (max-width: 560px) {
  .cg-fiche-card {
    flex-wrap: wrap;
  }

  .cg-fiche-card__action {
    width: 100%;
  }

  .cg-fiche-card__action .cg-button {
    width: 100%;
  }
}

/* =========================================================
   ÉCRAN « Revendiquer » — carte de confirmation centrée
   ========================================================= */
.cg-compte.cg-confirm {
  grid-column: 1 / -1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: clamp(420px, 55vh, 640px);
  padding: clamp(32px, 6vw, 64px) 16px;
  background: var(--cg-bg-soft);
}

.cg-confirm__card {
  width: 100%;
  max-width: 540px;
  text-align: center;
}

.cg-confirm__card .cg-callout {
  text-align: left;
}

.cg-confirm__card p {
  color: var(--cg-text-soft);
}

.cg-confirm__card strong {
  color: var(--cg-primary);
}

.cg-confirm__actions {
  display: flex;
  flex-direction: column;
  gap: var(--cg-space-3);
  margin-top: var(--cg-space-6);
}

.cg-confirm__actions .cg-button {
  width: 100%;
}

@media (max-width: 480px) {
  .cg-compte.cg-confirm {
    min-height: 0;
    padding: var(--cg-space-7) var(--cg-space-4);
  }

  .cg-confirm__card {
    padding: var(--cg-space-6) var(--cg-space-5);
  }
}

/* =========================================================
   ÉCRAN « Éditer ma fiche » — formulaire au niveau de la fiche
   publique (sections en cards à filet orange). STYLING PUR :
   aucun champ ajouté/retiré, namespace .cg-edit-*.
   ========================================================= */
.cg-compte.cg-edit {
  grid-column: 1 / -1;
  width: 100%;
  max-width: calc(var(--cg-container-sm) + 40px);
  margin-inline: auto;
  padding: clamp(28px, 4vw, 48px) 20px clamp(40px, 5vw, 80px);
}

.cg-edit > h1 {
  margin-bottom: var(--cg-space-2);
}

.cg-edit__subtitle {
  margin: 0 0 var(--cg-space-6);
  font-size: var(--cg-text-sm);
  color: var(--cg-text-muted);
}

.cg-edit__subtitle strong {
  color: var(--cg-primary);
}

.cg-edit__subtitle a {
  font-weight: 700;
}

/* --- Section = card avec titre à filet orange (grammaire fiche publique) --- */
.cg-edit-section {
  margin: 0 0 var(--cg-space-6);
  padding: clamp(18px, 3vw, 26px);
  border: 1px solid var(--cg-border);
  border-radius: var(--cg-radius-lg);
  background: var(--cg-bg);
  box-shadow: var(--cg-shadow-sm);
}

.cg-edit-section__title {
  margin: 0 0 var(--cg-space-5);
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--cg-accent);
  font-family: 'Playfair Display', serif;
  font-size: var(--cg-text-xl);
  font-weight: 500;
  line-height: 1.2;
  color: var(--cg-heading);
}

/* --- Champs texte / textarea / select (mêmes primitives que l'auth) --- */
.cg-edit-field {
  margin: 0 0 var(--cg-space-5);
}

.cg-edit-field:last-child {
  margin-bottom: 0;
}

.cg-edit-field > label,
.cg-edit-label {
  display: block;
  margin-bottom: var(--cg-space-2);
  font-size: var(--cg-text-sm);
  font-weight: 700;
  color: var(--cg-primary);
}

.cg-edit input[type="text"],
.cg-edit input[type="email"],
.cg-edit input[type="url"],
.cg-edit input[type="number"],
.cg-edit input[type="tel"],
.cg-edit select,
.cg-edit textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--cg-border-strong);
  border-radius: var(--cg-radius-sm);
  background: var(--cg-bg);
  color: var(--cg-text);
  font-size: var(--cg-text-base);
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cg-edit textarea {
  min-height: 96px;
  resize: vertical;
  line-height: var(--cg-leading-normal);
}

.cg-edit input:hover,
.cg-edit select:hover,
.cg-edit textarea:hover {
  border-color: var(--cg-text-muted);
}

.cg-edit input:focus,
.cg-edit select:focus,
.cg-edit textarea:focus {
  outline: none;
  border-color: var(--cg-accent);
  box-shadow: var(--cg-focus-ring);
}

.cg-edit-help {
  margin: var(--cg-space-2) 0 0;
  font-size: var(--cg-text-sm);
  color: var(--cg-text-muted);
}

/* --- Services : pastilles tappables, état coché lisible d'un coup d'œil --- */
.cg-edit-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cg-space-3);
  margin-top: var(--cg-space-1);
}

/* Les bascules oui/non (true_false) coulent comme des chips et s'enroulent au
   lieu de s'empiler une par ligne. Un champ bloc intercalé (tarif, lien…)
   recasse naturellement la rangée. */
.cg-edit-field--true_false {
  display: inline-block;
  margin: 0 var(--cg-space-3) var(--cg-space-3) 0;
  vertical-align: top;
}

.cg-edit-checkboxes .cg-edit-check,
.cg-edit-field--true_false .cg-edit-check {
  display: inline-flex;
  align-items: center;
  gap: var(--cg-space-2);
  min-height: 44px;
  margin: 0;
  padding: 9px 14px;
  border: 1px solid var(--cg-border-strong);
  border-radius: var(--cg-radius-sm);
  background: var(--cg-bg);
  font-size: var(--cg-text-sm);
  font-weight: 500;
  line-height: 1.2;
  color: var(--cg-text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.cg-edit-checkboxes .cg-edit-check:hover,
.cg-edit-field--true_false .cg-edit-check:hover {
  border-color: var(--cg-accent);
  background: #fffaf5;
}

/* État sélectionné : fond ambré doux + bordure accent — tranche nettement
   d'une pastille décochée (fond blanc). */
.cg-edit-checkboxes .cg-edit-check:has(input:checked),
.cg-edit-field--true_false .cg-edit-check:has(input:checked) {
  border-color: var(--cg-accent);
  background: #fff1e3;
  color: var(--cg-primary);
  font-weight: 600;
}

.cg-edit-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--cg-accent);
  cursor: pointer;
}

/* --- Logo : card autour de l'existant + zone de remplacement --- */
.cg-edit-logo-current {
  display: flex;
  flex-direction: column;
  gap: var(--cg-space-3);
  margin-bottom: var(--cg-space-4);
  padding: var(--cg-space-4);
  border: 1px solid var(--cg-border);
  border-radius: var(--cg-radius-md);
  background: var(--cg-bg-soft);
}

.cg-edit-logo-current img {
  max-width: 120px;
  height: auto;
  border: 1px solid var(--cg-border);
  border-radius: var(--cg-radius-sm);
  background: #fff;
}

.cg-edit-logo-current .cg-edit-check {
  display: inline-flex;
  align-items: center;
  gap: var(--cg-space-2);
  cursor: pointer;
}

.cg-edit input[type="file"] {
  font-size: var(--cg-text-sm);
}

/* --- Consentements RGPD : encart info (choix conscients) --- */
.cg-edit-consent {
  margin-top: var(--cg-space-4);
  padding: var(--cg-space-4);
  border: 1px solid #cfe3f7;
  border-radius: var(--cg-radius-md);
  background: var(--cg-info-bg);
}

.cg-edit-consent .cg-edit-check {
  display: inline-flex;
  align-items: center;
  gap: var(--cg-space-2);
  min-height: auto;
  padding: 0;
  border: 0;
  background: none;
  font-weight: 700;
  color: var(--cg-primary);
  cursor: pointer;
}

.cg-edit-consent .cg-edit-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--cg-accent);
}

.cg-edit-consent__hint {
  margin: var(--cg-space-2) 0 0;
  font-size: var(--cg-text-xs);
  line-height: var(--cg-leading-normal);
  color: var(--cg-info);
}

/* --- Barre d'action : enregistrer (primaire) + retour (secondaire) --- */
.cg-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cg-space-3);
  margin-top: var(--cg-space-6);
  padding: var(--cg-space-4);
  border: 1px solid var(--cg-border);
  border-radius: var(--cg-radius-lg);
  background: var(--cg-bg);
  box-shadow: var(--cg-shadow-md);
}

.cg-edit-actions .cg-button {
  flex: 1 1 auto;
}

@media (min-width: 768px) {
  /* Sticky bas : la barre reste visible le long du formulaire (desktop only). */
  .cg-edit-actions {
    position: sticky;
    bottom: 16px;
  }
}

@media (max-width: 560px) {
  .cg-edit-actions {
    flex-direction: column;
  }
}
