/* Sidebar Styles */

/* Mobile Logo - only visible on mobile */
.sidebar-logo-mobile {
  display: none;
  height: var(--navbar-height);
  padding: 0 1rem;
  border-bottom: 1px solid #e0e0e0;
}

.sidebar-logo-mobile a {
  display: flex;
  align-items: center;
  height: 100%;
}

[data-theme="dark"] .sidebar-logo-mobile {
  border-bottom-color: #363636;
}

/* Make "Networks" text white in dark mode */
[data-theme="dark"] .sidebar-logo-mobile .logo-sidebar .logo-networks {
  fill: #ffffff;
}

@media screen and (max-width: 1023px) {
  .sidebar-logo-mobile {
    display: block;
  }
}

/* Layout */
.has-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.dashboard-wrapper {
  display: flex;
  flex: 1;
  position: relative;
}

/* Sidebar Container */
.sidebar {
  width: var(--sidebar-width);
  height: calc(100vh - var(--navbar-height));
  position: sticky;
  top: var(--navbar-height);
  background-color: #f5f5f5;
  transition: width 0.3s ease, transform 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
  z-index: 40;
  flex-shrink: 0;
  border-right: 1px solid #e0e0e0;
}

.sidebar.is-collapsed {
  width: var(--sidebar-width-collapsed);
}

[data-theme="dark"] .sidebar {
  background-color: #1a1a1a;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.3);
  border-right: 1px solid #363636;
}

/*************/
/* Dropdowns */
/*************/
.dropdown-content {
  --bulma-dropdown-content-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--bulma-border);
}

/* When our text is too wide in dropdown menus, we don't want it to wrap to the next line */
.dropdown-menu-wide .icon-text {
  flex-wrap: nowrap;
}
/******************/
/* END: Dropdowns */
/******************/

/****************************/
/* ZONE 1: Account Context  */
/****************************/
.sidebar-account-context {
  position: relative;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e0e0e0;
}

[data-theme="dark"] .sidebar-account-context {
  border-bottom-color: #363636;
}

.account-switcher-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background-color: #fff;
  border: 1px solid #dbdbdb;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  color: #363636;
  text-align: left;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.account-switcher-trigger:hover {
  border-color: #b5b5b5;
  background-color: #fafafa;
}

.account-switcher-trigger:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 209, 178, 0.2);
}

[data-theme="dark"] .account-switcher-trigger {
  background-color: #2a2a2a;
  border-color: #4a4a4a;
  color: #f5f5f5;
}

[data-theme="dark"] .account-switcher-trigger:hover {
  border-color: #6a6a6a;
  background-color: #333;
}

[data-theme="dark"] .account-switcher-trigger:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 209, 178, 0.2);
}

.account-switcher-trigger .account-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-switcher-trigger .chevron {
  transition: transform 0.2s ease;
}

.sidebar-account-context.is-active .account-switcher-trigger .chevron {
  transform: rotate(180deg);
}

