/* ============================================================
   PAPA PV — Layout & Navigation
   Import après tokens.css + base.css + components.css
   ============================================================ */

/* ================================================================
   TOPBAR WEB PUBLIC / CLIENT WEB
   ================================================================ */
.topbar {
  position: sticky;
  top: 56px; /* Below top header */
  z-index: 999;
  background: var(--color-white);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.topbar .container {
  padding: var(--sp-2) var(--container-pad);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

/* Logo */
.topbar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-heading);
  font-weight: var(--fw-bold);
  font-size: 1.125rem;
  color: var(--color-primary);
  text-decoration: none;
  flex-shrink: 0;
  height: 100%;
}

.topbar-logo .logo-image {
  height: 100%;
  max-height: 50px;
  width: auto;
  object-fit: contain;
}

.logo-mark {
  width: 38px;
  height: 38px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-white);
  font-size: 1rem;
  flex-shrink: 0;
}

/* Nav principale */
.topbar-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.topbar-nav a {
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-pill);
  font-size: var(--text-small);
  font-weight: var(--fw-medium);
  color: var(--gray-600);
  transition: color var(--t-fast), background var(--t-fast);
  white-space: nowrap;
}

.topbar-nav a:hover,
.topbar-nav a[aria-current="page"] {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}

/* Burger */
.burger-btn {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  transition: background var(--t-fast);
  flex-shrink: 0;
}

.burger-btn:hover { background: var(--gray-100); }

.burger-line {
  display: block;
  width: 22px; height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform var(--t-normal), opacity var(--t-normal);
  transform-origin: center;
}

.burger-btn[aria-expanded="true"] .burger-line:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger-btn[aria-expanded="true"] .burger-line:nth-child(2) { opacity: 0; transform: scaleX(0); }
.burger-btn[aria-expanded="true"] .burger-line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Drawer mobile */
.mobile-drawer {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0;
  background: var(--color-white);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-fixed);
  padding: var(--sp-4) var(--sp-4) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  /*
    Bug fix : translateY(-110%) ne cachait pas toujours le drawer.
    Calcul exact : bord bas = top(68px) + H - translateY
    Avec calc(-100% - topbar-h) : bord bas = 68 + H - H - 68 = 0px → parfaitement caché.
    translateY(-200%) serait suffisant mais moins précis.
  */
  transform: translateY(calc(-100% - var(--topbar-h)));
  transition: transform var(--t-normal), visibility var(--t-normal);
  overflow-y: auto;
  max-height: calc(100vh - var(--topbar-h));
  pointer-events: none;
  visibility: hidden;
}

.mobile-drawer.is-open {
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
  transition: transform var(--t-normal);
}

.drawer-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--text-body);
  font-weight: var(--fw-medium);
  color: var(--gray-700);
  transition: background var(--t-fast), color var(--t-fast);
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

.drawer-link:hover,
.drawer-link[aria-current="page"] {
  background: var(--gray-100);
  color: var(--color-primary);
}

.drawer-link-danger {
  color: var(--color-danger);
}

.drawer-link-danger:hover {
  background: rgba(220, 38, 38, 0.1);
  color: var(--color-danger-dark);
}

.drawer-sep {
  height: 1px;
  background: var(--gray-200);
  margin: var(--sp-4) 0;
  border: none;
}

.drawer-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding-top: var(--sp-3);
}

/* Overlay fond quand drawer ouvert */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.35);
  z-index: calc(var(--z-fixed) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-normal);
}
.drawer-overlay.is-visible { opacity: 1; pointer-events: all; }


/* ================================================================
   FOOTER WEB
   ================================================================ */
.site-footer {
  background: var(--gray-900);
  color: rgba(255,255,255,.75);
  padding: var(--sp-16) 0 var(--sp-8);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--sp-10);
  margin-bottom: var(--sp-10);
}

.footer-brand .footer-logo {
  font-family: var(--font-heading);
  font-weight: var(--fw-bold);
  font-size: 1.2rem;
  color: var(--color-white);
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.footer-brand p {
  font-size: var(--text-small);
  color: rgba(255,255,255,.5);
  line-height: var(--lh-relaxed);
  max-width: 280px;
}

.footer-col-title {
  font-weight: var(--fw-semibold);
  color: var(--color-white);
  font-size: var(--text-small);
  margin-bottom: var(--sp-4);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: var(--text-caption);
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.footer-links a {
  font-size: var(--text-small);
  color: rgba(255,255,255,.5);
  transition: color var(--t-fast);
}

.footer-links a:hover { color: var(--color-white); }

.footer-contact-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-size: var(--text-small);
  color: rgba(255,255,255,.55);
  margin-bottom: var(--sp-2);
}

.footer-contact-icon { flex-shrink: 0; }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,.1);
  padding-top: var(--sp-6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-4);
}

.footer-copy { font-size: var(--text-caption); color: rgba(255,255,255,.35); }

.footer-legal {
  display: flex;
  gap: var(--sp-5);
}

