/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 220px;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 28px 14px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.2s ease, padding 0.2s ease;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 20px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 8px;
}
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--text3);
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.sidebar-collapse-btn:hover { color: var(--text); background: var(--surface2); }
.sidebar-collapse-btn svg { width: 14px; height: 14px; transition: transform 0.2s; }
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
.sidebar-brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--text3);
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}
.sidebar-brand .brand-short { display: none; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 7px;
  border-radius: 10px;
  height: 38px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-nav a:hover { background: var(--surface2); color: var(--text); }
.sidebar-nav a.active {
  background: var(--surface2);
  color: var(--text);
  font-weight: 600;
}
.sidebar-nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
.sidebar-nav a.active svg { opacity: 1; }
.sidebar-nav .nav-label { transition: opacity 0.15s; }

/* ===== Sidebar chat list ===== */
.sidebar-chats {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
}
.sidebar-chats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 6px;
}
.sidebar-chats-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
}
.sidebar-new-chat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  padding: 0;
  transition: background 0.12s, color 0.12s;
}
.sidebar-new-chat:hover { background: var(--surface2); color: var(--text); }
.sidebar-new-chat svg { width: 14px; height: 14px; }
.sidebar-chats-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  padding-right: 2px;
}
.sidebar-chats-empty {
  font-size: 12px;
  color: var(--text3);
  padding: 10px 12px;
  line-height: 1.4;
}
.sidebar-chat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.sidebar-chat-item:hover { background: var(--surface2); color: var(--text); }
.sidebar-chat-item.active {
  background: var(--surface2);
  color: var(--text);
  font-weight: 500;
}
.sidebar-chat-item .sidebar-chat-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.35;
}
.sidebar-chat-item .sidebar-chat-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 0;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  padding: 0;
  opacity: 0;
  flex-shrink: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.sidebar-chat-item:hover .sidebar-chat-delete { opacity: 1; }
.sidebar-chat-item .sidebar-chat-delete:hover { background: var(--border); color: var(--text); }
.sidebar-chat-item .sidebar-chat-delete svg { width: 13px; height: 13px; }

/* Hide chat list when sidebar is collapsed */
.sidebar.collapsed .sidebar-chats { display: none; }

/* ===== Collapsed state ===== */
.sidebar.collapsed {
  width: 60px;
  padding: 28px 0;
}
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 0 0 16px; }
.sidebar.collapsed .sidebar-brand { display: none; }
.sidebar.collapsed .sidebar-nav a {
  justify-content: center;
  padding: 10px 0;
  height: 38px;
}
.sidebar.collapsed .sidebar-nav .nav-label { display: none; }

/* ===== Mobile sidebar ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: translateX(0); }
}
