/* ============================
   SIDEBAR NAVIGATION — COLLAPSIBLE
   Collapsed by default (icons only)
   Expands on hover, collapses 1s after mouse leave
   ============================ */

/* ============================
   CSS VARIABLES
   ============================ */
:root {
  --sidebar-width-expanded: 220px;
  --sidebar-width-collapsed: 60px;
  --sidebar-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================
   SIDEBAR BASE — COLLAPSED STATE (default)
   ============================ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width-collapsed);
  z-index: 150;
  background: linear-gradient(180deg, #F5F3FF 0%, #EDE9FE 40%, #F8F7FF 100%);
  border-right: 1px solid rgba(139,92,246,0.10);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  transition: width var(--sidebar-transition);
  scrollbar-width: thin;
  scrollbar-color: rgba(139,92,246,0.15) transparent;
  box-shadow: 1px 0 12px rgba(108,58,237,0.04);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(139,92,246,0.15); border-radius: 4px; }

/* ============================
   EXPANDED STATE (hover or JS class)
   ============================ */
.sidebar.expanded {
  width: var(--sidebar-width-expanded);
}

/* ============================
   LOGO
   ============================ */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(139,92,246,0.08);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-logo .logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #1E1B4B;
  letter-spacing: -0.3px;
  opacity: 0;
  transition: opacity 0.2s ease 0.05s;
}
.sidebar.expanded .sidebar-logo .logo-text {
  opacity: 1;
}
.sidebar-logo .logo-gradient {
  background: linear-gradient(135deg, #8B5CF6, #F97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
/* Collapsed logo: show a small icon/initial */
.sidebar-logo::before {
  content: "🤖";
  font-size: 22px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

/* ============================
   SECTIONS
   ============================ */
.sidebar-section {
  padding: 10px 0 4px;
}

.sidebar-section-title {
  padding: 0 14px;
  margin: 0 0 6px 0;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(107,114,128,0.50);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  opacity: 0;
  height: 0;
  transition: opacity 0.2s ease, height 0.2s ease;
}
.sidebar.expanded .sidebar-section-title {
  opacity: 1;
  height: auto;
  margin-bottom: 6px;
}

.sidebar-items {
  display: flex;
  flex-direction: column;
}

.sidebar-divider {
  height: 1px;
  margin: 6px 10px;
  background: rgba(139,92,246,0.06);
}

/* ============================
   SIDEBAR ITEMS
   ============================ */
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  margin: 1px 6px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #6B7280;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-item:hover {
  background: rgba(139,92,246,0.07);
  color: #4C1D95;
}
.sidebar-item.active {
  background: rgba(108,58,237,0.10);
  color: #6C3AED;
  font-weight: 600;
}

/* Icon */
.sidebar-icon {
  font-size: 18px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 6px;
  transition: background 0.15s;
  color: inherit;
}
.sidebar-icon svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.sidebar-item:hover .sidebar-icon svg {
  color: #6C3AED;
}
.sidebar-item.active .sidebar-icon svg {
  color: #6C3AED;
}
/* In collapsed state, center the icons */
.sidebar:not(.expanded) .sidebar-icon {
  width: 32px;
  height: 32px;
  margin: 0 auto;
}
.sidebar:not(.expanded) .sidebar-item {
  justify-content: center;
  padding: 8px 6px;
  margin: 1px 4px;
}

/* Text labels: hidden when collapsed */
.sidebar-item > span:not(.sidebar-icon) {
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.2s ease 0.05s, width 0.2s ease;
}
.sidebar.expanded .sidebar-item > span:not(.sidebar-icon) {
  opacity: 1;
  width: auto;
}

.sidebar-badge {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(249,115,22,0.10);
  color: #EA580C;
  opacity: 0;
  transition: opacity 0.2s;
}
.sidebar.expanded .sidebar-badge {
  opacity: 1;
}

/* ============================
   TOOLTIP on collapsed items
   ============================ */
.sidebar:not(.expanded) .sidebar-item {
  position: relative;
}
.sidebar:not(.expanded) .sidebar-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: #1E1B4B;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.sidebar:not(.expanded) .sidebar-item:hover::after {
  opacity: 1;
}

/* ============================
   PUSH MAIN CONTENT (WP selectors)
   ============================ */
body.has-sidebar-nav header.wp-block-template-part,
body.has-sidebar-nav main.wp-block-group.site-main,
body.has-sidebar-nav main.site-main,
body.has-sidebar-nav footer.wp-block-template-part,
body.has-sidebar-nav .wp-site-blocks > .wp-block-group.alignfull,
body.has-sidebar-nav .wp-site-blocks > .wp-block-group.hero-compact,
body.has-sidebar-nav .wp-site-blocks > .cia-hero,
body.has-sidebar-nav .wp-site-blocks > .hero-compact,
body.has-sidebar-nav .wp-site-blocks > section.hero,
body.has-sidebar-nav .tuto-hero,
body.has-sidebar-nav .tuto-layout,
body.has-sidebar-nav .tuto-transparence {
  margin-left: var(--sidebar-width-collapsed) !important;
  transition: margin-left var(--sidebar-transition);
}
/* When sidebar expanded, push content further */
body.has-sidebar-nav.sidebar-expanded header.wp-block-template-part,
body.has-sidebar-nav.sidebar-expanded main.wp-block-group.site-main,
body.has-sidebar-nav.sidebar-expanded main.site-main,
body.has-sidebar-nav.sidebar-expanded footer.wp-block-template-part,
body.has-sidebar-nav.sidebar-expanded .wp-site-blocks > .wp-block-group.alignfull,
body.has-sidebar-nav.sidebar-expanded .wp-site-blocks > .wp-block-group.hero-compact,
body.has-sidebar-nav.sidebar-expanded .wp-site-blocks > .cia-hero,
body.has-sidebar-nav.sidebar-expanded .wp-site-blocks > .hero-compact,
body.has-sidebar-nav.sidebar-expanded .wp-site-blocks > section.hero,
body.has-sidebar-nav.sidebar-expanded .tuto-hero,
body.has-sidebar-nav.sidebar-expanded .tuto-layout,
body.has-sidebar-nav.sidebar-expanded .tuto-transparence {
  margin-left: var(--sidebar-width-expanded) !important;
}

/* Sidebar template-part itself: NO margin */
body.has-sidebar-nav .wp-site-blocks > .wp-block-template-part:first-child {
  margin-left: 0 !important;
}

/* ============================
   MOBILE TOGGLE & OVERLAY
   ============================ */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 16px; left: 16px;
  z-index: 200;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: #6C3AED;
  color: white;
  border: none;
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(108,58,237,0.2);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width-expanded) !important; /* Always expanded on mobile when open */
    z-index: 160;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar.open .sidebar-section-title,
  .sidebar.open .sidebar-logo .logo-text,
  .sidebar.open .sidebar-item > span:not(.sidebar-icon) {
    opacity: 1;
    width: auto;
    height: auto;
  }
  .sidebar-toggle {
    display: flex;
  }
  .sidebar-overlay.open {
    display: block;
  }

  /* Remove sidebar margin on mobile */
  body.has-sidebar-nav header.wp-block-template-part,
  body.has-sidebar-nav main.wp-block-group.site-main,
  body.has-sidebar-nav main.site-main,
  body.has-sidebar-nav footer.wp-block-template-part,
  body.has-sidebar-nav .wp-site-blocks > .wp-block-group.alignfull,
  body.has-sidebar-nav .wp-site-blocks > .wp-block-group.hero-compact,
  body.has-sidebar-nav .wp-site-blocks > .cia-hero,
  body.has-sidebar-nav .wp-site-blocks > .hero-compact,
  body.has-sidebar-nav .wp-site-blocks > section.hero,
  body.has-sidebar-nav.sidebar-expanded header.wp-block-template-part,
  body.has-sidebar-nav.sidebar-expanded main.wp-block-group.site-main,
  body.has-sidebar-nav.sidebar-expanded main.site-main,
  body.has-sidebar-nav.sidebar-expanded footer.wp-block-template-part,
  body.has-sidebar-nav.sidebar-expanded .wp-site-blocks > .wp-block-group.alignfull,
  body.has-sidebar-nav.sidebar-expanded .wp-site-blocks > .wp-block-group.hero-compact,
  body.has-sidebar-nav.sidebar-expanded .wp-site-blocks > .cia-hero,
  body.has-sidebar-nav.sidebar-expanded .wp-site-blocks > .hero-compact,
  body.has-sidebar-nav.sidebar-expanded .wp-site-blocks > section.hero {
    margin-left: 0 !important;
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 100% !important;
  }
}
