/* ── AI CHAT — APP-LIKE LAYOUT ─────────────────────── */

#view-ai-chat {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ai-app {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* ── SIDEBAR ──────────────────────────────────────── */

.ai-app-sidebar {
  width: 240px;
  min-width: 200px;
  border-right: 1px solid var(--b1);
  display: flex;
  flex-direction: column;
  background: var(--bg1);
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
  flex-shrink: 0;
}

.ai-app-sidebar.collapsed {
  width: 0;
  min-width: 0;
}

.ai-sidebar-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px 10px;
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
}

.ai-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--tx);
  white-space: nowrap;
}

.ai-new-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-d);
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  border-radius: 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.ai-new-btn:hover { background: var(--accent); color: #fff; }

.ai-history-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--t3);
  padding: 10px 14px 4px;
  flex-shrink: 0;
}

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

.ai-no-sessions {
  font-size: 12px;
  color: var(--t3);
  text-align: center;
  padding: 20px 12px;
  line-height: 1.5;
}

/* scrollbar */
.ai-session-list::-webkit-scrollbar { width: 3px; }
.ai-session-list::-webkit-scrollbar-thumb { background: var(--b2); border-radius: 2px; }

/* session item */
.ai-session-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s;
  margin-bottom: 2px;
  position: relative;
}
.ai-session-item:hover  { background: var(--b1); }
.ai-session-item.active { background: var(--accent-d); }

.ai-session-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--b2);
  flex-shrink: 0;
  transition: background 0.12s;
}
.ai-session-dot.done { background: var(--green, #3dba6e); }
.ai-session-item.active .ai-session-dot { background: var(--accent); }

.ai-session-body {
  flex: 1;
  min-width: 0;
}
.ai-session-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--tx);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-session-item.active .ai-session-title { color: var(--accent); }
.ai-session-meta {
  font-size: 10px;
  color: var(--t3);
  margin-top: 1px;
}

.ai-session-del {
  background: none;
  border: none;
  color: var(--t3);
  cursor: pointer;
  padding: 3px;
  border-radius: 3px;
  display: none;
  flex-shrink: 0;
  line-height: 1;
}
.ai-session-item:hover .ai-session-del { display: flex; align-items: center; }
.ai-session-del:hover { color: var(--red, #ef4444); background: rgba(239,68,68,0.1); }

/* ── MAIN CHAT AREA ────────────────────────────────── */

.ai-app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.ai-main-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
  background: var(--bg1);
}

.ai-toggle-sidebar-btn {
  background: none;
  border: 1px solid var(--b2);
  border-radius: 5px;
  color: var(--t2);
  padding: 5px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background 0.12s;
}
.ai-toggle-sidebar-btn:hover { background: var(--b1); color: var(--tx); }

.ai-main-topbar-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--tx);
}

.ai-state-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-d);
  border-radius: 10px;
  padding: 3px 10px;
  letter-spacing: .3px;
  margin-left: auto;
}

/* ── AI AVATAR ─────────────────────────────────────── */
.ai-avi {
  background: linear-gradient(135deg, #6366f1, #a855f7) !important;
  color: #fff !important;
  font-size: 10px !important;
  font-weight: 800 !important;
}

/* ── TYPING INDICATOR ──────────────────────────────── */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  padding: 8px 20px;
  font-size: 13px;
  color: var(--t3);
  flex-shrink: 0;
  gap: 3px;
}
.ai-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: ai-pulse 1.4s ease-in-out infinite;
}
.ai-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-dot:nth-child(3) { animation-delay: 0.4s; }
.ai-typing-text { margin-left: 6px; }

@keyframes ai-pulse {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40%           { transform: scale(1);   opacity: 1;   }
}

/* ── INPUT WRAP (glassmorphism) ────────────────────── */
#view-ai-chat .chat-input-wrap {
  background: var(--glass-bg, rgba(255,255,255,0.04));
  backdrop-filter: var(--glass-blur, blur(12px));
  -webkit-backdrop-filter: var(--glass-blur, blur(12px));
  border-top: 1px solid var(--glass-border, rgba(255,255,255,0.08));
  box-shadow: var(--shadow-glass, 0 -4px 16px rgba(0,0,0,0.12));
  position: sticky;
  bottom: 0;
  flex-shrink: 0;
}

/* ── TITLE CARDS ───────────────────────────────────── */
.ai-title-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.ai-title-card {
  background: var(--bg2);
  border: 1px solid var(--b2);
  border-radius: var(--r, 8px);
  padding: 11px 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.ai-title-card:hover {
  border-color: var(--accent);
  background: var(--accent-d);
  transform: translateX(3px);
}
.ai-title-card-history {
  cursor: default;
  opacity: 0.75;
}
.ai-title-card-history:hover {
  transform: none;
  border-color: var(--b2);
  background: var(--bg2);
}
.ai-title-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--tx);
  margin-bottom: 3px;
}
.ai-title-card-hook {
  font-size: 12px;
  color: var(--t2);
  margin-bottom: 4px;
}
.ai-title-card-meta {
  font-size: 11px;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* ── BULK INGEST MODAL ─────────────────────────────── */
.ingest-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.ingest-tab {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--b2);
  background: var(--bg2);
  color: var(--t2);
  font-size: 13px;
  cursor: pointer;
}
.ingest-tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.ingest-framework-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--t2);
  cursor: pointer;
  padding: 3px 0;
}

.ingest-progress-wrap { margin-top: 12px; }
.ingest-progress-bar-bg {
  height: 4px;
  background: var(--b2);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.ingest-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .3s;
  width: 0%;
}

.ingest-result-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--b1);
}
.ingest-result-item:last-child { border-bottom: none; }

/* ── RESPONSIVE ────────────────────────────────────── */
@media (max-width: 640px) {
  .ai-app-sidebar { width: 0; min-width: 0; }
  .ai-app-sidebar.collapsed { width: 0; }
  /* On mobile, opening sidebar overlays */
  .ai-app-sidebar.open {
    width: 220px;
    min-width: 220px;
    position: absolute;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }
}
