/* ═══════════════════════════════════════════════════════════════════════════
   adminlte.css — Shell AdminLTE 4
   v3.1 · Sidebar rétractable (rail 54px ↔ full 240px)
═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset body ── */
body {
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden; /* le scroll est géré par .al-content */
}

/* ── Wrapper ── */
.al-wrapper {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ════════════════════════════════
   SIDEBAR — largeur variable
════════════════════════════════ */
:root { --al-sb-w: 240px; --al-sb-rail: 54px; }

.al-sidebar {
  width: var(--al-sb-w);
  background: #0f172a;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  transition: width 0.22s ease;
  scrollbar-width: none; /* cacher scrollbar sidebar */
}
.al-sidebar::-webkit-scrollbar { display: none; }

/* ── MODE RAIL (icônes seules) ── */
.al-sidebar.rail {
  width: var(--al-sb-rail);
}

/* Éléments masqués en mode rail */
.al-sidebar.rail .al-brand-text,
.al-sidebar.rail .al-nav-name,
.al-sidebar.rail .al-section-toggle,
.al-sidebar.rail .al-badge-expert,
.al-sidebar.rail .al-sidebar-footer { display: none; }

/* Brand centré en rail */
.al-sidebar.rail .al-brand-link {
  justify-content: center;
  padding: 14px 0;
}

/* Items centrés en rail */
.al-sidebar.rail .al-nav-item {
  justify-content: center;
  padding: 11px 0;
  border-left-width: 0;
  border-bottom: 1px solid #1e293b;
}

/* Items dans sections toujours visibles en rail (même collapsées) */
.al-sidebar.rail .al-section-items { display: block !important; }

/* Icône centrée en rail */
.al-sidebar.rail .al-nav-icon {
  width: var(--al-sb-rail);
  font-size: 16px;
}

/* Tooltip au hover en rail */
.al-sidebar.rail .al-nav-item { position: relative; }
.al-sidebar.rail .al-nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--al-sb-rail) + 8px);
  top: 50%; transform: translateY(-50%);
  background: #1e293b;
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9999;
}
.al-sidebar.rail .al-nav-item:hover::after { opacity: 1; }

