/* Sidebar trigger area - hover to show when hidden */
.sidebar-trigger-area {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  height: 100%;
  width: 5px;
  background: transparent;
}

/* Main sidebar container */
.sidebar {
  position: relative;
  z-index: 100;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 32px);
  min-height: 0;
  overflow: hidden;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: all 0.3s ease-in-out;
  box-sizing: border-box;
  flex-shrink: 0;
}

.dark .sidebar {
  background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 50%, #1a1a1a 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

/* Sidebar hidden state */
.sidebar.hidden {
  pointer-events: none;
  transform: translateX(-100%);
  opacity: 0;
  position: absolute;
}

/* Hover to show when hidden */
.sidebar.hidden.hover-visible {
  pointer-events: auto;
  transform: translateX(0);
  opacity: 1;
  position: fixed;
  top: 32px;
  left: 0;
  z-index: 150;
  height: calc(100dvh - 32px);
  box-shadow: var(--shadow-xl);
}

/* Sidebar header - spacer for titlebar drag area */
.sidebar-header {
  min-height: 28px;
  flex-shrink: 0;
}

/* Sidebar control buttons */
.sidebar-controls {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  gap: 4px;
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-controls {
  justify-content: center;
  padding: 4px;
}

.sidebar-control-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  transition: all 0.2s ease;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-tertiary);
}

.sidebar-control-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Navigation area - scrollable, takes remaining space */
.sidebar-nav {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.sidebar.collapsed .sidebar-nav {
  padding: 0;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

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

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

/* Sidebar footer - fixed at bottom */
.sidebar-footer {
  flex-shrink: 0;
  padding: 8px;
  border-top: 1px solid var(--border-color-light);
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: auto;
}

.dark .sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar.collapsed .sidebar-footer {
  padding: 8px 4px;
  align-items: center;
}

/* Footer menu item (settings) */
.footer-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--border-radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.footer-menu-item:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.footer-menu-item.collapsed {
  padding: 12px;
  justify-content: center;
}

.footer-menu-label {
  font-size: 14px;
}

/* Naive UI Menu customization */
:deep(.n-menu) {
  background: transparent !important;
  padding: 8px;
}

:deep(.n-menu-item) {
  margin: 4px 0;
  border-radius: var(--border-radius-md) !important;
}

:deep(.n-menu-item-content) {
  padding-left: 16px !important;
  padding-right: 16px !important;
  border-radius: var(--border-radius-md) !important;
}

:deep(.n-menu-item-content:hover) {
  background-color: var(--bg-tertiary) !important;
}

:deep(.n-menu-item-content--selected) {
  background-color: var(--color-primary) !important;
}

:deep(.n-menu-item-content--selected),
:deep(.n-menu-item-content--selected .n-menu-item-content__icon),
:deep(.n-menu-item-content--selected .n-icon),
:deep(.n-menu-item-content--selected a) {
  color: white !important;
}

/* Collapsed state adjustments */
.sidebar.collapsed .sidebar-nav {
  padding: 0;
}

.sidebar.collapsed :deep(.n-menu) {
  padding: 8px 0;
}

.sidebar.collapsed :deep(.n-menu-item) {
  margin: 4px 10px !important;
}

.sidebar.collapsed :deep(.n-menu-item-content) {
  padding: 0 12px !important;
}

.sidebar.collapsed :deep(.n-menu-item-content__icon) {
  margin-right: 0 !important;
}

.sidebar.collapsed :deep(.n-menu-item-content-header),
.sidebar.collapsed :deep(.n-menu-item-content__arrow) {
  display: none !important;
}

/* Responsive design */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 32px;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-xl);
  }

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