/* Feuille de style uniquement pour le rendu du chassis de la PWA (sidebar, layout principal) */
/* Contient la sidebar, le menu burger, le layout content, et les styles responsive */

/* === Layout principal === */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  background-color: var(--color-bg);
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background-color: #f4f5f7;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-normal), min-width var(--transition-normal);
  z-index: var(--z-sidebar);
  overflow: hidden;
}

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

/* Logo / Header sidebar */
.sidebar-header {
  display: flex;
  align-items: center;
  padding: var(--space-md);
  height: 56px;
  gap: var(--space-sm);
}

.sidebar-header .logo-text {
  font-size: 17px;
  font-weight: 900;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  letter-spacing: -0.02em;
}

.sidebar.collapsed .logo-text {
  display: none;
}

/* Bell notification button — sidebar (desktop) */
.bell-btn-header { display: none; } /* masquée sur desktop, visible sur mobile */
.bell-btn {
  width: 30px; height: 30px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-secondary); cursor: pointer;
  background: none; border: none; position: relative; flex-shrink: 0;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  margin-left: auto;
}
.bell-btn:hover { background-color: var(--color-bg-hover); color: var(--color-text); }
.bell-btn svg { width: 17px; height: 17px; }
.bell-dot {
  position: absolute; top: 4px; right: 4px; width: 7px; height: 7px;
  border-radius: 50%; background: #ef4444; border: 1.5px solid #f4f5f7; display: none;
}
.sidebar.collapsed .bell-btn { margin-left: 0; }

/* Notification panel */
.notif-panel {
  position: fixed; top: 0; left: 0; width: 290px; height: 100%;
  background: #fff; border-right: 1px solid var(--color-border);
  z-index: calc(var(--z-sidebar) + 1); display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform .25s cubic-bezier(.4,0,.2,1);
  box-shadow: 4px 0 20px rgba(0,0,0,.1);
}
.notif-panel.open { transform: translateX(var(--sidebar-width)); }
.notif-panel-header {
  padding: 16px; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.notif-panel-title { font-size: 15px; font-weight: 700; color: #111; }
.notif-panel-close {
  width: 28px; height: 28px; border-radius: var(--radius-md); border: none;
  background: none; cursor: pointer; display: flex; align-items: center;
  justify-content: center; color: var(--color-text-secondary);
}
.notif-panel-close:hover { background: var(--color-bg-hover); }
.notif-section { padding: 14px 16px; border-bottom: 1px solid var(--color-border); flex-shrink: 0; }
.notif-section-last { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.notif-section-title {
  font-size: 10px; font-weight: 700; color: #999;
  text-transform: uppercase; letter-spacing: .8px; margin-bottom: 10px;
}
.notif-push-row { display: flex; align-items: center; gap: 10px; }
.notif-push-info { flex: 1; min-width: 0; }
.notif-push-status { font-size: 13px; font-weight: 500; color: #111; }
.notif-push-sub { font-size: 11px; color: #888; margin-top: 3px; line-height: 1.4; }
.notif-push-btn {
  padding: 6px 13px; border-radius: 8px; border: none; font-size: 12px;
  font-weight: 600; cursor: pointer; font-family: inherit; white-space: nowrap; flex-shrink: 0;
}
.notif-push-btn.enable { background: #6366f1; color: #fff; }
.notif-push-btn.disable { background: #f1f1f5; color: #666; border: 1px solid #e0e0e0; }
.notif-interactions-list { flex: 1; overflow-y: auto; }
.notif-empty { padding: 32px 16px; text-align: center; color: #bbb; font-size: 13px; line-height: 1.7; }
.notif-empty svg { width: 32px; height: 32px; opacity: .25; margin: 0 auto 10px; display: block; }

@media (max-width: 768px) {
  .notif-panel.open { transform: translateX(0); }
  .notif-panel { width: min(290px, 100vw); }
  .bell-btn-header { display: flex; margin-left: 0; }
  .bell-btn:not(.bell-btn-header) { display: none; }
}

.sidebar-toggle {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--color-text-secondary);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
  outline: none;
}

.sidebar-toggle:hover {
  background-color: var(--color-bg-hover);
  color: var(--color-text);
}

.sidebar-toggle:focus-visible {
  box-shadow: 0 0 0 2px var(--color-bg-hover, #e8e8e8);
}

/* Navigation sidebar */
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-sm);
  gap: 2px;
  overflow-y: auto;
}

.nav-spacer {
  flex: 1;
  min-height: var(--space-sm);
}

.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--space-md) 4px;
  cursor: pointer;
  user-select: none;
  gap: 6px;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  opacity: 0.6;
  white-space: nowrap;
  overflow: hidden;
  flex: 1;
}

.nav-group-chevron {
  flex-shrink: 0;
  color: var(--color-text-secondary);
  opacity: 0.5;
  transition: transform 0.2s ease;
}

.nav-group.collapsed .nav-group-chevron {
  transform: rotate(-90deg);
}

.nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  max-height: 400px;
  opacity: 1;
}

.nav-group.collapsed .nav-group-items {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar.collapsed .nav-group-header { display: none; }
.sidebar.collapsed .nav-group-items { max-height: 400px; opacity: 1; pointer-events: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-weight: 500;
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}

.nav-item:hover {
  background-color: var(--color-bg-hover);
  color: var(--color-text);
}

.nav-item.active {
  background-color: rgba(10, 10, 10, 0.08);
  color: #0a0a0a;
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item .nav-icon svg {
  width: 20px;
  height: 20px;
}

.nav-item .nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar.collapsed .nav-label {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: var(--space-sm);
}

/* === Zone de contenu === */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: #fff;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  height: 56px;
  border-bottom: 1px solid var(--color-border);
  background-color: var(--color-surface);
}

.content-header .page-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.content-body {
  flex: 1;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* === Menu burger (mobile) === */
.burger-btn {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text);
  background: none;
  border: none;
  cursor: pointer;
  z-index: calc(var(--z-sidebar) + 1);
}

/* Overlay mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: calc(var(--z-sidebar) - 1);
}

/* === Login / Setup === */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  background-color: var(--color-bg);
}

.auth-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.auth-card h1 {
  font-size: var(--font-size-2xl);
  margin-bottom: var(--space-xs);
}

.auth-card .auth-subtitle {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-lg);
}

.auth-card .form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.auth-card .form-group label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-weight: 500;
}

.auth-card .form-group input {
  width: 100%;
}

.auth-card .auth-error {
  color: var(--color-error);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-md);
  display: none;
}