/* ── Brand ── */
.al-brand {
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
}
.al-brand-link {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  text-decoration: none;
  transition: background 0.15s;
}
.al-brand-link:hover { background: #1e293b; }
.al-brand-icon { font-size: 22px; flex-shrink: 0; }
.al-brand-text {}
.al-brand-name { font-size: 14px; font-weight: 700; color: #f1f5f9; line-height: 1.2; }
.al-brand-sub  { font-size: 10px; color: #64748b; margin-top: 1px; }

/* ── Navigation ── */
.al-nav { flex: 1; padding: 6px 0; }

.al-nav-section { border-bottom: 1px solid #1e293b; }
.al-nav-top     { border-bottom: 1px solid #1e293b; padding: 4px 0; }

.al-section-toggle {
  display: flex; align-items: center;
  width: 100%; padding: 6px 16px 4px;
  background: none; border: none; cursor: pointer; gap: 6px;
}
.al-section-label {
  font-size: 9px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: #475569; flex: 1;
}
.al-chevron {
  font-size: 10px; color: #334155;
  transition: transform 0.2s; display: inline-block;
}
.al-nav-section.collapsed .al-chevron   { transform: rotate(-90deg); }
.al-nav-section.collapsed .al-section-items { display: none; }

.al-section-items { padding: 2px 0 6px; }

.al-nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 16px;
  font-size: 12px; color: #94a3b8;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  border-left: 3px solid transparent;
  line-height: 1.3;
}
.al-nav-item:hover  { background: #1e293b; color: #e2e8f0; border-left-color: #334155; }
.al-nav-item.active { background: #1e3a8a; color: #bfdbfe; border-left-color: #3b82f6; }

.al-nav-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.al-nav-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.al-badge-expert {
  font-size: 8px; font-weight: 700;
  background: #581c87; color: #e9d5ff;
  padding: 1px 5px; border-radius: 4px; flex-shrink: 0;
}

/* ── Portfolio pill ── */
.al-portfolio-pill {
  display: inline-block;
  background: #1d4ed8; color: #bfdbfe;
  font-size: 9px; font-weight: 700;
  padding: 1px 6px; border-radius: 99px; margin-left: 4px;
}

/* ── Footer sidebar ── */
.al-sidebar-footer { border-top: 1px solid #1e293b; padding: 10px 12px; flex-shrink: 0; }
.al-mode-toggle {
  width: 100%; padding: 7px 10px;
  background: #1e293b; border: 1px solid #334155; border-radius: 6px;
  color: #94a3b8; font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; text-align: center;
}
.al-mode-toggle:hover { background: #27374d; color: #e2e8f0; }

/* ── Overlay mobile ── */
.al-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999; }
.al-overlay.visible { display: block; }

/* ════════════════════════════════
   MAIN AREA
════════════════════════════════ */
.al-main {
  flex: 1;
  margin-left: var(--al-sb-w);
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  overflow: hidden;
  transition: margin-left 0.22s ease;
}

/* Main décalé quand sidebar en rail */
.al-main.rail { margin-left: var(--al-sb-rail); }

/* ════════════════════════════════
   TOPBAR
════════════════════════════════ */
.al-topbar {
  height: 52px;
  background: var(--color-bg, #fff);
  border-bottom: 1px solid var(--color-border, #e2e8f0);
  display: flex; align-items: center;
  padding: 0 14px; gap: 8px;
  flex-shrink: 0; z-index: 100;
}

/* Hamburger TOUJOURS visible (toggle rail/full desktop + overlay mobile) */
.al-hamburger {
  display: flex; flex-direction: column;
  justify-content: center; gap: 4px;
  width: 30px; height: 30px;
  background: none; border: none; cursor: pointer;
  padding: 5px; border-radius: 6px; flex-shrink: 0;
}
.al-hamburger:hover { background: var(--color-bg2, #f4f4f5); }
.al-hamburger span  { display: block; height: 2px; background: var(--color-text2, #52525b); border-radius: 1px; }

.al-topbar-title {
  font-size: 14px; font-weight: 600;
  color: var(--color-text, #18181b);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}
.al-topbar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.al-btn {
  padding: 6px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; border: none; text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
  transition: all 0.15s; white-space: nowrap;
}
.al-btn-ghost {
  background: var(--color-bg2, #f4f4f5); color: var(--color-text2, #52525b);
  border: 1px solid var(--color-border, #d4d4d8);
}
.al-btn-ghost:hover { background: var(--color-bg3, #e4e4e7); color: var(--color-text, #18181b); }
.al-btn-primary { background: #185fa5; color: #fff; }
.al-btn-primary:hover { background: #0c447c; }

/* ════════════════════════════════
   CONTENT AREA
════════════════════════════════ */
.al-content {
  flex: 1;
  min-height: 0;          /* flex trick : permet le scroll vertical */
  overflow-y: auto;
  overflow-x: hidden;     /* pas d'ascenseur horizontal */
  background: var(--color-bg, #fafafa);
}

/* Empêcher le contenu interne de dépasser la largeur disponible */
.al-content .app {
  box-sizing: border-box;
  max-width: 100%;
  padding-top: 1rem;
  padding-bottom: 2rem;
  overflow-x: hidden;
}

/* ── Back to top ── */
.al-back-top {
  position: fixed; bottom: 20px; right: 18px;
  width: 36px; height: 36px; border-radius: 50%;
  background: #185fa5; color: #fff;
  border: none; font-size: 16px; cursor: pointer;
  z-index: 9998; opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.al-back-top.visible { opacity: 1; pointer-events: auto; }
.al-back-top:hover { background: #0c447c; }

/* ════════════════════════════════
   DARK MODE
════════════════════════════════ */
[data-theme="dark"] .al-topbar  { background: #1a1a1f; border-bottom-color: #2e2e38; }
[data-theme="dark"] .al-content { background: #0f0f11; }
[data-theme="dark"] .al-btn-ghost { background: #27272e; color: #a1a1aa; border-color: #3a3a44; }
[data-theme="dark"] .al-btn-ghost:hover { background: #3a3a44; color: #f4f4f5; }
[data-theme="dark"] .al-hamburger span { background: #a1a1aa; }
[data-theme="dark"] .al-hamburger:hover { background: #27272e; }

/* ════════════════════════════════
   MOBILE < 768px
════════════════════════════════ */
@media (max-width: 768px) {
  .al-sidebar {
    width: var(--al-sb-w) !important; /* sidebar pleine sur mobile, cachée par défaut */
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .al-sidebar.open { transform: translateX(0); }
  .al-main { margin-left: 0 !important; }
  .al-topbar-title { font-size: 13px; }
}

/* ════════════════════════════════
   RELATED BAR
════════════════════════════════ */
.al-content .related-bar {
  position: sticky; bottom: 0;
  background: var(--color-bg2, #f4f4f5);
  border-top: 1px solid var(--color-border, #d4d4d8);
  z-index: 10;
}
