/**
 * RADEXEL Design System - Sidebar Component
 *
 * Left sidebar: Collapsible, conversation list with date grouping, search.
 * Right sidebar: Icon strip with tooltips.
 * Mobile: Left sidebar becomes a drawer with swipe gesture support.
 */

/* ==========================================================================
   Left Sidebar - Navigation Items
   ========================================================================== */

.nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  min-height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-default),
    color var(--duration-fast) var(--ease-default);
}

.nav-item:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.nav-item:active {
  background: var(--color-surface-active);
}

.nav-item.active {
  background: var(--color-info-light);
  color: var(--rdx-blue);
  font-weight: var(--font-weight-medium);
}

.nav-item:focus-visible {
  outline: 2px solid var(--rdx-blue);
  outline-offset: -2px;
}

.nav-item__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-item__icon svg {
  width: 18px;
  height: 18px;
}

.nav-item__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 var(--space-1);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  background: var(--color-danger);
  color: var(--color-text-inverse);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.nav-item__action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  opacity: 0;
  transition:
    opacity var(--duration-fast) var(--ease-default),
    background-color var(--duration-fast) var(--ease-default),
    color var(--duration-fast) var(--ease-default);
  flex-shrink: 0;
}

.nav-item:hover .nav-item__action {
  opacity: 1;
}

.nav-item__action:hover {
  background: var(--color-surface-active);
  color: var(--color-text);
}

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


/* ==========================================================================
   Section Headers (Date Groups)
   ========================================================================== */

.sidebar-section {
  padding-top: var(--space-4);
}

.sidebar-section:first-child {
  padding-top: 0;
}

.sidebar-section__title {
  display: flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}


/* ==========================================================================
   Conversation List Item (Extends nav-item)
   ========================================================================== */

.conversation-item {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
}

.conversation-item__title {
  font-size: var(--font-size-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.conversation-item__time {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* Editing mode (inline rename) */
.conversation-item--editing .conversation-item__input {
  width: 100%;
  padding: var(--space-1) var(--space-2);
  font-size: var(--font-size-sm);
  background: var(--color-bg);
  border: 1px solid var(--color-border-focus);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* Pinned indicator */
.conversation-item--pinned::before {
  content: '';
  width: 3px;
  height: 16px;
  background: var(--rdx-blue);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  margin-right: var(--space-1);
}


/* ==========================================================================
   New Conversation Button
   ========================================================================== */

.sidebar-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--rdx-blue);
  background: transparent;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-default),
    border-color var(--duration-fast) var(--ease-default);
}

.sidebar-new-chat:hover {
  background: var(--color-info-light);
  border-color: var(--rdx-blue);
}

.sidebar-new-chat svg {
  width: 16px;
  height: 16px;
}


/* ==========================================================================
   Keyboard Shortcut Hint
   ========================================================================== */

.sidebar-shortcut {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

.sidebar-shortcut kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 var(--space-1);
  font-size: 10px;
  font-family: var(--font-mono);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  color: var(--color-text-secondary);
}


/* ==========================================================================
   Mobile Drawer Mode (Overlay Left Sidebar)
   ========================================================================== */

@media (max-width: 1024px) {
  .left-sidebar {
    /* Position and transform handled by layout.css */
    border-right: none;
  }

  .left-sidebar.drawer-open {
    border-right: 1px solid var(--color-border);
  }

  /* Show sidebar toggle in topbar */
  .topbar__sidebar-toggle {
    display: flex;
  }

  /* Hide keyboard shortcuts on mobile */
  .sidebar-shortcut {
    display: none;
  }
}

@media (min-width: 1025px) {
  /* Hide sidebar toggle on desktop (sidebar always visible) */
  .topbar__sidebar-toggle--mobile-only {
    display: none;
  }
}


/* ==========================================================================
   Right Sidebar - Specific Icon Features
   ========================================================================== */

.right-sidebar__icon--active-indicator::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  background: var(--color-success);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-surface);
}

/* Right sidebar panel (expands from right) */
.right-sidebar-panel {
  position: fixed;
  top: var(--topbar-height);
  right: var(--right-sidebar-width);
  bottom: 0;
  width: 320px;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  z-index: var(--z-dropdown);
  transform: translateX(100%);
  opacity: 0;
  transition:
    transform var(--duration-slow) var(--ease-default),
    opacity var(--duration-slow) var(--ease-default);
  overflow-y: auto;
}

.right-sidebar-panel.open {
  transform: translateX(0);
  opacity: 1;
  box-shadow: var(--shadow-lg);
}

.right-sidebar-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
}

.right-sidebar-panel__title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

.right-sidebar-panel__body {
  padding: var(--space-4);
}

@media (max-width: 768px) {
  .right-sidebar-panel {
    right: 0;
    width: 100%;
    max-width: 360px;
  }
}
