/* ============================================================
   layout.css — Page shell: navigation, sections, flex helpers
   Loaded on every page via Page::displayHeader()
   ============================================================ */

/* ── Page shell reset ───────────────────────────────────── */

body {
  margin: 0;
  padding: 0;
  background: linear-gradient(160deg, #f0f4f1 0%, #f7f9f7 60%, #f9f8f5 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-body {
  padding: 0 var(--space-4);
  flex: 1;
}

/* ── Navigation (desktop) ──────────────────────────────── */

.main-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 4px 8px;
  margin-bottom: var(--space-3);
  background: var(--color-brand);
  border-radius: 0;
}

/* Menu ouvert : la barre nav passe au-dessus des éléments sticky/flottants des
   pages (cartes d'en-tête, barre et bottom sheet panier, boutons flottants).
   Le z-index n'est posé que pendant l'ouverture, pour ne pas passer devant les
   modales (backdrops à 100-400) le reste du temps. */
.main-nav.is-menu-open {
  position: relative;
  z-index: 900;
}

.nav-brand-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  flex-shrink: 0;
}

.nav-brand {
  flex-shrink: 0;
  padding: 4px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.nav-page-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--font-weight-display);
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(42vw, 28rem);
}

/* ── Titre page (sous la navigation) ─────────────────────── */

.page-nav-heading {
  margin: 0 0 var(--space-3);
  padding: var(--space-3) 0 0;
}

.page-nav-heading__title {
  margin: 0;
  font-size: var(--text-xl, 1.35rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-text);
}

.nav-brand img {
  display: block;
}

/* #primary-nav-items masqué — nav unique via le dropdown nav-profile-menu */
.nav-items {
  display: none !important;
}

.menu-icon {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 6px;
  width: 75px;
  font-size: 11px;
  line-height: 1.3;
}

/* br between icon and label — not needed with flexbox gap */
.menu-icon br {
  display: none;
}

.menu-icon.is-active {
  background: var(--color-primary-light);
  border-radius: 8px;
  font-weight: 700;
  color: var(--color-primary);
}

.menu-icon a {
  color: inherit;
  text-decoration: none;
}

.menu-icon img {
  margin-bottom: 3px;
}

/* kept for legacy compatibility */
.menu-item {
  display: inline-flex;
  align-items: center;
  width: 60px;
  padding-right: 6px;
}

.tab {
  display: inline-flex;
  align-items: center;
  padding-left: 25px;
}

.menu-logged-in {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px;
  text-align: center;
  color: silver;
  font-size: 11px;
}

.nav-logout {
  display: flex;
  align-items: center;
  padding: 0 6px;
}

/* ── Profile dropdown ───────────────────────────────────── */

.nav-profile {
  position: relative;
  margin-left: auto;
  flex-shrink: 0;
}

.nav-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.nav-profile-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

/* Avatar circle inside the button */
.nav-profile-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.32);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-profile-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-profile-chevron {
  flex-shrink: 0;
  transition: transform 0.2s;
}

.nav-profile-btn[aria-expanded="true"] .nav-profile-chevron {
  transform: rotate(180deg);
}

.nav-profile-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0 0 4px;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  /* Full list visible on desktop (same entries as mobile drawer); scroll only if the viewport is short */
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-profile-menu[hidden] {
  display: none;
}

/* Bandeau profil vert (nom de l'adhérent) en tête du menu déroulant, desktop et mobile */
.nav-profile-menu > .nav-drawer-profile {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-brand);
  color: #fff;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.nav-profile-menu > .nav-drawer-profile .nav-drawer-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-profile-menu > .nav-drawer-profile .nav-drawer-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.nav-profile-menu > .nav-drawer-profile .nav-drawer-name {
  font-weight: 700;
  font-size: var(--text-md, 1rem);
  line-height: var(--leading-tight, 1.25);
  word-break: break-word;
  color: #fff;
}

.nav-profile-menu > .nav-drawer-profile .nav-drawer-role {
  font-size: var(--text-xs, 0.8rem);
  opacity: 0.78;
  color: #fff;
}

/* Bouton « œil » du bureau : voir l'appli avec un autre rôle (cf. Auth::VUES) */
.nav-profile-menu > .nav-drawer-profile .nav-drawer-role {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-vue-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background 0.12s;
}

.nav-vue-btn:hover,
.nav-vue-btn:focus-visible,
.nav-vue-btn.is-active {
  background: rgba(255, 255, 255, 0.25);
}

.nav-vue-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

.vue-role-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  padding: 8px 16px;
  background: var(--color-warning-bg);
  border-bottom: 1px solid var(--color-warning-border);
  color: var(--color-text);
  font-size: 14px;
  text-align: center;
}

.vue-role-banner svg {
  flex-shrink: 0;
  color: var(--color-warning);
}

