/* ============================================================
   Shell applicatif — un seul canevas blanc borné et centré,
   sidebar flottante embarquée (DS « Style Partoo »).
   ============================================================ */

/* ===== VIEWPORT & SHELL =====
   Full-bleed (écart assumé au prototype, demandé le 05/08/2026) :
   le shell occupe toute la fenêtre ; la sidebar flottante garde
   ses marges et son rayon pour conserver le langage du DS. */
.app-viewport {
  height: 100dvh;
  overflow: hidden;
}

.app-shell {
  width: 100%;
  height: 100dvh;
  display: flex;
  min-width: 0;
  background: var(--surface-card);
  overflow: hidden;
}

/* ===== SIDEBAR FLOTTANTE ===== */
.app-sidebar {
  width: 222px;
  flex: none;
  background: var(--surface-sidebar);
  border-radius: 24px;
  box-shadow: var(--shadow-panel-soft), 0 0 0 1px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 18px;
  margin: 14px 0 14px 12px;
  overflow-y: auto;
  min-height: 0;
}

.app-sidebar__logo {
  padding: 4px 8px 6px;
}
.app-sidebar__logo img {
  width: 132px;
  height: auto;
  display: block;
}

/* Déclencheur de la command palette */
.app-sidebar__search {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: transparent;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  margin: 16px 0 20px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.16s ease;
  text-align: left;
}
.app-sidebar__search:hover { border-color: rgba(15, 23, 42, 0.16); }
.app-sidebar__search-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  flex: 1;
}
.app-sidebar__search-kbd {
  font-size: 10px;
  color: #B5BAC4;
}
.app-sidebar__search .lucide {
  width: 13px;
  height: 13px;
  color: var(--gray-400);
  flex: none;
}

/* Groupes de navigation */
.app-sidebar__group-label {
  font-size: 10.5px;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #C1C5CE;
  padding: 0 10px 8px;
}
.app-sidebar__group-label:not(:first-of-type) { padding-top: 24px; }
.app-sidebar__group-label--first { padding-top: 22px; }

.app-sidebar__group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-sidebar__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: var(--weight-medium);
  color: #5B6172;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.app-sidebar__item:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}
.app-sidebar__item.is-active {
  background: var(--accent);
  color: #fff;
  font-weight: var(--weight-semibold);
  box-shadow: 0 6px 14px -6px rgba(86, 93, 246, 0.55);
}
.app-sidebar__item.is-active:hover { background: var(--accent-hover); }
.app-sidebar__item .lucide {
  width: 16px;
  height: 16px;
  flex: none;
}
.app-sidebar__item-count {
  margin-left: auto;
  font-size: var(--text-xs);
  opacity: 0.7;
}

/* Pied de sidebar : jauge + profil */
.app-sidebar__footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 20px;
}

.app-sidebar__me {
  display: flex;
  align-items: center;
  gap: 4px;
}
.app-sidebar__me-profile {
  flex: 1;
  min-width: 0;
}

.app-sidebar__bell {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: var(--gray-400);
  transition: background 0.16s ease, color 0.16s ease;
}
.app-sidebar__bell:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}
.app-sidebar__bell .lucide { width: 16px; height: 16px; }
.app-sidebar__bell-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid var(--surface-sidebar);
}

.app-sidebar__profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background 0.16s ease;
  width: 100%;
  background: transparent;
  border: 0;
  text-align: left;
  font-family: inherit;
}
.app-sidebar__profile:hover { background: var(--gray-100); }
.app-sidebar__profile-body { flex: 1; min-width: 0; }
.app-sidebar__profile-name {
  font-size: 13px;
  font-weight: var(--weight-semibold);
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-sidebar__profile-role {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== ZONE PRINCIPALE ===== */
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface-card);
}

.app-header {
  flex: none;
  height: 60px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  /* backdrop-filter crée un contexte d'empilement : sans étage explicite,
     tout élément positionné du contenu (cartes en position relative) passe
     au-dessus des dropdowns du header (menu profil, notifications). */
  position: relative;
  z-index: 500;
}
.app-header__spacer { flex: 1; }

.app-header__burger {
  display: none;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: #fff;
  border: 1px solid var(--gray-200);
  color: var(--gray-600);
  transition: border-color 0.16s ease;
}
.app-header__burger:hover { border-color: var(--gray-300); }
.app-header__burger .lucide { width: 17px; height: 17px; }