.auth-card .auth-error.visible {
  display: block;
}

.auth-card .btn {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  margin-top: var(--space-sm);
}

/* === Bottom navigation bar (mobile uniquement) === */
.mobile-bottom-nav {
  display: none;
}

/* === Responsive (mobile) === */
@media (max-width: 768px) {
  /* Pas de bottom tab bar implementee cote HTML : navigation mobile = tiroir sidebar ouvert par le
     burger (deja cable en JS via initSidebar — burgerBtn toggle .mobile-open, overlay ferme). */
  /* Menu mobile = page pleine largeur (pas un tiroir etroit), coherent avec le reste de l'app qui
     ouvre des pages completes plutot que des popups. */
  .sidebar {
    display: flex !important;
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    min-width: 100% !important;
    background-color: #f4f5f7 !important;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    z-index: 1000 !important;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay { display: none !important; }
  .burger-btn { display: flex !important; }
  .sidebar-toggle { display: none; }

  /* Header mobile : burger a gauche, titre centre */
  .content-header {
    justify-content: space-between;
    padding: 0 var(--space-md);
  }
  .content-header > div:last-child { display: none; }

  /* Zone de contenu prend tout l'écran */
  .content-area { width: 100%; }

  /* Bottom tab bar */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e8e8e8;
    z-index: 300;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 10px 4px 8px;
    cursor: pointer;
    color: #bbb;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-tab:active { background: #f5f5f5; }

  .mobile-tab.active {
    color: #000;
  }

  .mobile-tab svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.8;
  }

  .mobile-tab-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
  }
}
