/* ============================================
   PANEL.CSS — Layout sidebar + topbar
   Utilisé via base.html
   ============================================ */

/* ── Layout racine ── */
.panel-layout {
  display: flex;
  min-height: 100vh;
  overflow: hidden;
}

/* ══════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════ */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition), transform var(--transition);
  z-index: 100;
}

/* Scrollbar ultra fine dans la sidebar */
.sidebar::-webkit-scrollbar { width: 2px; }

/* ── Brand ── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1.25rem 1.1rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-brand .brand-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand .brand-icon svg {
  width: 13px;
  height: 13px;
  color: var(--text-inverse);
}

.sidebar-brand .brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
}

/* ── Nav ── */
.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* ── Group ── */
.nav-group {
  display: flex;
  flex-direction: column;
}

.nav-group-trigger {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1.1rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  width: 100%;
  text-align: left;
  border-radius: 0;
  transition: color var(--transition), background var(--transition);
  position: relative;
}

.nav-group-trigger:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.nav-group.open .nav-group-trigger {
  color: var(--text-primary);
}

.nav-group-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.nav-group-icon svg {
  width: 14px;
  height: 14px;
}

.nav-group-label {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
}

.nav-chevron {
  display: flex;
  align-items: center;
  margin-left: auto;
  transition: transform var(--transition);
  flex-shrink: 0;
}

.nav-chevron svg {
  width: 12px;
  height: 12px;
}

.nav-group.open .nav-chevron {
  transform: rotate(180deg);
}

/* ── Submenu ── */
.nav-sub {
  display: flex;
  flex-direction: column;
  max-height: 0;
  overflow: hidden;
  transition: max-height 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-group.open .nav-sub {
  max-height: 300px;
}

.nav-sub > * {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.nav-sub-item {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.42rem 1.1rem 0.42rem 2.5rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

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

.nav-sub-item.active {
  color: var(--accent);
}

.nav-sub-item.active .sub-dot {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
}

.sub-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}

/* Ligne verticale gauche pour les groupes ouverts */
.nav-group.open .nav-sub-item::before {
  content: '';
  position: absolute;
  left: 1.55rem;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border-subtle);
}

/* ── Sidebar footer ── */
.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border-subtle);
  padding: 0.85rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.7rem;
  color: var(--accent);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}

.user-name {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.62rem;
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color var(--transition), background var(--transition);
}

.logout-btn:hover {
  color: var(--danger);
  background: var(--danger-dim);
}

.logout-btn svg {
  width: 14px;
  height: 14px;
}

/* ══════════════════════════════════════════
   MAIN + TOPBAR
══════════════════════════════════════════ */
.panel-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── Topbar ── */
.panel-topbar {
  height: 52px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}

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

.sidebar-toggle svg {
  width: 15px;
  height: 15px;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
}

.breadcrumb-root {
  font-size: 0.65rem;
}

.breadcrumb-sep {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Status pill */
.status-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 0.28rem 0.75rem;
  font-size: 0.65rem;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online {
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
  animation: pulse-dot 2.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* Topbar icon buttons */
.topbar-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.topbar-btn:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.topbar-btn svg {
  width: 15px;
  height: 15px;
}

.topbar-btn-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
}

/* Clock */
.topbar-clock {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  min-width: 56px;
  text-align: right;
}

/* ── Content area ── */
.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 2.5rem;
}

/* ══════════════════════════════════════════
   HOME PAGE
══════════════════════════════════════════ */
.home-hero {
  padding-top: 1rem;
}

.home-greeting {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.home-greeting .step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  flex-shrink: 0;
}

.home-title {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  line-height: 1.05;
  margin-bottom: 0.6rem;
}

.home-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ══════════════════════════════════════════
   SIDEBAR COLLAPSED (toggle)
══════════════════════════════════════════ */
.panel-layout.sidebar-collapsed .sidebar {
  width: 52px;
}

.panel-layout.sidebar-collapsed .brand-name,
.panel-layout.sidebar-collapsed .nav-group-label,
.panel-layout.sidebar-collapsed .nav-chevron,
.panel-layout.sidebar-collapsed .nav-sub,
.panel-layout.sidebar-collapsed .user-info,
.panel-layout.sidebar-collapsed .user-name,
.panel-layout.sidebar-collapsed .user-role {
  display: none;
}

.panel-layout.sidebar-collapsed .nav-group-trigger {
  justify-content: center;
  padding: 0.6rem;
}

.panel-layout.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 1.25rem 0.6rem 1rem;
}

.panel-layout.sidebar-collapsed .sidebar-footer {
  justify-content: center;
  padding: 0.85rem 0.6rem;
}

.panel-layout.sidebar-collapsed .sidebar-user {
  justify-content: center;
}

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    transform: translateX(-100%);
    width: 220px !important;
  }

  .panel-layout.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .panel-layout.sidebar-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
  }

  .panel-content {
    padding: 1.5rem 1.25rem;
  }
}