/* =========================================================
   Menu commun PharmaX — bandeau vert, bandeau invité et
   barre d'onglets. Utilisé par la page Assistant et par
   toutes les pages qui héritent de base.html.
   ========================================================= */

:root {
  --primary-color: #007d50;
  --primary-dark: #00663f;
  --primary-light: #e6f6f0;
  --border-color: #e2e8f0;
  --text-dark: #333333;
  --text-gray: #666666;
  --accent-blue-dark: #0369a1;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  flex-shrink: 0;
}

/* --- TOP HEADER --- */
.top-header {
  background-color: var(--primary-color);
  color: white;
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  flex-shrink: 0;
}

.top-left, .top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-status {
  font-size: 12px;
  opacity: .96;
}

.btn-top {
  background: rgba(0, 40, 24, 0.24);   /* voile foncé : texte blanc à plus de 6:1 (WCAG AA) */
  border: none;
  color: white;
  padding: 4px 12px;
  border-radius: 16px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn-top:hover { background: rgba(0, 40, 24, 0.36); color: white; }

.top-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #f59e0b;
  color: #1f2937;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* --- BANNER --- */
.info-banner {
  background-color: var(--primary-light);
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-dark);
  border-bottom: 1px solid var(--border-color);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  flex-shrink: 0;
}

