/* ========================================================================== */
/* Sidebar — Apple Futuristic (Pixel-Perfect)                                  */
/* 280px width, 44px touch targets, 8px margins, SF font                      */
/* ========================================================================== */

.chat-sidebar-toggle {
  position: fixed; top: 12px; left: 12px; z-index: 40;
  padding: 8px 12px;
  background: rgba(30,30,30,0.85) !important;
  backdrop-filter: saturate(180%) blur(20px) !important;
  border: 0.5px solid rgba(255,255,255,0.1) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text-secondary) !important;
  cursor: pointer; transition: all 0.15s !important; font-size: 14px;
}
.chat-sidebar-toggle:hover { color: var(--text-primary) !important; }
.sidebar-count { color: #007AFF !important; font-weight: 600; }

.sidebar-panel {
  width: 280px; min-width: 280px;
  height: 100%; max-height: 100%;
  box-sizing: border-box;
  display: flex; flex-direction: column;
  background: rgba(28,28,30,0.92) !important;
  backdrop-filter: saturate(180%) blur(20px) !important;
  border-right: 0.5px solid rgba(255,255,255,0.06) !important;
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
}
.sidebar-panel::before, .sidebar-panel::after { display: none !important; }
.sidebar-panel.collapsed { width: 0 !important; min-width: 0 !important; overflow: hidden; }

/* Header */
.sidebar-header {
  padding: 12px 14px 8px !important;
  display: flex; align-items: center; justify-content: space-between !important;
  flex-shrink: 0;
}
.sidebar-header-title {
  font-size: 13px !important; font-weight: 600 !important;
  color: var(--text-secondary) !important;
  text-transform: uppercase; letter-spacing: 0.02em;
}
.sidebar-header-actions { display: flex; gap: 2px; }
.sidebar-btn {
  width: 30px; height: 30px;
  border-radius: 6px !important;
  border: none !important; background: transparent !important;
  color: var(--text-tertiary) !important;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.12s !important; font-size: 16px;
}
.sidebar-btn:hover { background: rgba(255,255,255,0.06) !important; color: var(--text-primary) !important; }

/* New Chat — Apple blue button */
.sidebar-new-btn {
  margin: 6px 12px 10px !important;
  padding: 9px 14px !important;
  border-radius: var(--radius-sm) !important;
  border: none !important;
  background: #007AFF !important;
  color: #fff !important;
  font-size: 13px !important; font-weight: 500 !important;
  cursor: pointer; display: flex; align-items: center; gap: 6px;
  width: calc(100% - 24px) !important;
  transition: opacity 0.12s !important;
  flex-shrink: 0;
}
.sidebar-new-btn:hover { opacity: 0.85 !important; }
.sidebar-new-btn:active { opacity: 0.7 !important; }
.sidebar-new-btn::before { display: none !important; }

/* Search */
.sidebar-search-wrap { margin: 0 12px 8px !important; flex-shrink: 0; }
.sidebar-search {
  width: 100% !important; padding: 8px 10px !important;
  background: rgba(0,0,0,0.2) !important;
  border: none !important;
  border-radius: 8px !important;
  color: var(--text-primary) !important; font-size: 13px !important;
  outline: none !important; transition: background 0.12s !important;
  box-sizing: border-box !important;
}
.sidebar-search:focus { background: rgba(0,0,0,0.3) !important; }
.sidebar-search::placeholder { color: var(--text-placeholder) !important; }

/* List */
.sidebar-list { flex: 1; overflow-y: auto; padding: 4px 8px !important; min-height: 0; }

/* Item — 44px touch target */
.sidebar-item {
  padding: 0 12px !important;
  margin: 0 !important;
  height: 44px !important;
  min-height: 44px !important;
  border-radius: var(--radius-sm) !important;
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  background: transparent !important;
  border: none !important;
  transition: background 0.12s !important;
  position: relative;
}
.sidebar-item::before { display: none !important; }
.sidebar-chatname {
  flex: 1; min-width: 0;
  font-size: 14px !important;
  color: rgba(255,255,255,0.6) !important;
  white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important;
  transition: color 0.12s !important;
  line-height: 1.3 !important;
  letter-spacing: -0.01em !important;
}
.sidebar-item:hover { background: rgba(255,255,255,0.04) !important; }
.sidebar-item:hover .sidebar-chatname { color: rgba(255,255,255,0.85) !important; }

/* Active */
.sidebar-item-active { background: rgba(255,255,255,0.06) !important; }
.sidebar-item-active .sidebar-chatname { color: rgba(255,255,255,0.95) !important; font-weight: 500 !important; }
.sidebar-item-active::before { display: none !important; }

/* Current dot */
.sidebar-current-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #007AFF !important;
  flex-shrink: 0;
}

