/* ============================================================
   LAYOUT V1 — Structure uniquement, sans design visuel
   Deux contextes distincts : patient (mobile) / pro (tablette)
   ============================================================ */

/* --- Variables structurelles --- */
:root {
  --max-patient: 428px;
  --max-pro: 1024px;
  --sidebar-width: 220px;
  --sidebar-collapsed: 56px;
  --bottom-nav-height: 60px;
  --header-height: 52px;
  --gap-sm: 8px;
  --gap-md: 16px;
  --gap-lg: 24px;
}

/* ============================================================
   LAYOUT COMMUN (landing, auth)
   ============================================================ */

.layout-centered {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.layout-centered .site-header {
  border-bottom: 1px solid #ccc;
  padding: var(--gap-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.layout-centered .site-main {
  flex: 1;
  padding: var(--gap-lg) var(--gap-md);
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.layout-centered .site-footer {
  border-top: 1px solid #ccc;
  padding: var(--gap-md);
  text-align: center;
  font-size: 14px;
  color: #666;
}

/* ============================================================
   LAYOUT PATIENT — Mobile first (max 428px)
   ============================================================ */

.layout-patient {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: var(--max-patient);
  margin: 0 auto;
  position: relative;
  border-left: 1px solid #eee;
  border-right: 1px solid #eee;
}

.layout-patient .page-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-height);
  padding: 0 var(--gap-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #ccc;
  background: #fff;
}

.layout-patient .page-header .header-title {
  font-size: 17px;
  font-weight: 600;
}

.layout-patient .page-header .header-back {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  font-size: 15px;
}

.layout-patient .page-content {
  flex: 1;
  padding: var(--gap-md);
  padding-bottom: calc(var(--bottom-nav-height) + var(--gap-md));
  overflow-y: auto;
}

/* Barre de navigation bas — patient */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-patient);
  height: var(--bottom-nav-height);
  display: flex;
  border-top: 2px solid #ccc;
  background: #fff;
  z-index: 100;
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
  font-size: 11px;
  gap: 3px;
  color: #666;
  border-right: 1px solid #eee;
}

.bottom-nav a:last-child {
  border-right: none;
}

.bottom-nav a.active {
  color: #000;
  font-weight: 600;
  border-top: 2px solid #000;
  margin-top: -2px;
}

/* ============================================================
   LAYOUT PRO — Tablette (768px – 1024px)
   ============================================================ */

.layout-pro {
  display: flex;
  min-height: 100vh;
  max-width: var(--max-pro);
  margin: 0 auto;
  border-left: 1px solid #eee;
  border-right: 1px solid #eee;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  border-right: 1px solid #ccc;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-brand {
  height: var(--header-height);
  padding: 0 var(--gap-md);
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ccc;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-brand {
  justify-content: center;
  font-size: 14px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--gap-sm) 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px var(--gap-md);
  font-size: 14px;
  color: #444;
  border-left: 3px solid transparent;
}

.sidebar-nav a.active {
  font-weight: 600;
  color: #000;
  border-left-color: #000;
  background: #f5f5f5;
}

.sidebar.collapsed .sidebar-nav a span {
  display: none;
}

.sidebar.collapsed .sidebar-nav a {
  justify-content: center;
  padding: 11px 0;
}

.sidebar-toggle {
  padding: var(--gap-md);
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
}

.sidebar-footer {
  padding: var(--gap-md);
  border-top: 1px solid #ccc;
  font-size: 13px;
}

/* Contenu principal pro */
.layout-pro .main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.main-header {
  height: var(--header-height);
  padding: 0 var(--gap-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #ccc;
  flex-shrink: 0;
}

/* Déconnexion : visible seulement en vue ≤768px (à côté de la cloche / actions) */
.header-logout-mobile {
  display: none;
}

.main-body {
  flex: 1;
  padding: var(--gap-lg);
}

/* ============================================================
   COMPOSANTS STRUCTURELS COMMUNS
   ============================================================ */

/* Section avec titre */
.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #666;
  margin-bottom: var(--gap-sm);
}

/* Carte */
.card {
  border: 1px solid #ccc;
  padding: var(--gap-md);
  margin-bottom: var(--gap-md);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.card-body {
  font-size: 14px;
  color: #444;
}

/* Grille 2 colonnes */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-md);
}