.info-banner a {
  color: var(--accent-blue-dark);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

/* --- NAVIGATION BAR --- */
.nav-bar {
  background: white;
  display: flex;
  flex-wrap: nowrap;
  gap: 24px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.nav-bar::-webkit-scrollbar { display: none; }

.nav-bar .nav-item {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  color: var(--text-gray);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding-bottom: 4px;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.nav-bar .nav-item:hover { color: var(--primary-color); }

.nav-bar .nav-item.active {
  color: var(--primary-color);
  border-bottom: 2px solid var(--primary-color);
}

.nav-bar .nav-item.locked { color: #556274; }
.nav-bar .nav-item.locked .lock { font-size: 13px; opacity: .75; }
.nav-bar .nav-item.locked:hover { color: var(--primary-color); }

/* --- RESPONSIVE --- */
@media (max-width: 1024px) {
  .nav-bar { gap: 18px; }
}

@media (max-width: 900px) {
  .top-header {
    flex-wrap: nowrap;
    gap: 10px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .top-left { flex: 0 0 auto; }

  /* Les boutons de droite défilent horizontalement plutôt que
     de faire passer le bandeau sur plusieurs lignes */
  .top-right {
    flex: 1 1 auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px;
    padding-bottom: 2px;
  }

  .top-right::-webkit-scrollbar { display: none; }
  .top-right > * { flex: 0 0 auto; }

  .info-banner {
    font-size: 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 8px 14px;
  }

  .nav-bar {
    gap: 18px;
    padding: 10px 14px;
  }

  /* Marge de fin pour que le dernier onglet ne colle pas au bord */
  .nav-bar::after {
    content: "";
    flex: 0 0 6px;
  }
}

@media (max-width: 640px) {
  .top-header { font-size: 13px; }
  .btn-top { padding: 4px 10px; font-size: 12px; }

  /* Les libellés secondaires cèdent la place aux icônes */
  .btn-top .btn-top-label { display: none; }

  .nav-bar .nav-item { font-size: 13px; }
}

@media (max-width: 400px) {
  .info-banner { font-size: 12px; }
}

@media (max-height: 520px) and (max-width: 900px) {
  .info-banner { display: none; }
}

/* =========================================================
   Identité dans le bandeau vert
   ========================================================= */
.top-logo {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 10px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  text-decoration: none;
}

.top-logo img { width: 100%; height: 100%; object-fit: contain; }

.top-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: white;
  min-width: 0;
}

.top-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: rgba(0, 40, 24, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

/* Avatar générique des comptes invités : icône Remix Icon, même cercle que les initiales */
.top-avatar-invite i,
.nav-drawer-avatar-invite i { font-size: 18px; line-height: 1; }

.top-identity-text { min-width: 0; line-height: 1.25; }

.top-identity-text strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-identity-text strong em {
  font-style: normal;
  font-weight: 400;
  font-size: 12px;
  opacity: .96;   /* au-delà de 4,5:1 sur le vert */
}

.top-identity-text small {
  display: block;
  font-size: 12px;
  opacity: .96;   /* au-delà de 4,5:1 sur le vert */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================
   Navigation basse (mobile uniquement)
   ========================================================= */
.bottom-nav { display: none; }

@media (max-width: 900px) {
  /* Les onglets du haut cèdent la place à la barre du bas */
  .app-topbar .nav-bar { display: none; }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1035;
    display: flex;
    background: white;
    border-top: 1px solid var(--border-color);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(15, 23, 42, .06);
  }

  .bottom-nav a {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 4px 7px;
    color: var(--text-gray);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
  }

  .bottom-nav a i { font-size: 20px; }
  .bottom-nav a.active { color: var(--primary-color); }
  .bottom-nav a.locked { color: #556274; }

  .bottom-dot {
    position: absolute;
    top: 6px;
    right: 50%;
    margin-right: -16px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
  }

  .top-identity-text small { display: none; }
  .top-logo { display: none; }
}

@media (max-width: 380px) {
  .top-identity-text strong { font-size: 13px; }
  .bottom-nav a span { font-size: 12px; }
}

/* =========================================================
   Tiroir de navigation mobile (défilable, comme la console)
   ========================================================= */
.top-burger {
  display: none;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: white;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 10px;
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.top-burger:hover { background: rgba(255, 255, 255, 0.3); }

.nav-drawer,
.nav-drawer-backdrop { display: none; }

.nav-drawer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.nav-drawer-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.nav-drawer-id { flex: 1; min-width: 0; }
.nav-drawer-id strong { display: block; font-size: 14px; color: var(--text-dark); }

.nav-drawer-id small {
  display: block;
  font-size: 12px;
  color: var(--text-gray);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-drawer-close {
  border: none;
  background: none;
  color: var(--text-gray);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.nav-drawer-links {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-drawer-links a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 10px;
  color: var(--text-dark);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
}

.nav-drawer-links a i:first-child { font-size: 19px; color: var(--text-gray); }
.nav-drawer-links a:hover { background: #f5f7f9; }

.nav-drawer-links a.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.nav-drawer-links a.active i:first-child { color: var(--primary-color); }
.nav-drawer-links a.locked { color: #9aa5b4; }
.nav-drawer-links a.locked i:first-child { color: #556274; }
.drawer-lock { margin-left: auto; font-size: 14px; opacity: .7; }
.nav-drawer-links a.drawer-danger { color: #dc2626; }
.nav-drawer-links a.drawer-danger i:first-child { color: #dc2626; }

.drawer-count {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--text-gray);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-count.warn { background: #f59e0b; color: #1f2937; }

.nav-drawer-separator {
  height: 1px;
  background: var(--border-color);
  margin: 8px 6px;
}

@media (max-width: 900px) {
  .top-burger { display: flex; }

  /* Le bandeau vert ne garde que l'identité : le reste passe dans le tiroir */
  .top-header .top-right { display: none; }

  .nav-drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1055;
    background: rgba(15, 23, 42, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  .nav-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 82%;
    max-width: 320px;
    z-index: 1060;
    background: white;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(15, 23, 42, .25);
    padding-top: env(safe-area-inset-top);
  }

  body.nav-drawer-open { overflow: hidden; }
  body.nav-drawer-open .nav-drawer { transform: translateX(0); }
  body.nav-drawer-open .nav-drawer-backdrop { opacity: 1; pointer-events: auto; }
}

/* « Créer un compte » dans le bandeau invité : zone tactile de 28 px. */
.info-banner a { display: inline-flex; align-items: center; min-height: 28px; }