.vue-role-banner__btn {
  padding: 4px 12px;
  border: 1.5px solid var(--color-warning);
  border-radius: var(--radius-sm, 4px);
  background: var(--color-surface, #fff);
  color: var(--color-text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.vue-role-banner__btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.vue-role-dialog {
  border: 1.5px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  width: calc(100% - 32px);
  max-width: 440px;
  box-sizing: border-box;
  color: var(--color-text);
  background: var(--color-surface, #fff);
}

.vue-role-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.vue-role-dialog h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
}

.vue-role-dialog__intro {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--color-text-muted, #6b7280);
}

.vue-role-dialog__options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vue-role-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius-sm, 4px);
  font-size: 14px;
  cursor: pointer;
}

.vue-role-option:has(input:checked) {
  border-color: var(--color-brand);
  background: var(--color-surface-sunken, #f6f7f9);
}

.vue-role-option small {
  color: var(--color-text-muted, #6b7280);
}

.vue-role-dialog__erreur {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--color-danger);
}

.vue-role-dialog__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

@media (min-width: 769px) {
  .nav-profile-name {
    max-width: min(50vw, 28rem);
  }

  .nav-profile-menu {
    min-width: 260px;
  }
}

.nav-profile-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  font-size: 14px;
  color: var(--color-text);
  text-decoration: none;
  transition: background 0.12s;
}

.nav-profile-item:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.nav-profile-item.is-active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 700;
}

.nav-profile-item.is-active:hover,
.nav-profile-item.is-active:focus-visible {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 700;
}

/* SVG utilisent currentColor : aligner sur le bleu primaire (les PNG menu sont déjà bleus). */
.nav-profile-menu .nav-profile-item:not(.nav-profile-item--logout) > svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--color-primary);
}

.nav-profile-item--logout {
  color: #c0392b;
}

.nav-profile-item--logout:hover {
  background: #fdf2f2;
  color: #c0392b;
}

.nav-profile-sep {
  height: 1px;
  background: var(--color-border);
  margin: 4px 0;
}

/* ── Mobile drawer (hidden on desktop) ──────────────────── */

.nav-drawer-profile,
.nav-drawer-list,
.nav-drawer-sep {
  display: none;
}

.nav-drawer-item {
  display: none;
}

/* kept for legacy inline uses in page content (search bars, toolbars) */
.vertical-align {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

/* ── Footer ─────────────────────────────────────────────── */

body > hr {
  width: 100%;
  margin: var(--space-4) 0 0;
  box-sizing: border-box;
}

.footer {
  color: gray;
  overflow: hidden;
  padding: 8px;
  background-color: ghostwhite;
  font-size: 12px;
  text-align: center;
}

/* ── Float sections (panier-contenu, etc.) ──────────────── */

.left-section {
  width: 65%;
  float: left;
  border-collapse: collapse;
  overflow: auto;
}

.right-section {
  width: 35%;
  float: right;
  border-collapse: collapse;
  overflow: auto;
}

.top-section {
  width: 100%;
  border-collapse: collapse;
}

/* ── Flex layout helpers ────────────────────────────────── */

.container {
  width: 100%;
}

.row {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
}

.bloc {
  padding: 10px;
  box-sizing: border-box;
}

.bloc-gauche {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.bloc-droite {
  background-color: ghostwhite;
  border: solid 1px var(--color-primary);
  width: 300px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.bloc-image {
  width: 100%;
  text-align: center;
  margin-top: 10px;
}

.bloc-full {
  width: 100%;
  margin-top: 10px;
}

/* ── Mobile overrides ───────────────────────────────────── */

@media (max-width: 768px) {

  /* Top bar: logo | bouton profil (ouvre le panneau mobile à la place de l’ancien burger) */
  .main-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 8px;
    row-gap: 0;
    flex-wrap: nowrap;
    box-sizing: border-box;
    max-width: 100%;
    position: relative;
    z-index: 20;
  }

  .nav-brand-group {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    min-width: 0;
  }

  .nav-profile {
    display: block;
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: center;
    margin-left: 0;
    min-width: 0;
  }

  .nav-profile-name {
    max-width: min(40vw, 180px);
  }

  /* nav-profile-menu : pleine largeur sous la barre nav sur mobile */
  .nav-profile {
    position: static; /* ancrage relatif à main-nav (position:relative) */
  }

  .nav-profile-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    min-width: unset;
    /* Pas de bordure haute/latérale : elle cernait de clair le bandeau vert */
    border-width: 0 0 1px;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    max-height: calc(100dvh - 60px);
    overflow-y: auto;
  }

  /* Bandeau profil compact : même hauteur qu'une entrée de la liste, nom et rôle sur une ligne */
  .nav-profile-menu > .nav-drawer-profile {
    border-radius: 0;
    gap: 10px;
    padding: 11px 16px;
  }

  .nav-profile-menu > .nav-drawer-profile .nav-drawer-avatar {
    width: 20px;
    height: 20px;
  }

  .nav-profile-menu > .nav-drawer-profile .nav-drawer-avatar svg {
    width: 14px;
    height: 14px;
  }

  .nav-profile-menu > .nav-drawer-profile .nav-drawer-info {
    flex: 1;
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
  }

  .nav-profile-menu > .nav-drawer-profile .nav-drawer-name {
    min-width: 0;
    font-size: 14px;
    line-height: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: normal;
  }

  .nav-profile-menu > .nav-drawer-profile .nav-drawer-role {
    flex-shrink: 0;
    margin-left: auto;
    font-size: 12px;
    white-space: nowrap;
  }

  .nav-profile-menu[hidden] {
    display: none !important;
  }

  .nav-items {
    grid-column: 1 / -1;
    grid-row: 2;
    flex: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    display: none;
    flex-direction: column;
    align-items: stretch;
    align-self: stretch;
    justify-content: flex-start;
    border-top: 1px solid var(--color-border);
    padding: 0;
    margin: 0;
    background: #fff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.10);
  }

  .nav-items.is-open {
    display: flex;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    overflow: hidden;
  }

  /* Hide desktop icon items when drawer opens */
  .menu-icon,
  .nav-items.is-open .menu-icon {
    display: none;
  }

  /* ── Drawer: green profile header ─── */

  .nav-items.is-open .nav-drawer-profile {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-4) var(--space-4);
    background: var(--color-brand);
    color: #fff;
  }

  .nav-drawer-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .nav-drawer-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
  }

  .nav-drawer-name {
    font-weight: 700;
    font-size: var(--text-md);
    line-height: var(--leading-tight);
    word-break: break-word;
  }

  .nav-drawer-role {
    font-size: var(--text-xs);
    opacity: 0.78;
  }

  /* ── Drawer: flat item list ──────── */

  .nav-items.is-open .nav-drawer-list {
    display: block;
  }

  .nav-drawer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    font-size: 14px;
    color: var(--color-text);
    text-decoration: none;
    border-bottom: 1px solid var(--color-border);
    transition: background 0.12s;
  }

  .nav-drawer-item.is-active {
    border-left: 3px solid var(--color-primary);
    padding-left: 13px;
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 700;
  }

  .nav-drawer-item:hover,
  .nav-drawer-item:active {
    background: var(--color-primary-light);
    color: var(--color-primary);
  }

  .nav-drawer-item--logout {
    color: #c0392b;
  }

  .nav-drawer-item--logout:hover,
  .nav-drawer-item--logout:active {
    background: #fdf2f2;
    color: #c0392b;
  }

  .nav-items.is-open .nav-drawer-sep {
    display: block;
    height: 1px;
    background: var(--color-border);
    margin: 4px 0;
  }

  /* Stack float sections vertically; remove fixed heights */
  .left-section,
  .right-section {
    width: 100%;
    float: none;
    height: auto;
  }

  /* Sidebar becomes full-width */
  .bloc-droite {
    width: 100%;
  }
}