.account-switcher-dropdown {
  position: absolute;
  top: 100%;
  left: 0.75rem;
  right: 0.75rem;
  margin-top: 0.25rem;
  background-color: #fff;
  border: 1px solid #dbdbdb;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.sidebar-account-context.is-active .account-switcher-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

[data-theme="dark"] .account-switcher-dropdown {
  background-color: #2a2a2a;
  border-color: #4a4a4a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.account-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: none;
  background: none;
  font-size: 0.875rem;
  color: #363636;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.account-option:hover {
  background-color: #f5f5f5;
}

[data-theme="dark"] .account-option {
  color: #f5f5f5;
}

[data-theme="dark"] .account-option:hover {
  background-color: #363636;
}

.account-option.is-selected {
  background-color: #e8f8f6;
  cursor: default;
}

[data-theme="dark"] .account-option.is-selected {
  background-color: #1a3d38;
}

.account-option.is-selected .check {
  color: var(--primary);
  margin-left: auto;
}

.account-option.is-disabled {
  color: #b5b5b5;
  cursor: not-allowed;
}

.account-option.is-disabled:hover {
  background-color: transparent;
}

[data-theme="dark"] .account-option.is-disabled {
  color: #6a6a6a;
}

[data-theme="dark"] .account-option.is-disabled:hover {
  background-color: transparent;
}

.account-option-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-option-form {
  margin: 0;
}

.account-option-divider {
  height: 1px;
  background-color: #e0e0e0;
  margin: 0.25rem 0;
}

[data-theme="dark"] .account-option-divider {
  background-color: #4a4a4a;
}

/* Collapsed sidebar - show icon only */
.sidebar.is-collapsed .sidebar-account-context {
  padding: 0.5rem;
}

.sidebar.is-collapsed .account-switcher-trigger .account-name,
.sidebar.is-collapsed .account-switcher-trigger .chevron {
  display: none;
}

.sidebar.is-collapsed .account-switcher-trigger {
  justify-content: center;
  padding: 0.5rem;
}

.sidebar.is-collapsed .account-switcher-dropdown {
  left: calc(var(--sidebar-width-collapsed) - 0.5rem);
  right: auto;
  width: 220px;
}

/********************************/
/* END ZONE 1: Account Context  */
/********************************/

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
}

/* Menu items base styling */
.sidebar .menu-list a {
  background-color: #f5f5f5;
}

[data-theme="dark"] .sidebar .menu-list a {
  background-color: #1a1a1a;
}

/* Menu label */
.sidebar .menu-label {
  padding: 0 1rem;
  margin: 0.75rem 0 0.5rem;
}

.sidebar .menu-label.menu-label-first {
  margin-top: 0;
}

.sidebar.is-collapsed .menu-label {
  display: none;
}

/* Admin Sidebar Collapsible Sections */
.menu-label.collapsible {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.menu-label.collapsible:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.menu-label.collapsible:focus:not(:focus-visible) {
  outline: none;
}

.section-toggle-icon,
.section-toggle-icon i {
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

/* Collapsed state */
.menu-list.is-collapsed {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  margin-bottom: 0;
}

/* Expanded state */
.menu-list:not(.is-collapsed) {
  max-height: 500px;
  overflow: visible;
  transition: max-height 0.3s ease;
}

/* When full sidebar is collapsed, hide section toggles */
.sidebar.is-collapsed .section-toggle-icon {
  display: none;
}

.sidebar.is-collapsed .menu-label.collapsible {
  justify-content: center;
  cursor: default;
  pointer-events: none;
}

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

.menu-list li {
  margin: 0;
}

.menu-list a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: #363636;
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
}

[data-theme="dark"] .menu-list a {
  color: #f5f5f5;
}

/* Hover states with proper cascade */
.sidebar .menu-list a:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .sidebar .menu-list a:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Active states - highest specificity, always wins */
.sidebar .menu-list a.is-active,
.sidebar .menu-list a.is-active:hover {
  background-color: var(--primary);
  color: white;
}

.menu-list a.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--primary-darker);
}

/* Disabled menu links */
.sidebar .menu-list a.is-disabled {
  color: #b5b5b5;
  cursor: not-allowed;
  pointer-events: none;
}

.sidebar .menu-list a.is-disabled:hover {
  background-color: #f5f5f5;
}

[data-theme="dark"] .sidebar .menu-list a.is-disabled {
  color: #6a6a6a;
}

[data-theme="dark"] .sidebar .menu-list a.is-disabled:hover {
  background-color: #1a1a1a;
}

.menu-list .icon {
  flex-shrink: 0;
  width: 1.5rem;
  text-align: center;
}

.menu-text {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.3s ease;
}

.sidebar.is-collapsed .menu-text {
  opacity: 0;
  width: 0;
}

.sidebar.is-collapsed .menu-list a {
  gap: 0;
}

