/* Strapontin — layout : sidebar, contenu, nav mobile, auth */

/* ── Layout application (sidebar + contenu) ─────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
}

.sidebar-logo {
  padding: 1.25rem 1rem;
  font-size: 1.125rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  color: var(--fg-muted);
  font-size: 0.875rem;
  font-weight: 500;
  position: relative;
  transition:
    background 0.15s,
    color 0.15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.actif {
  background: var(--accent);
  color: var(--accent-fg);
}

.sidebar-nav a.actif {
  view-transition-name: nav-actif;
}

.sidebar-nav hr {
  margin: 0.5rem 0;
  border-color: var(--border);
}

.sidebar-footer {
  padding: 0.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.sidebar-footer hr {
  margin: 0.25rem 0;
  border-color: var(--border);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  color: var(--fg-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition:
    background 0.15s,
    color 0.15s;
}

.icon {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
}

.sidebar-footer a:hover,
.sidebar-footer a.actif {
  background: var(--accent);
  color: var(--accent-fg);
}

.sidebar-footer a.actif {
  view-transition-name: nav-actif;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  gap: 0.5rem;
}

.sidebar-user > span {
  font-size: 0.875rem;
  color: var(--fg-muted);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-deconnexion {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.8125rem;
  color: var(--fg-muted);
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: color 0.15s;
}

.btn-deconnexion:hover {
  color: var(--fg);
}

.main-content {
  margin-left: max(
    var(--sidebar-w),
    calc((100vw + var(--sidebar-w) - 1100px) / 2)
  );
  flex: 1;
  padding: 2rem;
  max-width: 1100px;
  view-transition-name: zone-principale;
  overflow-x: clip;
}

/* ── Navigation mobile (bottom nav) ─────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 10;
}

.bottom-nav-items {
  display: flex;
  height: 100%;
}

.bottom-nav-items a,
.bottom-nav-plus {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  font-size: 0.6875rem;
  color: var(--fg-muted);
  transition: color 0.15s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

.bottom-nav-items a.actif,
.bottom-nav-items a:hover,
.bottom-nav-plus.actif,
.bottom-nav-plus:hover {
  color: var(--fg);
}

.bottom-nav-items a.actif {
  view-transition-name: nav-actif;
}

/* Drawer navigation mobile (dialog natif) */
#dialog-nav-plus {
  position: fixed;
  inset: auto 0 calc(var(--nav-h) + env(safe-area-inset-bottom)) 0;
  margin: 0;
  width: 100%;
  max-width: 100%;
  max-height: 80vh;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0.75rem 0.75rem 0 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
  animation: drawer-entree 0.25s ease;
}

@keyframes drawer-entree {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

#dialog-nav-plus::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.dark #dialog-nav-plus::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.dialog-nav-handle {
  width: 2.5rem;
  height: 0.25rem;
  background: var(--border);
  border-radius: 9999px;
  margin: 0.75rem auto 0.25rem;
}

.dialog-nav-contenu {
  padding: 0.25rem 0.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.dialog-nav-contenu a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  color: var(--fg-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  transition:
    background 0.15s,
    color 0.15s;
}

.dialog-nav-contenu a:hover,
.dialog-nav-contenu a.actif {
  background: var(--accent);
  color: var(--accent-fg);
}

.dialog-nav-sep {
  margin: 0.25rem 0;
  border-color: var(--border);
}

.dialog-nav-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
}

/* Badge nouveautés — bottom nav */
.bottom-nav-badge-wrapper {
  position: relative;
  display: inline-flex;
}

.nav-badge {
  position: absolute;
  top: -0.25rem;
  right: -0.5rem;
  min-width: 1rem;
  height: 1rem;
  background: var(--danger);
  color: #fff;
  border-radius: 9999px;
  font-size: 0.5625rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.2rem;
  pointer-events: none;
  line-height: 1;
}

/* Badge sidebar desktop — positionné sur le lien nav */
.nav-badge--sidebar {
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
}

/* Fix view-transition : isoler la bottom nav de la transition root */
.bottom-nav {
  view-transition-name: barre-nav-mobile;
}

::view-transition-old(barre-nav-mobile),
::view-transition-new(barre-nav-mobile) {
  animation: none;
}

@media (max-width: 1024px) {
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  }
  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 1rem);
  }
}

/* ── Page auth (login, forgot, reset, setup) ─────────────── */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-muted);
  padding: 1rem;
}

.auth-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.auth-logo {
  text-align: center;
  margin-bottom: 1rem;
}

.auth-logo img {
  width: 160px;
  height: auto;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.auth-subtitle {
  color: var(--fg-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}