/* Grille bi-colonnes (pro) */
.col-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-lg);
}

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-sm);
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 500;
  border: 1px solid #333;
  cursor: pointer;
  background: #fff;
}

.btn-primary {
  background: #333;
  color: #fff;
  border-color: #333;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
}

/* Badge statut */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid #ccc;
}

.badge-confirmed { border-color: #333; background: #eee; }
.badge-pending   { border-color: #999; color: #666; }
.badge-cancelled { border-color: #ccc; color: #999; text-decoration: line-through; }

/* Formulaires */
.form-group {
  margin-bottom: var(--gap-md);
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: #444;
}

.form-input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  font-size: 15px;
  background: #fff;
}

.form-input:focus {
  border-color: #333;
}

/* Tabs (structure) */
.tabs-header {
  display: flex;
  border-bottom: 1px solid #ccc;
  margin-bottom: var(--gap-md);
}

.tab-btn {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}

.tab-btn.active {
  color: #000;
  border-bottom-color: #000;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Accordéon */
.accordion-item {
  border: 1px solid #ccc;
  margin-bottom: var(--gap-sm);
}

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gap-md);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  background: #fff;
  border: none;
}

.accordion-content {
  display: none;
  padding: 0 var(--gap-md) var(--gap-md);
  font-size: 14px;
  color: #444;
  border-top: 1px solid #eee;
}

.accordion-item.open .accordion-content {
  display: block;
}

.accordion-chevron {
  font-size: 12px;
  color: #999;
}

.accordion-item.open .accordion-chevron {
  transform: rotate(180deg);
}

/* Filtres chips */
.filter-chips {
  display: flex;
  gap: var(--gap-sm);
  overflow-x: auto;
  padding-bottom: var(--gap-sm);
  margin-bottom: var(--gap-md);
}

.chip {
  flex-shrink: 0;
  padding: 6px 14px;
  font-size: 13px;
  border: 1px solid #ccc;
  cursor: pointer;
  background: #fff;
  white-space: nowrap;
}

.chip.active {
  background: #333;
  color: #fff;
  border-color: #333;
}

/* Séparateur */
.divider {
  border: none;
  border-top: 1px solid #eee;
  margin: var(--gap-md) 0;
}

/* Stat box */
.stat-box {
  border: 1px solid #ccc;
  padding: var(--gap-md);
  text-align: center;
}

.stat-number {
  font-size: 28px;
  font-weight: 700;
  display: block;
}

.stat-label {
  font-size: 12px;
  color: #666;
}

/* Agenda grid pro */
.agenda-grid {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  border: 1px solid #ccc;
  overflow-x: auto;
}

.agenda-cell {
  border-right: 1px solid #ccc;
  border-bottom: 1px solid #eee;
  padding: 4px;
  min-height: 48px;
  font-size: 12px;
}

.agenda-cell:last-child {
  border-right: none;
}

.agenda-col-header {
  border-right: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  background: #f5f5f5;
}

.agenda-time-label {
  font-size: 11px;
  color: #999;
  text-align: right;
  padding: 4px 8px;
  background: #f5f5f5;
}

.agenda-appt {
  border: 1px solid #999;
  padding: 3px 5px;
  font-size: 11px;
  background: #eee;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Slots de créneau */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
}

.slot-btn {
  padding: 10px;
  border: 1px solid #ccc;
  font-size: 14px;
  text-align: center;
  cursor: pointer;
  background: #fff;
}

.slot-btn.selected {
  border-color: #333;
  border-width: 2px;
  font-weight: 600;
}

.slot-btn:disabled {
  color: #ccc;
  cursor: not-allowed;
}

/* Liste items */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gap-md) 0;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}