.sidebar.is-collapsed .menu-list .icon {
  margin: 0 auto;
}

.sidebar-divider {
  height: 1px;
  background-color: #e0e0e0;
  margin: 0.5rem 0;
}

[data-theme="dark"] .sidebar-divider {
  background-color: #363636;
}

/******************************/
/* ZONE 3: Bottom Spacer      */
/* (Reserved for future use)  */
/******************************/
.sidebar-bottom-spacer {
  /* Empty spacer - profile/logout moved to navbar */
  padding: 0.5rem;
}

/******************************/
/* END ZONE 3                 */
/******************************/

/******************************/
/* ADMIN SIDEBAR HEADER       */
/******************************/
.sidebar-header {
  border-bottom: 1px solid #e0e0e0;
  padding: 0.5rem 0;
}

[data-theme="dark"] .sidebar-header {
  border-bottom-color: #363636;
}

.user-profile-mini {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.user-profile-mini:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .user-profile-mini:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.user-profile-mini:hover .back-link-icon {
  box-shadow: 0 0 0 3px rgba(0, 209, 178, 0.4);
}

.sidebar.is-collapsed .user-profile-mini {
  justify-content: center;
  padding: 0.5rem;
}

.back-link-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-dark) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
  transition: box-shadow 0.2s ease;
}

.avatar-initials {
  font-size: 0.875rem;
  text-transform: uppercase;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.3s ease, width 0.3s ease;
}

.sidebar.is-collapsed .user-info {
  display: none;
}

.user-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: #363636;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="dark"] .user-name {
  color: #f5f5f5;
}

.user-email {
  font-size: 0.75rem;
  color: #7a7a7a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="dark"] .user-email {
  color: #b5b5b5;
}

/******************************/
/* END ADMIN SIDEBAR HEADER   */
/******************************/

.main-content {
  flex: 1;
  transition: margin-left 0.3s ease;
  overflow-x: hidden;
}

.main-content.is-expanded {
  margin-left: 0;
}

/* Sidebar Toggle Buttons */
.sidebar-toggle-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.75rem;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: #4a4a4a;
  font-size: 1.2rem;
}

.sidebar-toggle-btn:hover {
  background-color: rgba(0, 0, 0, 0.08);
  color: #363636;
}

.sidebar.is-collapsed .sidebar-toggle-btn i {
  transform: rotate(180deg);
}

[data-theme="dark"] .sidebar-toggle-btn {
  color: #b0b0b0;
}

[data-theme="dark"] .sidebar-toggle-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #e0e0e0;
}

/* Mobile Sidebar Toggle styles moved to navbar.css */

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 35;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

/* Mobile Responsive */
@media screen and (max-width: 1023px) {
  .main-content {
    margin-left: 0 !important;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 100;
  }

  .sidebar.is-mobile-active {
    transform: translateX(0);
  }

  /* On mobile, sidebar is always full width - never collapsed */
  .sidebar {
    width: var(--sidebar-width-mobile);
  }

  .sidebar.is-collapsed {
    width: var(--sidebar-width-mobile);
  }

  /* Ensure text is visible on mobile */
  .sidebar .menu-text,
  .sidebar .account-switcher-trigger .account-name,
  .sidebar .account-switcher-trigger .chevron {
    opacity: 1 !important;
    display: flex !important;
    pointer-events: auto !important;
  }

  /* Reset collapsed styles for account context on mobile */
  .sidebar.is-collapsed .sidebar-account-context {
    padding: 0.75rem 1rem;
  }

  .sidebar.is-collapsed .account-switcher-trigger {
    justify-content: flex-start;
    padding: 0.5rem 0.75rem;
  }

  .sidebar.is-collapsed .account-switcher-dropdown {
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
  }

  /* Overlay should cover entire screen including navbar */
  .sidebar-overlay {
    top: 0;
    z-index: 90;
  }
}