.footer-legal a { font-size: var(--text-caption); color: rgba(255,255,255,.35); transition: color var(--t-fast); }
.footer-legal a:hover { color: rgba(255,255,255,.7); }


/* ================================================================
   LAYOUT ADMIN
   ================================================================ */
.admin-layout {
  display: flex;
  min-height: 100vh;
  background: var(--gray-50);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--color-primary);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--t-normal), width var(--t-normal);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5);
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

.sidebar-logo-text { font-family: var(--font-heading); font-weight: var(--fw-bold); color: var(--color-white); font-size: 1rem; }
.sidebar-logo-sub  { font-size: var(--text-caption); color: rgba(255,255,255,.55); margin-top: 1px; }

.sidebar-nav { padding: var(--sp-4) var(--sp-3); flex: 1; }

.sidebar-section { margin-bottom: var(--sp-5); }

.sidebar-section-label {
  font-size: 10px;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  padding: 0 var(--sp-3);
  margin-bottom: var(--sp-2);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7);
  font-size: var(--text-small);
  font-weight: var(--fw-medium);
  transition: background var(--t-fast), color var(--t-fast);
  margin-bottom: 2px;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}

.sidebar-link:hover              { background: rgba(255,255,255,.1); color: var(--color-white); }
.sidebar-link[aria-current="page"] { background: rgba(255,255,255,.18); color: var(--color-white); font-weight: var(--fw-semibold); }

.sidebar-link-icon  { width: 18px; height: 18px; flex-shrink: 0; text-align: center; }