/* ── Lignes panier (#panier-contenu, APIs charger / produit) ─── */

#panier-contenu > .panier-ligne {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  margin: 0 0 6px;
  box-sizing: border-box;
  border-radius: 8px;
}

#panier-contenu > .panier-ligne:nth-child(even) {
  background: rgba(42, 122, 184, 0.09);
}

#panier-contenu > .panier-ligne:nth-child(odd) {
  background: #f8fafc;
}

#panier-contenu .panier-ligne__qty {
  flex: 0 0 auto;
  min-width: 0;
}

#panier-contenu .panier-ligne__qty-field {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

#panier-contenu .panier-ligne__qty-stepper {
  flex-wrap: nowrap;
  gap: 2px;
  align-items: center;
}

#panier-contenu .panier-qty-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  min-width: 2rem;
  height: 2.35rem;
  margin: 0;
  padding: 0;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  color: var(--color-primary, #2a7ab8);
  background: #e8f1f8;
  border: 2px solid #c5d8e8;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

#panier-contenu .panier-qty-btn:hover {
  background: var(--color-primary-light, #d6e8f4);
  border-color: #8eb8d4;
}

#panier-contenu .panier-qty-btn:active {
  background: #d0e0ed;
}

#panier-contenu .panier-qty-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(42, 122, 184, 0.22);
}

#panier-contenu .panier-qty-input {
  width: 3rem;
  min-width: 2.75rem;
  max-width: 4.25rem;
  padding: 6px 2px;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  border: 2px solid #c5d8e8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  transition: border-color 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
  appearance: textfield;
}

#panier-contenu .panier-qty-input::-webkit-outer-spin-button,
#panier-contenu .panier-qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#panier-contenu .panier-qty-input:hover {
  border-color: #8eb8d4;
}

#panier-contenu .panier-qty-input:focus {
  border-color: var(--color-primary, #2a7ab8);
  outline: none;
  box-shadow: 0 0 0 3px rgba(42, 122, 184, 0.22);
}

#panier-contenu .panier-ligne__unite {
  font-size: 0.82rem;
  font-weight: 700;
  color: #4a5568;
  line-height: 1;
  align-self: center;
}

#panier-contenu .panier-ligne__thumb {
  flex: 0 0 auto;
}

#panier-contenu .panier-ligne__img {
  display: block;
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 8px;
}

#panier-contenu .panier-ligne__nom {
  flex: 1 1 auto;
  min-width: 0;
  align-self: center;
  line-height: 1.35;
  overflow-wrap: break-word;
  word-wrap: break-word;
  font-weight: 600;
  color: #1a202c;
}
