/* ===== SIDEBAR STYLES ===== */
.sidebar {
  width: 260px;
  height: 100vh;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-secondary);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, background-color 0.2s ease;
  position: relative;
  flex-shrink: 0;
}

.sidebar.collapsed {
  width: 60px;
}

/* ===== SIDEBAR HEADER ===== */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px;
  border-bottom: 1px solid var(--border-secondary);
  min-height: 60px;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 16px 8px;
}

.logo-container {
  display: flex;
  align-items: center;
  flex: 1;
}

.sidebar.collapsed .logo-container {
  display: none;
}

.logo {
  height: 32px;
  width: auto;
  transition: opacity 0.2s ease;
}

.sidebar.collapsed .logo {
  opacity: 0;
  pointer-events: none;
}

.sidebar-toggle {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-button-secondary);
  color: var(--text-secondary);
  transition: background-color 0.2s ease;
}

.sidebar-toggle:hover {
  background-color: var(--bg-button-secondary-hover);
}

.sidebar-toggle .icon {
  transform: rotate(0deg);
  transition: transform 0.3s ease;
}

.sidebar.collapsed .sidebar-toggle .icon {
  transform: rotate(180deg);
}

/* ===== SIDEBAR CONTENT ===== */
.sidebar-content {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ===== NEW CHAT BUTTON ===== */
.new-chat-btn {
  width: 100%;
  height: 44px;
  border-radius: 8px;
  background-color: var(--bg-button-secondary);
  border: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.new-chat-btn:hover {
  background-color: var(--bg-button-secondary-hover);
}

.new-chat-btn .icon {
  color: var(--icon-primary);
}

.sidebar.collapsed .new-chat-btn .btn-text {
  display: none;
}

.sidebar.collapsed .new-chat-btn {
  justify-content: center;
  padding: 0;
}

/* ===== FEATURE BUTTONS ===== */
.feature-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-secondary);
}

.feature-btn {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  background-color: var(--bg-button-secondary);
  border: 1px solid var(--border-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  justify-content: flex-start;
}

.feature-btn:hover {
  background-color: var(--bg-button-secondary-hover);
  border-color: var(--accent-primary);
}

.feature-btn .icon {
  color: var(--icon-primary);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar.collapsed .feature-btn {
  justify-content: center;
  padding: 0;
}

.sidebar.collapsed .feature-btn .btn-text {
  display: none;
}

/* ===== SEARCH CONTAINER ===== */
.search-container {
  margin-top: 8px;
  margin-bottom: 8px;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background-color: var(--bg-input);
  border: 1px solid var(--border-secondary);
  border-radius: 8px;
  padding: 0 12px;
  height: 36px;
  transition: all 0.2s ease;
}

.search-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-primary-alpha);
}

.search-icon {
  width: 16px;
  height: 16px;
  color: var(--icon-secondary);
  margin-right: 8px;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  padding: 0;
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-clear {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--icon-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 4px;
}

.search-clear:hover {
  background-color: var(--bg-button-secondary-hover);
  color: var(--icon-primary);
}

.search-clear .icon {
  width: 12px;
  height: 12px;
}

.sidebar.collapsed .search-container {
  display: none;
}

/* ===== SEARCH RESULTS ===== */
.no-results {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 12px;
  color: var(--text-tertiary);
  font-size: 14px;
  text-align: center;
}

.chat-title mark {
  background-color: var(--accent-primary-alpha);
  color: var(--accent-primary);
  padding: 1px 2px;
  border-radius: 2px;
}

/* ===== CHAT HISTORY ===== */
.chat-history {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-item {
  display: flex;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  gap: 12px;
  position: relative;
}

.chat-item:hover {
  background-color: var(--hover-bg);
}

.chat-item.active {
  background-color: var(--accent-bg);
  color: var(--accent-text);
}

.chat-item .icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  flex-shrink: 0;
}

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

.chat-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-meta {
  font-size: 12px;
  opacity: 0.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar.collapsed .chat-title {
  display: none;
}

.chat-options {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-item:hover .chat-options {
  opacity: 1;
}

.chat-options:hover {
  background-color: var(--bg-button-secondary-hover);
}

.sidebar.collapsed .chat-options {
  display: none;
}

.sidebar.collapsed .chat-item {
  justify-content: center;
  padding: 0;
}

/* ===== SIDEBAR FOOTER ===== */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-btn {
  width: 100%;
  height: 44px;
  border-radius: 8px;
  background-color: transparent;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  color: var(--text-secondary);
  font-size: 14px;
  transition: all 0.2s ease;
  text-decoration: none;
}

.sidebar-btn:hover {
  background-color: var(--bg-button-secondary-hover);
}

.sidebar-btn .icon {
  color: var(--icon-secondary);
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-btn .btn-text {
  display: none;
}

.sidebar.collapsed .sidebar-btn {
  justify-content: center;
  padding: 0;
}

.theme-toggle {
  width: 100%;
  height: 44px;
  border-radius: 8px;
  background-color: transparent;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  color: var(--text-secondary);
  font-size: 14px;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  background-color: var(--bg-button-secondary-hover);
}

.theme-toggle .icon {
  color: var(--icon-secondary);
  flex-shrink: 0;
}

.sidebar.collapsed .theme-toggle .btn-text {
  display: none;
}

.sidebar.collapsed .theme-toggle {
  justify-content: center;
  padding: 0;
}

/* ===== RESPONSIVE SIDEBAR ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 260px;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }
  
  .sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
  }
}