.sidebar-link-badge {
  margin-left: auto;
  background: var(--color-accent);
  color: var(--color-white);
  font-size: 10px;
  font-weight: var(--fw-bold);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: var(--sp-4) var(--sp-3);
  border-top: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-user:hover { background: rgba(255,255,255,.1); }

.sidebar-user-name { font-weight: var(--fw-semibold); font-size: var(--text-small); color: var(--color-white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: var(--text-caption); color: rgba(255,255,255,.5); }
.sidebar-user-arrow { color: rgba(255,255,255,.4); margin-left: auto; flex-shrink: 0; }

/* Admin main */
.admin-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  height: 64px;
  background: var(--color-white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  gap: var(--sp-4);
}

.admin-page-title {
  font-family: var(--font-heading);
  font-weight: var(--fw-semibold);
  font-size: var(--text-h4);
  color: var(--color-text);
  white-space: nowrap;
}

.admin-topbar-left  { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.admin-topbar-right { display: flex; align-items: center; gap: var(--sp-3); flex-shrink: 0; }

.admin-content { padding: var(--sp-6); flex: 1; }

/* Burger admin (mobile) */
.admin-burger {
  display: none;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  transition: background var(--t-fast);
  flex-shrink: 0;
}
.admin-burger:hover { background: var(--gray-100); }


/* ================================================================
   BOTTOM NAVIGATION MOBILE (MC / MA)
   ================================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--color-white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  z-index: var(--z-fixed);
  padding-bottom: env(safe-area-inset-bottom, 0);
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0));
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: var(--sp-2) 0;
  color: var(--gray-400);
  cursor: pointer;
  transition: color var(--t-fast);
  position: relative;
  font-size: 10px;
  font-weight: var(--fw-medium);
  border: none;
  background: none;
  min-height: 44px;
}

.bottom-nav-item:hover,
.bottom-nav-item[aria-current="page"] { color: var(--color-primary); }

.bottom-nav-icon { position: relative; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; }

.bottom-nav-badge {
  position: absolute;
  top: -4px; right: -8px;
  background: var(--color-danger);
  color: var(--color-white);
  font-size: 9px;
  font-weight: var(--fw-bold);
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  min-width: 16px;
  text-align: center;
  line-height: 1.4;
}

/* Bouton central FAB */
.bottom-nav-fab {
  width: 52px; height: 52px;
  background: var(--color-primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-white);
  font-size: 1.5rem;
  margin-top: -26px;
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
}

/* Padding bas pour contenu avec bottom nav fixe */
/* Appliqué sur mobile réel (nav fixe) — ignoré sur desktop simulation (nav sticky) */
@media (max-width: 430px) {
  .page-with-bottom-nav {
    padding-bottom: calc(var(--bottom-nav-h) + var(--sp-6) + env(safe-area-inset-bottom, 0));
  }
}
/* Sur desktop dans le phone-frame, la nav est sticky (en flux), padding suffisant */
@media (min-width: 431px) {
  .page-with-bottom-nav {
    padding-bottom: var(--sp-4);
  }
}


/* ================================================================
   MOBILE APP HEADER (MC / MA)
   ================================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  padding: calc(env(safe-area-inset-top, 0) + var(--sp-3)) var(--sp-4) var(--sp-3);
}

.app-header.theme-primary { background: var(--color-primary); color: var(--color-white); }
.app-header.theme-white   { background: var(--color-white); color: var(--color-text); border-bottom: 1px solid var(--gray-200); }

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.app-back-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.15);
  color: inherit;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.app-header.theme-white .app-back-btn { background: var(--gray-100); color: var(--gray-600); }

.app-header-title {
  font-family: var(--font-heading);
  font-weight: var(--fw-semibold);
  font-size: 1.0625rem;
  flex: 1;
  text-align: center;
}

.app-header-action {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.15);
  color: inherit;
  font-size: 1.1rem;
  position: relative;
}

.app-header.theme-white .app-header-action { background: var(--gray-100); color: var(--gray-600); }


/* ================================================================
   SECTION HELPERS
   ================================================================ */
.section    { padding: var(--sp-8) 0; }
.section-sm { padding: var(--sp-6) 0; }
.section-lg { padding: var(--sp-10) 0; }
.section-xs { padding: var(--sp-5) 0; }

.section-head { margin-bottom: var(--sp-6); }
.section-head.center { text-align: center; }
.section-head.center .section-subtitle { margin-inline: auto; }

.section-title    { color: var(--color-text); margin-bottom: var(--sp-3); }
.section-subtitle { color: var(--gray-500); max-width: 560px; line-height: var(--lh-relaxed); }


/* ================================================================
   HERO
   ================================================================ */
.hero {
  background: linear-gradient(135deg, var(--color-primary) 0%, #163e9e 40%, #1a2c6b 100%);
  color: var(--color-white);
  padding: var(--sp-10) 0;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.hero-content { position: relative; z-index: 1; }

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-size: var(--text-small);
  font-weight: var(--fw-medium);
  margin-bottom: var(--sp-5);
}

.hero h1 {
  font-size: clamp(1.875rem, 5vw, 3rem);
  font-weight: var(--fw-bold);
  line-height: 1.15;
  margin-bottom: var(--sp-5);
  color: var(--color-white);
}

.hero-highlight { color: #6ee7b7; }

.hero-desc {
  font-size: clamp(var(--text-body), 2vw, 1.125rem);
  opacity: .85;
  max-width: 520px;
  line-height: var(--lh-relaxed);
  margin-bottom: var(--sp-8);
}

.hero-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); }


/* ================================================================
   RESPONSIVE NAVIGATION
   ================================================================ */
/* ── Overlay sidebar admin ───────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: calc(var(--z-fixed) - 1);
  opacity: 0;
  transition: opacity var(--t-normal);
}
.sidebar-overlay.is-visible {
  display: block;
  opacity: 1;
}

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: var(--z-fixed);
    transform: translateX(-100%);
  }

  .sidebar.is-open { transform: translateX(0); }

  .admin-main { width: 100%; }

  .admin-burger { display: flex; }
}

@media (max-width: 768px) {
  .topbar-nav    { display: none; }
  .topbar-actions .hide-mobile { display: none; }
  .burger-btn    { display: flex; }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-8);
  }

  .footer-brand { grid-column: 1 / -1; }

  .admin-topbar { padding: 0 var(--sp-4); }
  .admin-content { padding: var(--sp-4); }

  /* Titre tronqué — la gauche prend l'espace dispo, la droite ne réduit jamais */
  .admin-topbar-left {
    min-width: 0;        /* autorise la réduction de la zone gauche */
    overflow: hidden;
  }
  .admin-topbar-right {
    flex-shrink: 0;      /* la cloche + bouton ne bougent pas */
  }
  .admin-page-title {
    font-size: var(--text-body);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .admin-page-date { display: none; }
}

@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }

  /* ── Section padding ─────────────────────────────────────────── */
  .section    { padding: var(--sp-6) 0; }
  .section-lg { padding: var(--sp-8) 0; }
  .section-sm { padding: var(--sp-5) 0; }
  .site-footer { padding: var(--sp-10) 0 var(--sp-6); }

  /* ── Hero ────────────────────────────────────────────────────── */
  .hero { padding: var(--sp-8) 0; }
  .hero h1 { font-size: clamp(1.5rem, 8vw, 2rem); }
  .hero-desc { margin-bottom: var(--sp-6); }
  .hero-actions { gap: var(--sp-2); }

  /* ── CTA banner ──────────────────────────────────────────────── */
  .cta-banner { padding: var(--sp-6) var(--sp-5); gap: var(--sp-4); }
  .cta-banner h2 { font-size: var(--text-h4); }

  /* ── Topbar logo ─────────────────────────────────────────────── */
  .topbar-logo { font-size: 1rem; }
  .logo-mark { width: 34px; height: 34px; font-size: 0.875rem; }
}

/* ── Ultra petit (≤ 390px) — logo only + burger ─────────────── */
@media (max-width: 390px) {
  /* Cache les boutons CTA du topbar — accessibles dans le drawer */
  .topbar-actions .btn { display: none !important; }
  .topbar-logo { font-size: 0.9375rem; }
}

/* ── Admin : contenu extra petit ────────────────────────────── */
@media (max-width: 480px) {
  .admin-content { padding: var(--sp-3); }
}
