/* ============================================
   Fennec360-v2 Sidebar & Top Bar Layout
   Covers: sidebar, topbar, layout shell,
   collapsed rail, mobile overlay, Your Agent,
   logo swap, theme toggle, print.
   ============================================ */

/* ----------------------------------------
   1. LAYOUT SHELL
   ---------------------------------------- */
.fennec360-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--surface-raised);
  border-right: 1px solid var(--border-default);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease;
}

.fennec360-topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border-default);
  z-index: 1030;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  transition: left 0.2s ease;
}

.fennec360-layout {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  min-height: 100vh;
  transition: margin-left 0.2s ease;
}

.fennec360-content {
  padding: var(--space-6);
}

/* ----------------------------------------
   2. SIDEBAR LOGO
   ---------------------------------------- */
.sidebar-logo {
  padding: var(--space-4) var(--space-5);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-default);
}

.sidebar-logo a {
  display: flex;
  align-items: center;
  text-decoration: none;
  overflow: hidden;
}

.sidebar-logo img {
  max-height: 36px;
  width: auto;
  object-fit: contain;
}

/* Logo swap: show correct variant per theme */
[data-theme="light"] .sidebar-logo-dark,
.sidebar-logo-dark {
  display: none;
}

[data-theme="dark"] .sidebar-logo-light {
  display: none;
}

[data-theme="dark"] .sidebar-logo-dark {
  display: block;
}

/* Compact logo: hidden by default, shown when collapsed */
.sidebar-logo-compact {
  display: none !important;
}

/* ----------------------------------------
   3. SIDEBAR NAVIGATION
   ---------------------------------------- */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-2) 0;
}

/* Scrollbar styling */
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 4px;
}

.sidebar-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-item {
  margin: 1px 0;
}

.sidebar-item > a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-5);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-item > a:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar-item.active > a {
  background: var(--primary-50);
  color: var(--primary-700);
  border-left-color: var(--accent-700);
  font-weight: 500;
}

[data-theme="dark"] .sidebar-item.active > a {
  background: var(--surface-active);
  color: var(--primary-200);
  border-left-color: var(--accent-400);
}

.sidebar-icon {
  font-size: 20px;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--accent-700);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  border-radius: var(--radius-badge);
  flex-shrink: 0;
}

/* Sidebar section divider */
.sidebar-divider {
  height: 1px;
  background: var(--border-default);
  margin: var(--space-2) var(--space-5);
}

/* ----------------------------------------
   4. YOUR AGENT WIDGET
   ---------------------------------------- */
.sidebar-agent {
  flex-shrink: 0;
  margin: var(--space-3);
  padding: var(--space-4);
  background: #fff;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-card);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  font-family: 'Bricolage Grotesque', sans-serif;
}

[data-theme="dark"] .sidebar-agent {
  background: var(--neutral-900);
  border-color: var(--neutral-800);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.sidebar-agent-label {
  font-family: 'Bricolage Grotesque', var(--font-family-base);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.sidebar-agent-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.sidebar-agent-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--primary-100);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--primary-500);
}

.sidebar-agent-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-agent-avatar.initials {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-700);
}

[data-theme="dark"] .sidebar-agent-avatar {
  background: var(--surface-active);
  box-shadow: 0 0 0 2px var(--primary-400);
}

[data-theme="dark"] .sidebar-agent-avatar.initials {
  color: var(--primary-200);
}