.app-header__logo { display: none; }
.app-header__logo img { width: 118px; height: auto; }

/* Recherche du header (ouvre la palette) */
.app-header__search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  padding: 9px 14px;
  width: 260px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.16s ease;
  text-align: left;
}
.app-header__search:hover { border-color: var(--gray-300); }
.app-header__search-label {
  flex: 1;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
}
.app-header__search .lucide {
  width: 13px;
  height: 13px;
  color: #A7ADB9;
  flex: none;
}

/* Profil dans le header */
.app-header__profile {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 5px;
  border: none;
  background: transparent;
  border-radius: var(--radius-full);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.16s ease;
}
.app-header__profile:hover { background: var(--gray-100); }
.app-header__profile-name {
  font-size: 13px;
  font-weight: var(--weight-semibold);
  color: var(--gray-900);
  white-space: nowrap;
}

/* Cloche de notifications */
.app-header__bell {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: var(--radius-full);
  background: #fff;
  border: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: var(--gray-600);
  transition: border-color 0.16s ease;
}
.app-header__bell:hover { border-color: var(--gray-300); color: var(--gray-700); }
.app-header__bell .lucide { width: 15px; height: 15px; }
.app-header__bell-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
}

/* Contenu défilant */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 32px;
}
.app-content__inner {
  max-width: 1320px;
  margin: 0 auto;
  animation: fadeUp 0.35s ease;
}

/* En-tête de page standard */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head__title {
  font-size: 32px;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  margin: 0;
}
.page-head__subtitle {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin-top: 6px;
}
.page-head__actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex: none;
}

/* Backdrop du tiroir mobile */
.app-sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 26, 34, 0.34);
  z-index: 1040;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* ===== MOBILE / TABLETTE : shell plein écran, sidebar off-canvas ===== */
@media (max-width: 991.98px) {
  .app-viewport {
    height: auto;
    overflow: visible;
  }
  .app-shell {
    height: auto;
    min-height: 100dvh;
    flex-direction: column;
  }
  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(300px, 84vw);
    margin: 0;
    border-radius: 0 24px 24px 0;
    z-index: 1050;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-panel-strong);
  }
  .app-shell.is-sidebar-open .app-sidebar { transform: none; }
  .app-shell.is-sidebar-open .app-sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  .app-main { overflow: visible; }
  .app-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    border-bottom: 1px solid var(--border-subtle);
  }
  .app-header__burger { display: flex; }
  .app-header__logo { display: block; }
  .app-header__search { display: none; }
  .app-header__profile-name { display: none; }
  .app-content {
    overflow: visible;
    padding: 16px 16px 32px;
  }
  .page-head__title { font-size: 26px; }
}

/* ===== MODE CONCENTRATION ====================================================
   Certains écrans travaillent en largeur — le tableau de réorganisation en
   premier. Les deux niveaux de navigation s'effacent alors ensemble : la
   barre latérale et le rail d'administration. On ne les supprime pas, on les
   replie, et un bouton les ramène.

   Le repli se fait à la largeur, pas en `display: none` : c'est ce qui permet
   au contenu de s'étaler d'un mouvement continu plutôt que de sauter.

   Sur mobile, la barre latérale est déjà hors champ derrière son bouton : le
   mode n'a rien à y replier, et s'y appliquer casserait le tiroir.
   ========================================================================== */
@media (min-width: 992px) {
  .app-sidebar {
    transition: width 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                margin 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.18s ease;
  }
  /* La barre de sections se replie en hauteur — elle est horizontale. */
  .admin-bar {
    transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                border-width 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.18s ease;
    max-height: 120px;
  }
  .admin-shell { transition: gap 0.32s cubic-bezier(0.4, 0, 0.2, 1); }

  body.is-focus .app-sidebar {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    margin-left: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
  }

  body.is-focus .admin-bar {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
  }
  body.is-focus .admin-shell { gap: 0; }
}

/* Le bouton qui commande le mode. Deux libellés dans le document, un seul
   visible : l'état est porté par le CSS, le script ne fait que basculer une
   classe. */
.focus-toggle__expand { display: none; }
body.is-focus .focus-toggle__collapse { display: none; }
body.is-focus .focus-toggle__expand { display: inline; }