.list-item:last-child {
  border-bottom: none;
}

/* Responsive tablette → mobile pour pro */
@media (max-width: 768px) {
  .layout-pro {
    flex-direction: column;
    max-width: 100%;
    margin: 0;
    border-left: none;
    border-right: none;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid #ccc;
    flex-shrink: 0;
  }

  /*
   * Annuler le mode « réduit » : hors media, .sidebar.collapsed vaut 56px et masque les libellés,
   * ce qui casse la barre horizontale sur mobile.
   */
  .sidebar.collapsed {
    width: 100%;
  }

  .sidebar.collapsed .sidebar-brand {
    justify-content: flex-start;
    font-size: 18px;
    letter-spacing: 0.05em;
  }

  .sidebar.collapsed .sidebar-nav a span {
    display: inline;
  }

  .sidebar.collapsed .sidebar-nav a {
    justify-content: center;
    padding: 10px 12px;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding: var(--gap-sm) 0;
    gap: 0;
  }

  .sidebar-nav a {
    flex-shrink: 0;
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: 10px 12px;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
    min-width: 72px;
    max-width: 96px;
  }

  .sidebar-nav a svg {
    flex-shrink: 0;
  }

  .sidebar-nav a.active {
    border-left: none;
    border-bottom-color: #000;
    background: rgba(0, 0, 0, 0.04);
  }

  /* Réduire / agrandir la sidebar : sans objet en barre horizontale pleine largeur */
  .sidebar-toggle {
    display: none;
  }

  /* Nom / métier / déconnexion restent dans la sidebar en desktop ; en mobile la déconnexion est dans .main-header */
  .sidebar-footer {
    display: none;
  }

  .header-logout-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border: 1px solid #ccc;
    background: #fff;
    color: #333;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    min-height: 36px;
    box-sizing: border-box;
  }

  .header-logout-mobile:active {
    background: #f5f5f5;
  }

  /*
   * En-tête : une ligne — à gauche le titre ou « Bonjour » (+ date en dessous dans la colonne gauche),
   * à droite les actions (Moreen, cloche, déconnexion) alignées sur la même ligne que le premier texte.
   */
  .main-header {
    height: auto;
    min-height: var(--header-height);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    padding: 12px var(--gap-md);
    gap: 8px 10px;
  }

  .main-header > div:first-child {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
    flex: 1 1 auto;
  }

  .main-header > div:first-child .text-muted {
    margin-left: 0 !important;
  }

  .main-header .flex-gap-sm {
    width: auto;
    max-width: 100%;
    justify-content: flex-end;
    flex-wrap: nowrap;
    flex-shrink: 0;
    gap: 6px;
    align-items: center;
    align-self: flex-start;
  }

  .main-header .flex-gap-sm > * {
    flex-shrink: 0;
  }

  /* Titre Agenda / Patients : même ligne que le groupe de boutons */
  .main-header > span.text-bold:first-child {
    font-size: 17px;
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.25;
    padding-top: 2px;
    padding-right: 8px;
  }

  .main-header .flex-gap-sm .btn {
    max-width: none;
    white-space: nowrap;
  }

  /* Si vraiment trop étroit, les actions passent sous le bloc gauche tout en restant groupées */
  @media (max-width: 380px) {
    .main-header .flex-gap-sm {
      flex-basis: 100%;
      justify-content: flex-start;
      flex-wrap: wrap;
    }
  }

  .main-body {
    padding: var(--gap-md);
  }

  .col-layout {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Utilitaires */
.text-sm   { font-size: 13px; }
.text-xs   { font-size: 12px; }
.text-muted { color: #666; }
.text-bold  { font-weight: 600; }
.mb-sm { margin-bottom: var(--gap-sm); }
.mb-md { margin-bottom: var(--gap-md); }
.mb-lg { margin-bottom: var(--gap-lg); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; justify-content: center; align-items: center; }
.flex-gap-sm  { display: flex; gap: var(--gap-sm); align-items: center; }
.gap-sm { gap: var(--gap-sm); }