.sidebar-agent-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-agent-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.sidebar-agent-username {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.sidebar-agent-actions {
  display: flex;
  gap: var(--space-2);
}

.agent-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  color: #313b8a;
  background: var(--primary-100);
  border: 1px solid var(--primary-200);
  text-decoration: none;
  font-size: 15px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.agent-action-btn i {
  font-size: 16px;
  line-height: 1;
  color: #313b8a !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.agent-action-btn:hover {
  background: var(--primary-200);
  color: #272974;
  border-color: var(--primary-300);
  text-decoration: none;
  transform: translateY(-1px);
}

.agent-action-btn:hover i {
  color: #272974 !important;
}

[data-theme="dark"] .agent-action-btn {
  background: var(--primary-900);
  color: #a5b4fc;
  border-color: var(--primary-800);
}

[data-theme="dark"] .agent-action-btn i {
  color: #a5b4fc !important;
}

[data-theme="dark"] .agent-action-btn:hover {
  background: var(--primary-800);
  color: #c7d2fe;
  border-color: var(--primary-700);
}

[data-theme="dark"] .agent-action-btn:hover i {
  color: #c7d2fe !important;
}

.agent-action-whatsapp {
  background: #25D366 !important;
  color: #fff !important;
  border-color: #25D366 !important;
}

.agent-action-whatsapp i {
  color: #fff !important;
}

.agent-action-whatsapp:hover {
  background: #128C7E !important;
  color: #fff !important;
  border-color: #128C7E !important;
}

.agent-action-whatsapp:hover i {
  color: #fff !important;
}

[data-theme="dark"] .agent-action-whatsapp {
  background: #25D366;
  color: #fff;
  border-color: #1da851;
}

[data-theme="dark"] .agent-action-whatsapp i {
  color: #fff !important;
}

[data-theme="dark"] .agent-action-whatsapp:hover {
  background: #128C7E;
  color: #fff;
}

/* Email button */
.agent-action-email {
  background: var(--primary-600) !important;
  color: #fff !important;
  border-color: var(--primary-600) !important;
}

.agent-action-email i {
  color: #fff !important;
}

.agent-action-email:hover {
  background: var(--primary-700) !important;
  border-color: var(--primary-700) !important;
}

[data-theme="dark"] .agent-action-email {
  background: var(--primary-500) !important;
  border-color: var(--primary-500) !important;
}

[data-theme="dark"] .agent-action-email:hover {
  background: var(--primary-400) !important;
  border-color: var(--primary-400) !important;
}

/* Instagram button with gradient */
.agent-action-instagram {
  background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%) !important;
  color: #fff !important;
  border: none !important;
}

.agent-action-instagram i {
  color: #fff !important;
}

.agent-action-instagram:hover {
  background: linear-gradient(45deg, #e08025 0%, #d55a30 25%, #c91f38 50%, #b81d5a 75%, #a8147a 100%) !important;
  filter: brightness(1.05);
}

[data-theme="dark"] .agent-action-instagram {
  background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%) !important;
}

[data-theme="dark"] .agent-action-instagram:hover {
  background: linear-gradient(45deg, #e08025 0%, #d55a30 25%, #c91f38 50%, #b81d5a 75%, #a8147a 100%) !important;
}

/* ----------------------------------------
   5. SIDEBAR FOOTER
   ---------------------------------------- */
.sidebar-footer {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sidebar-theme-toggle,
.sidebar-collapse-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--radius-input);
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-theme-toggle:hover,
.sidebar-collapse-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.sidebar-theme-toggle {
  flex: 1;
}

.sidebar-collapse-btn {
  flex-shrink: 0;
  margin-left: auto;
}

/* Theme toggle icon visibility */
[data-theme="light"] .theme-icon-dark,
.theme-icon-dark {
  display: none;
}

[data-theme="dark"] .theme-icon-light {
  display: none;
}

[data-theme="dark"] .theme-icon-dark {
  display: inline-flex;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ----------------------------------------
   6. TOP BAR
   ---------------------------------------- */
.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Hamburger (hidden on desktop) */
.topbar-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 22px;
  cursor: pointer;
  border-radius: var(--radius-input);
  transition: background 0.15s ease;
}

.topbar-hamburger:hover {
  background: var(--surface-hover);
}

/* Greeting */
.topbar-greeting {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.topbar-greeting-text {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-date {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Action buttons (theme toggle in topbar) */
.topbar-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  border-radius: var(--radius-input);
  transition: background 0.15s ease, color 0.15s ease;
}

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

/* Search bar (command palette trigger) */
.topbar-search-bar {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-3);
  background: var(--surface-hover);
  border: 1px solid var(--border-default);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.topbar-search-bar:hover {
  background: var(--surface-active);
  border-color: var(--border-strong);
}

.topbar-search-bar-icon {
  font-size: 16px;
  color: var(--text-tertiary);
}

.topbar-search-bar-text {
  font-size: 13px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.topbar-search-bar-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  font-size: 11px;
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--text-tertiary);
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  margin-left: var(--space-2);
}

/* Hide text on smaller screens, show icon only */
@media (max-width: 768px) {
  .topbar-search-bar {
    width: 36px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-input);
  }
  .topbar-search-bar-text,
  .topbar-search-bar-kbd {
    display: none;
  }
}

/* ----------------------------------------
   7. PROFILE DROPDOWN
   ---------------------------------------- */
.topbar-profile {
  position: relative;
}

.topbar-profile-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--border-default);
  background: transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.topbar-profile-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.topbar-caret {
  font-size: 14px;
  color: var(--text-tertiary);
  transition: transform 0.15s ease;
}

.topbar-profile.open .topbar-caret {
  transform: rotate(180deg);
}

