/* ==========================================================================
   NEXA — Sidebar Styling (Light & Dark Theme Support)
   ========================================================================== */

.nexa-sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 50;
  transition: var(--transition-normal);
  flex-shrink: 0;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.04);
}

/* 1. Header Brand Logo */
.sidebar-brand {
  padding: 1.5rem 1.25rem 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary-purple), var(--secondary-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.15rem;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.brand-text-wrapper {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  line-height: 1;
}

.brand-title span {
  background: linear-gradient(135deg, var(--primary-violet), var(--secondary-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

/* 2. New Chat Action Button */
.sidebar-action-box {
  padding: 0 1.25rem 1rem 1.25rem;
}

.btn-new-chat-sidebar {
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-purple), var(--accent-blue));
  border: none;
  color: #FFFFFF;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.25);
}

.btn-new-chat-sidebar:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(139, 92, 246, 0.35);
}

.btn-new-chat-sidebar i {
  font-size: 1.1rem;
}

/* 3. Recent Chats Section */
.sidebar-nav-section {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.section-label-header {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  text-transform: uppercase;
  padding: 0.4rem 0.4rem 0.2rem 0.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-count-badge {
  background: rgba(139, 92, 246, 0.15);
  color: var(--primary-purple);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 700;
}

/* History Search Box */
.sidebar-search-box {
  position: relative;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
}

.sidebar-search-box .search-icon {
  position: absolute;
  left: 0.65rem;
  color: var(--text-subtle);
  font-size: 0.85rem;
  pointer-events: none;
}

.history-search-input {
  width: 100%;
  padding: 0.45rem 0.65rem 0.45rem 2rem;
  border-radius: var(--radius-sm);
  background: var(--bg-light-alt);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  font-size: 0.82rem;
  font-family: var(--font-sans);
  outline: none;
  transition: var(--transition-fast);
}

.history-search-input:focus {
  border-color: var(--primary-purple);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.18);
  background: var(--surface-card);
}

.sidebar-convos-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Chat Item */
.convo-nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.86rem;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
  border: 1px solid transparent;
  position: relative;
}

.convo-nav-item:hover {
  background: rgba(139, 92, 246, 0.08);
  color: var(--text-main);
  transform: translateX(2px);
}

.convo-nav-item.active {
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.16) 0%, rgba(6, 182, 212, 0.08) 100%);
  color: var(--primary-purple);
  border-color: var(--border-subtle);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.convo-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 15%;
  bottom: 15%;
  width: 3px;
  background: linear-gradient(180deg, var(--primary-purple), var(--secondary-cyan));
  border-radius: 0 4px 4px 0;
}

.convo-icon-badge {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: rgba(139, 92, 246, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--text-subtle);
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.convo-nav-item:hover .convo-icon-badge,
.convo-nav-item.active .convo-icon-badge {
  background: rgba(139, 92, 246, 0.2);
  color: var(--primary-purple);
}

.convo-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Action Controls (Rename & Delete) on Hover */
.convo-actions-group {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-fast);
}

.convo-nav-item:hover .convo-actions-group {
  opacity: 1;
  pointer-events: auto;
}

.convo-action-btn {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  font-size: 0.85rem;
  padding: 0.25rem;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.convo-action-btn:hover.btn-rename {
  color: var(--primary-purple);
  background: rgba(139, 92, 246, 0.15);
}

.convo-action-btn:hover.btn-delete {
  color: #EF4444;
  background: rgba(239, 68, 68, 0.15);
}

/* Empty State Card */
.empty-history-card {
  padding: 1.5rem 1rem;
  text-align: center;
  background: rgba(139, 92, 246, 0.04);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  margin-top: 0.5rem;
}

.empty-history-card i {
  font-size: 1.5rem;
  color: var(--text-subtle);
}

/* 4. Bottom Account & Theme Footer */
.sidebar-account-footer {
  padding: 0.85rem 0.85rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Theme Toggle Button Component */
.sidebar-theme-wrapper {
  width: 100%;
}

.theme-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition-fast);
}

.theme-toggle-btn:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--primary-purple);
}

.theme-btn-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.86rem;
  font-weight: 600;
}

.theme-btn-info i {
  font-size: 1.1rem;
  color: var(--primary-purple);
}

.theme-switch-track {
  width: 38px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--text-subtle);
  position: relative;
  transition: var(--transition-fast);
}

[data-theme="dark"] .theme-switch-track {
  background: var(--primary-purple);
}

.theme-switch-thumb {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: #FFFFFF;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .theme-switch-thumb {
  transform: translateX(18px);
}

.sidebar-account-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.sidebar-account-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  background: rgba(139, 92, 246, 0.05);
  border: 1px solid var(--border-light);
}

.account-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-purple), var(--accent-pink));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(139, 92, 246, 0.2);
}

.account-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.account-name {
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.account-role {
  font-size: 0.73rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Explicit Sign In & Logout Buttons */
.btn-sidebar-auth {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary-purple), var(--secondary-cyan));
  border: none;
  color: #FFFFFF;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.25);
}

.btn-sidebar-auth:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(6, 182, 212, 0.35);
}

.btn-sidebar-logout {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #EF4444;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-sidebar-logout:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #EF4444;
  color: #DC2626;
}

/* Mobile Responsive Drawer */
@media (max-width: 768px) {
  .nexa-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: 15px 0 40px rgba(0, 0, 0, 0.3);
  }

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