/* ============================
   TUNLEY — Sidebar Styles
   ============================ */

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  height: 100vh;
  background: var(--tunley-sidebar);
  border-right: 1px solid var(--tunley-border);
  display: flex;
  flex-direction: column;
  overflow: visible;
  flex-shrink: 0;
  z-index: 100;
}

/* Logo */
.sidebar-logo {
  padding: 16px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--tunley-border);
}

.sidebar-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: var(--tunley-accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
}

.sidebar-logo .logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* New Chat Button */
.new-chat-btn {
  margin: 12px 12px 8px;
  padding: 10px;
  background: var(--tunley-surface);
  border: 1px solid var(--tunley-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--tunley-text);
  transition: var(--transition);
}

.new-chat-btn:hover {
  background: var(--tunley-surface-2);
  border-color: var(--tunley-accent);
  color: var(--tunley-accent);
}

/* Search */
.sidebar-search {
  padding: 8px 12px;
}

.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  background: var(--tunley-surface);
  border: 1px solid var(--tunley-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--tunley-text);
}

.sidebar-search input:focus {
  border-color: var(--tunley-accent);
}

.sidebar-search input::placeholder {
  color: var(--tunley-text-muted);
}

/* History List */
.sidebar-section-header {
  padding: 12px 16px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--tunley-text-muted);
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}

.history-item {
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-item:hover {
  background: var(--tunley-surface);
}

.history-item.active {
  background: var(--tunley-surface-2);
  border-left: 2px solid var(--tunley-accent);
}

.history-item .item-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.history-item .item-info {
  flex: 1;
  min-width: 0;
}

.history-item .item-title {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item .item-meta {
  font-size: 11px;
  color: var(--tunley-text-muted);
  margin-top: 2px;
}

.history-item .item-delete {
  opacity: 0;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--tunley-text-muted);
  transition: var(--transition);
}

.history-item:hover .item-delete {
  opacity: 1;
}

.history-item .item-delete:hover {
  background: var(--tunley-danger-bg);
  color: var(--tunley-red);
}

.history-group-label {
  padding: 16px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--tunley-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Sidebar Bottom */
.sidebar-bottom {
  border-top: 1px solid var(--tunley-border);
  padding: 8px 12px;
}

.sidebar-bottom .profile-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--tunley-text);
  transition: var(--transition);
}

.sidebar-bottom .profile-btn:hover {
  background: var(--tunley-surface);
}

.sidebar-bottom .profile-btn .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--tunley-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

/* ============================
   Models Section — Sidebar Nested Menu (UI_MODEL_SELECTOR_SIDEBAR.md)
   ============================ */

.models-section {
  padding: 8px;
  border-top: 1px solid var(--tunley-border);
  border-bottom: 1px solid var(--tunley-border);
  position: relative;
}

.models-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--tunley-surface);
  border: 1px solid var(--tunley-border);
  border-radius: 10px;
  color: var(--tunley-text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.models-trigger:hover {
  background: var(--tunley-surface-2);
}

.models-icon { font-size: 14px; }
.models-label { font-weight: 500; }

.models-current {
  margin-left: auto;
  color: var(--tunley-accent);
  font-size: 12px;
  font-weight: 500;
}

.chevron {
  color: var(--tunley-text-muted);
  font-size: 12px;
}

/* Nested menu — opens UPWARD above the trigger button */
.models-menu {
  position: absolute;
  bottom: calc(100% + 4px);
  top: auto;
  left: 0;
  right: 0;
  background: var(--tunley-surface);
  border: 1px solid var(--tunley-border);
  border-radius: 12px;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.6);
  z-index: 200;
  overflow: visible;
  max-height: 75vh;
  min-width: 100%;
}

.models-menu-platforms {
  flex: 1;
  max-height: 340px;
  overflow-y: auto;
  padding: 6px;
  min-width: 140px;
}

.platform-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--tunley-text);
  transition: background 0.1s ease;
  white-space: nowrap;
}

.platform-item:hover {
  background: var(--tunley-surface-2);
}

.platform-item.active-platform {
  background: rgba(124, 110, 247, 0.08);
  border-left: 2px solid var(--tunley-accent);
}

.platform-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.platform-arrow { color: var(--tunley-text-muted); font-size: 14px; margin-left: 4px; flex-shrink: 0; }

/* Submenu — shows models for hovered platform, positioned to the right with clear gap */
.models-menu-models {
  position: absolute;
  left: calc(100% + 6px);
  top: 0;
  width: 220px;
  max-height: 340px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--tunley-border);
  border-radius: 12px;
  background: var(--tunley-surface-2);
  box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  z-index: 201;
}

.submenu-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tunley-text-muted);
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--tunley-border);
  margin-bottom: 4px;
  white-space: nowrap;
}

.model-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--tunley-text);
  gap: 8px;
  border: 1px solid transparent;
  transition: all 0.12s ease;
}

.model-item:hover {
  background: var(--tunley-surface);
  border-color: var(--tunley-border);
}

.model-item.selected {
  background: rgba(124, 110, 247, 0.1);
  border: 1px solid var(--tunley-accent);
  color: var(--tunley-accent-glow);
  box-shadow: 0 0 0 1px var(--tunley-accent);
}

.model-item .model-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-dot {
  color: var(--tunley-accent);
  font-size: 12px;
  flex-shrink: 0;
}

/* First-time hint */
.first-time-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin: 8px 12px;
  background: rgba(124, 110, 247, 0.1);
  border: 1px solid var(--tunley-accent);
  border-radius: 10px;
  font-size: 12px;
  color: var(--tunley-text);
}

.hint-icon { font-size: 14px; }
.hint-text { flex: 1; line-height: 1.4; }
.hint-dismiss {
  background: none;
  border: none;
  color: var(--tunley-text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
}

/* Mobile behavior */
@media (max-width: 768px) {
  .models-section {
    border: none;
    padding: 6px 12px;
  }

  .models-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    border-radius: 16px 16px 0 0;
    flex-direction: column;
    max-height: 60vh;
    min-width: auto;
  }

  .models-menu-models {
    position: static;
    left: auto;
    top: auto;
    width: auto;
    border-left: none;
    border-top: 1px solid var(--tunley-border);
    box-shadow: none;
    margin-top: 4px;
  }
}