/* Delete */
.sidebar-delete-btn {
  opacity: 0; border: none !important; background: transparent !important;
  color: var(--text-tertiary) !important; cursor: pointer;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px; transition: all 0.12s !important; font-size: 14px !important;
  flex-shrink: 0;
}
.sidebar-item:hover .sidebar-delete-btn { opacity: 1 !important; }
.sidebar-delete-btn:hover { color: #ff453a !important; }

/* Rename */
.sidebar-rename-input {
  flex: 1; min-width: 0;
  background: rgba(0,0,0,0.3) !important;
  border: none !important;
  border-radius: 4px !important; color: var(--text-primary) !important;
  padding: 4px 8px !important; font-size: 14px !important;
  outline: none !important; box-sizing: border-box !important;
}

/* Footer */
.sidebar-footer {
  padding: 8px 12px !important;
  border-top: 0.5px solid rgba(255,255,255,0.04) !important;
  display: flex; gap: 4px;
  flex-shrink: 0;
}
.sidebar-footer-btn {
  flex: 1; padding: 8px !important;
  border-radius: 6px !important;
  border: none !important; background: rgba(255,255,255,0.03) !important;
  color: var(--text-tertiary) !important;
  font-size: 12px !important;
  cursor: pointer; transition: all 0.12s !important;
  text-align: center !important;
}
.sidebar-footer-btn:hover { background: rgba(255,255,255,0.06) !important; color: var(--text-secondary) !important; }

.chat-sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3) !important;
  backdrop-filter: blur(4px) !important; z-index: 49;
}
@media (max-width: 768px) {
  .sidebar-panel { position: fixed !important; left: 0; top: 0; z-index: 50; width: 280px !important; }
}

/* ═══ LIGHT MODE ═══ */
[data-theme="light"] .sidebar-panel {
  background: rgba(242,242,247,0.92) !important;
  border-right-color: rgba(0,0,0,0.06) !important;
}
[data-theme="light"] .sidebar-chatname { color: rgba(0,0,0,0.55) !important; }
[data-theme="light"] .sidebar-item:hover { background: rgba(0,0,0,0.04) !important; }
[data-theme="light"] .sidebar-item:hover .sidebar-chatname { color: rgba(0,0,0,0.8) !important; }
[data-theme="light"] .sidebar-item-active { background: rgba(0,0,0,0.06) !important; }
[data-theme="light"] .sidebar-item-active .sidebar-chatname { color: rgba(0,0,0,0.9) !important; }
[data-theme="light"] .sidebar-header-title { color: rgba(0,0,0,0.45) !important; }
[data-theme="light"] .sidebar-btn { color: rgba(0,0,0,0.35) !important; }
[data-theme="light"] .sidebar-btn:hover { background: rgba(0,0,0,0.06) !important; color: rgba(0,0,0,0.7) !important; }
[data-theme="light"] .sidebar-search { background: rgba(0,0,0,0.04) !important; color: var(--text-primary) !important; }
[data-theme="light"] .sidebar-search:focus { background: rgba(0,0,0,0.06) !important; }
[data-theme="light"] .sidebar-footer { border-top-color: rgba(0,0,0,0.06) !important; }
[data-theme="light"] .sidebar-footer-btn { color: rgba(0,0,0,0.35) !important; }
[data-theme="light"] .sidebar-footer-btn:hover { background: rgba(0,0,0,0.04) !important; color: rgba(0,0,0,0.6) !important; }
[data-theme="light"] .sidebar-delete-btn { color: rgba(0,0,0,0.25) !important; }
[data-theme="light"] .sidebar-delete-btn:hover { color: #ff453a !important; }
[data-theme="light"] .sidebar-rename-input { background: rgba(0,0,0,0.04) !important; color: var(--text-primary) !important; }
[data-theme="light"] .chat-sidebar-toggle {
  background: rgba(255,255,255,0.85) !important;
  border-color: rgba(0,0,0,0.08) !important;
  color: var(--text-secondary) !important;
}
[data-theme="light"] .chat-sidebar-overlay { background: rgba(0,0,0,0.15) !important; }