.topbar-profile-dropdown {
  min-width: 280px;
  padding: 0;
  margin-top: var(--space-2) !important;
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

[data-theme="dark"] .topbar-profile-dropdown {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* Profile Header */
.profile-dropdown-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface-default);
  border-bottom: 1px solid var(--border-default);
}

.profile-dropdown-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border-default);
}

.profile-dropdown-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.profile-dropdown-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-dropdown-email {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-dropdown-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 2px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--primary-700);
  background: var(--primary-50);
  border-radius: var(--radius-badge);
  width: fit-content;
}

[data-theme="dark"] .profile-dropdown-badge {
  color: var(--primary-200);
  background: var(--surface-active);
}

/* Dropdown Sections */
.profile-dropdown-section {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-default);
}

.profile-dropdown-section:last-of-type {
  border-bottom: none;
}

.profile-dropdown-section-label {
  padding: 0 var(--space-4) var(--space-2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

/* Menu Items */
.profile-dropdown-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.profile-dropdown-menu > li > a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-4);
  color: var(--text-primary);
  font-size: 13px;
  text-decoration: none;
  transition: background 0.15s ease;
}

.profile-dropdown-menu > li > a:hover {
  background: var(--surface-hover);
  text-decoration: none;
}

.profile-dropdown-menu > li > a > i {
  font-size: 18px;
  width: 20px;
  text-align: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.profile-dropdown-menu .badge {
  margin-left: auto;
  background: var(--accent-700);
  color: #fff;
  font-size: 10px;
  min-width: 18px;
  padding: 2px 6px;
  border-radius: var(--radius-badge);
}

.profile-dropdown-chevron {
  margin-left: auto;
  font-size: 14px;
  color: var(--text-tertiary);
}

/* Language submenu */
.profile-dropdown-menu .dropdown-submenu > .dropdown-menu {
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-input);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .profile-dropdown-menu .dropdown-submenu > .dropdown-menu {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.profile-dropdown-menu .dropdown-submenu > .dropdown-menu > li > a {
  padding: 6px var(--space-4);
  color: var(--text-primary);
  font-size: 13px;
}

.profile-dropdown-menu .dropdown-submenu > .dropdown-menu > li > a:hover {
  background: var(--surface-hover);
}

.profile-dropdown-menu .dropdown-submenu > .dropdown-menu > li.active > a {
  background: var(--primary-50);
  color: var(--primary-700);
}

[data-theme="dark"] .profile-dropdown-menu .dropdown-submenu > .dropdown-menu > li.active > a {
  background: var(--surface-active);
  color: var(--primary-200);
}

/* Dropdown Footer / Logout */
.profile-dropdown-footer {
  padding: var(--space-3) var(--space-4);
  background: var(--surface-default);
  border-top: 1px solid var(--border-default);
}

.profile-dropdown-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: 10px var(--space-3);
  font-size: 13px;
  font-weight: 500;
  color: var(--danger);
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: var(--radius-input);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.profile-dropdown-logout:hover {
  background: var(--danger);
  color: #fff;
  text-decoration: none;
}

.profile-dropdown-logout > i {
  font-size: 16px;
}

/* RTL Support */
[dir="rtl"] .profile-dropdown-chevron {
  transform: rotate(180deg);
}

[dir="rtl"] .profile-dropdown-menu .dropdown-submenu > .dropdown-menu {
  left: auto;
  right: 100%;
}

/* ----------------------------------------
   8. SIDEBAR COLLAPSED (RAIL MODE)
   ---------------------------------------- */
.sidebar-collapsed .fennec360-sidebar {
  width: var(--sidebar-rail-width);
  overflow: visible; /* Allow tooltips to show outside sidebar */
}

.sidebar-collapsed .sidebar-nav {
  overflow: visible; /* Allow tooltips to escape nav container */
}

.sidebar-collapsed .fennec360-topbar {
  left: var(--sidebar-rail-width);
}

.sidebar-collapsed .fennec360-layout {
  margin-left: var(--sidebar-rail-width);
}

/* Hide text labels in collapsed mode */
.sidebar-collapsed .sidebar-label,
.sidebar-collapsed .sidebar-badge,
.sidebar-collapsed .sidebar-agent-label,
.sidebar-collapsed .sidebar-agent-name,
.sidebar-collapsed .sidebar-agent-username,
.sidebar-collapsed .sidebar-agent-actions,
.sidebar-collapsed .sidebar-section-label {
  display: none;
}

/* Subtle divider in collapsed mode */
.sidebar-collapsed .sidebar-divider {
  margin: var(--space-2) var(--space-3);
  opacity: 0.5;
}

/* Consistent spacing in collapsed mode */
.sidebar-collapsed .sidebar-item {
  margin: 2px 0;
}

/* Center icons in collapsed mode */
.sidebar-collapsed .sidebar-item > a {
  justify-content: center;
  padding: 12px 0;
  border-left-width: 0;
  gap: 0; /* Remove gap when labels hidden */
}

.sidebar-collapsed .sidebar-item.active > a {
  border-left-width: 0;
  border-radius: 0;
  background: var(--primary-50);
}

[data-theme="dark"] .sidebar-collapsed .sidebar-item.active > a {
  background: var(--surface-active);
}

/* Collapsed logo: center the image */
.sidebar-collapsed .sidebar-logo {
  justify-content: center;
  padding: var(--space-4) var(--space-2);
}

.sidebar-collapsed .sidebar-logo img {
  max-height: 28px;
}

/* Collapsed logo swap: show compact, hide full */
.sidebar-collapsed .sidebar-logo-full {
  display: none !important;
}

.sidebar-collapsed .sidebar-logo-compact.sidebar-logo-light {
  display: block !important;
}

[data-theme="dark"] .sidebar-collapsed .sidebar-logo-compact.sidebar-logo-light {
  display: none !important;
}

[data-theme="dark"] .sidebar-collapsed .sidebar-logo-compact.sidebar-logo-dark {
  display: block !important;
}

/* Collapsed agent widget: show avatar only, centered */
.sidebar-collapsed .sidebar-agent {
  margin: var(--space-2) auto;
  padding: var(--space-2);
  background: transparent;
  border: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sidebar-collapsed .sidebar-agent-info {
  margin-bottom: 0;
}

.sidebar-collapsed .sidebar-agent-avatar {
  width: 36px;
  height: 36px;
}

/* Collapsed footer: stack vertically, center */
.sidebar-collapsed .sidebar-footer {
  flex-direction: column;
  padding: var(--space-3) var(--space-2);
  gap: var(--space-1);
}

.sidebar-collapsed .sidebar-theme-toggle,
.sidebar-collapsed .sidebar-collapse-btn {
  width: 40px;
  height: 40px;
  justify-content: center;
  padding: 0;
}

.sidebar-collapsed .sidebar-collapse-btn {
  margin-left: 0;
}

/* Tooltip on hover for collapsed items */
.sidebar-collapsed .sidebar-item > a {
  position: relative;
}

.sidebar-collapsed .sidebar-item > a::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(var(--sidebar-rail-width) + 6px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 10px;
  background: var(--neutral-900);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1050;
}

.sidebar-collapsed .sidebar-item > a:hover::after {
  opacity: 1;
}

/* Tooltip for footer buttons in collapsed mode */
.sidebar-collapsed .sidebar-footer {
  position: relative;
}

.sidebar-collapsed .sidebar-theme-toggle::after,
.sidebar-collapsed .sidebar-collapse-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(var(--sidebar-rail-width) + 6px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 10px;
  background: var(--neutral-900);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1050;
}

.sidebar-collapsed .sidebar-theme-toggle:hover::after,
.sidebar-collapsed .sidebar-collapse-btn:hover::after {
  opacity: 1;
}

/* Tooltip for agent widget in collapsed mode */
.sidebar-collapsed .sidebar-agent::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(var(--sidebar-rail-width) + 6px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 10px;
  background: var(--neutral-900);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1050;
}

.sidebar-collapsed .sidebar-agent:hover::after {
  opacity: 1;
}

/* ----------------------------------------
   9. MOBILE BACKDROP
   ---------------------------------------- */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1035;
  transition: opacity 0.2s ease;
}

.sidebar-backdrop.active {
  display: block;
}

/* ----------------------------------------
   10. AUTH LAYOUT (Logged-Out)
   ---------------------------------------- */
.fennec360-auth-layout {
  padding-top: var(--topbar-height);
}

/* Topbar in auth layout: full width, centered logo */
.fennec360-auth-layout ~ .fennec360-topbar,
body:not(.sidebar-collapsed) .fennec360-auth-topbar {
  left: 0;
}

/* When no sidebar exists (auth pages), topbar should span full width */
body:not(:has(.fennec360-sidebar)) .fennec360-topbar {
  left: 0;
}

/* Topbar logo for auth pages */
.topbar-logo {
  display: flex;
  align-items: center;
}

.topbar-logo img {
  max-height: 36px;
  width: auto;
}

/* Larger logo on mobile */
@media (max-width: 768px) {
  .topbar-logo img {
    max-height: 42px;
  }
}

[data-theme="light"] .topbar-logo .sidebar-logo-dark {
  display: none;
}

[data-theme="dark"] .topbar-logo .sidebar-logo-light {
  display: none;
}

[data-theme="dark"] .topbar-logo .sidebar-logo-dark {
  display: block;
}

/* ----------------------------------------
   11. RESPONSIVE — MOBILE (max-width: 992px)
   ---------------------------------------- */
@media (max-width: 992px) {
  .fennec360-sidebar {
    transform: translateX(-100%);
    z-index: 1040;
    width: var(--sidebar-width);
  }

  .fennec360-sidebar.sidebar-open {
    transform: translateX(0);
  }

  .fennec360-topbar {
    left: 0;
  }

  .fennec360-layout {
    margin-left: 0;
  }

  .topbar-hamburger {
    display: flex;
  }

  .topbar-greeting {
    display: none;
  }

  /* On mobile, ignore collapsed state — always show full sidebar when open */
  .sidebar-collapsed .fennec360-sidebar {
    width: var(--sidebar-width);
  }

  .sidebar-collapsed .fennec360-topbar {
    left: 0;
  }

  .sidebar-collapsed .fennec360-layout {
    margin-left: 0;
  }

  .sidebar-collapsed .sidebar-label,
  .sidebar-collapsed .sidebar-badge,
  .sidebar-collapsed .sidebar-agent-label,
  .sidebar-collapsed .sidebar-agent-name,
  .sidebar-collapsed .sidebar-agent-username,
  .sidebar-collapsed .sidebar-agent-actions {
    display: unset;
  }

  .sidebar-collapsed .sidebar-item > a {
    justify-content: flex-start;
    padding: 10px var(--space-5);
  }

  .sidebar-collapsed .sidebar-logo {
    justify-content: flex-start;
    padding: var(--space-4) var(--space-5);
  }

  .sidebar-collapsed .sidebar-logo img {
    max-height: 36px;
  }

  .sidebar-collapsed .sidebar-agent {
    padding: var(--space-4) var(--space-5);
    flex-direction: column;
    align-items: stretch;
  }

  .sidebar-collapsed .sidebar-agent-info {
    margin-bottom: var(--space-3);
  }

  .sidebar-collapsed .sidebar-footer {
    flex-direction: row;
    padding: var(--space-3) var(--space-5);
  }

  .sidebar-collapsed .sidebar-theme-toggle,
  .sidebar-collapsed .sidebar-collapse-btn {
    width: auto;
    height: auto;
    padding: 8px;
  }

  /* Hide collapse button on mobile — not useful */
  .sidebar-collapse-btn {
    display: none;
  }
}

/* ----------------------------------------
   12. RESPONSIVE — SMALL MOBILE (max-width: 576px)
   ---------------------------------------- */
@media (max-width: 576px) {
  .fennec360-topbar {
    padding: 0 var(--space-4);
  }

  .fennec360-content {
    padding: var(--space-4);
  }

  .topbar-date {
    display: none;
  }
}

/* ----------------------------------------
   13. PRINT
   ---------------------------------------- */
@media print {
  .fennec360-sidebar,
  .fennec360-topbar,
  .sidebar-backdrop {
    display: none !important;
  }

  .fennec360-layout {
    margin-left: 0 !important;
    padding-top: 0 !important;
  }
}

/* ----------------------------------------
   14. ACCESSIBILITY — Focus Styles
   ---------------------------------------- */
.sidebar-item > a:focus-visible,
.sidebar-theme-toggle:focus-visible,
.sidebar-collapse-btn:focus-visible,
.topbar-hamburger:focus-visible,
.topbar-action-btn:focus-visible,
.topbar-profile-btn:focus-visible,
.agent-action-btn:focus-visible {
  outline: 2px solid var(--primary-700);
  outline-offset: 2px;
}

[data-theme="dark"] .sidebar-item > a:focus-visible,
[data-theme="dark"] .sidebar-theme-toggle:focus-visible,
[data-theme="dark"] .sidebar-collapse-btn:focus-visible,
[data-theme="dark"] .topbar-hamburger:focus-visible,
[data-theme="dark"] .topbar-action-btn:focus-visible,
[data-theme="dark"] .topbar-profile-btn:focus-visible,
[data-theme="dark"] .agent-action-btn:focus-visible {
  outline-color: var(--primary-300);
}

/* Skip to content link */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--primary-700);
  color: #fff;
  font-size: 13px;
  border-radius: 0 0 var(--radius-input) var(--radius-input);
  z-index: 9999;
  text-decoration: none;
}

.skip-to-content:focus {
  top: 0;
  color: #fff;
  text-decoration: none;
}
