/* ═══════════════════════════════════════════════════════════════
   VOXPLUS AI  —  Global Styles
   ═══════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand palette */
  --brand-purple: #7C6FFF;
  --brand-teal:   #3ECFCF;
  --brand-grad:   linear-gradient(135deg, #7C6FFF 0%, #3ECFCF 100%);

  /* Surface colours (dark theme) */
  --bg-base:      #0D0D12;
  --bg-sidebar:   #111118;
  --bg-surface:   #18181F;
  --bg-input:     #1E1E27;
  --bg-hover:     #22222C;
  --bg-active:    #2A2A38;
  --bg-message-ai:#1A1A24;

  /* Borders */
  --border:       #2A2A38;
  --border-light: #333345;

  /* Text */
  --text-primary: #ECECF1;
  --text-muted:   #8E8EA0;
  --text-subtle:  #565670;

  /* Utility */
  --radius-sm:    6px;
  --radius-md:    12px;
  --radius-lg:    18px;
  --radius-xl:    24px;
  --transition:   0.18s ease;
  --sidebar-w:    260px;
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.45);
}

html { font-size: 16px; height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  height: 100%;
  display: flex;
  overflow: hidden;
  line-height: 1.6;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ═══════════════════════════════ SIDEBAR ═══════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: transform var(--transition), min-width var(--transition), width var(--transition);
  z-index: 100;
}

.sidebar.collapsed {
  transform: translateX(-100%);
  width: 0;
  min-width: 0;
}

/* Sidebar header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 14px 14px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon { display: flex; align-items: center; }
.logo-text {
  font-weight: 700;
  font-size: 1.05rem;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

/* New chat button */
.btn-new-chat {
  margin: 12px 12px 6px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-active);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  font-family: inherit;
}
.btn-new-chat:hover {
  background: var(--brand-purple);
  border-color: var(--brand-purple);
  color: #fff;
}

.sidebar-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 14px 16px 6px;
}

/* Chat history list */
.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  gap: 6px;
}
.history-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.history-item.active { background: var(--bg-active); color: var(--text-primary); }

.history-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-del {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 2px;
  display: flex;
  border-radius: 4px;
  transition: opacity var(--transition), color var(--transition);
}
.history-item:hover .history-item-del { opacity: 1; }
.history-item-del:hover { color: #ff6b6b; }

/* Sidebar footer */
.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
}
.sidebar-footer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  font-size: 0.84rem;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.sidebar-footer-item:hover { background: var(--bg-hover); color: #ff6b6b; }

/* ═══════════════════════════════ MAIN ══════════════════════════════════════ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-base);
  min-width: 0;
}

/* ─── Topbar ──────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 58px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-base);
  flex-shrink: 0;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1rem;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Icon buttons */
.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Model selector */
.model-selector-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.model-selector {
  appearance: none;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 7px 32px 7px 12px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}
.model-selector:hover { border-color: var(--brand-purple); background: var(--bg-hover); }
.model-selector:focus { border-color: var(--brand-purple); }
.model-selector option { background: var(--bg-surface); }
.model-selector-arrow {
  position: absolute;
  right: 10px;
  pointer-events: none;
  color: var(--text-muted);
}

/* ─── Chat window ───────────────────────────────────────────────── */
.chat-window {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ─── Welcome screen ─────────────────────────────────────────────── */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 16px;
  animation: fadeIn 0.4s ease;
}

.welcome-logo {
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.06); opacity: 0.9; }
}

.welcome-title {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 700;
  text-align: center;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
}

/* Suggestion cards */
.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  max-width: 700px;
  width: 100%;
  margin-top: 12px;
}

.suggestion-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.84rem;
  line-height: 1.5;
  transition: border-color var(--transition), background var(--transition), color var(--transition), transform var(--transition);
}
.suggestion-card:hover {
  border-color: var(--brand-purple);
  background: var(--bg-hover);
  color: var(--text-primary);
  transform: translateY(-2px);
}
.suggestion-icon { font-size: 1.3rem; }

/* ─── Messages ────────────────────────────────────────────────────── */
.messages-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 12px 0 24px;
}
.messages-container:empty { display: none; }

.message-row {
  padding: 18px max(20px, calc(50% - 380px));
  display: flex;
  gap: 14px;
  align-items: flex-start;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message-row.user-row { justify-content: flex-end; }
.message-row.ai-row   { background: var(--bg-message-ai); }

/* Avatars */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}
.avatar-ai {
  background: var(--brand-grad);
  color: #fff;
}
.avatar-user {
  background: var(--bg-active);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
}

/* Bubble */
.message-bubble {
  max-width: 680px;
  line-height: 1.7;
  font-size: 0.93rem;
}
.user-row .message-bubble {
  background: var(--bg-active);
  border: 1px solid var(--border-light);
  padding: 12px 16px;
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
  color: var(--text-primary);
}
.ai-row .message-bubble {
  color: var(--text-primary);
}

/* Markdown-ish styling inside AI bubbles */
.message-bubble p       { margin: 0 0 10px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble h1, .message-bubble h2, .message-bubble h3 {
  margin: 16px 0 8px; font-weight: 600;
}
.message-bubble ul, .message-bubble ol {
  padding-left: 20px; margin: 8px 0;
}
.message-bubble li { margin: 4px 0; }
.message-bubble code {
  font-family: 'Fira Mono', 'Consolas', monospace;
  font-size: 0.85em;
  background: rgba(124,111,255,0.15);
  border: 1px solid rgba(124,111,255,0.25);
  padding: 2px 6px;
  border-radius: 4px;
}
.message-bubble pre {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  overflow-x: auto;
  margin: 10px 0;
  position: relative;
}
.message-bubble pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.875rem;
}
.message-bubble blockquote {
  border-left: 3px solid var(--brand-purple);
  padding-left: 12px;
  margin: 10px 0;
  color: var(--text-muted);
}
.message-bubble strong { font-weight: 600; }
.message-bubble a { color: var(--brand-teal); text-decoration: none; }
.message-bubble a:hover { text-decoration: underline; }
.message-bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* Typing cursor */
.cursor {
  display: inline-block;
  width: 6px; height: 16px;
  background: var(--brand-purple);
  border-radius: 2px;
  margin-left: 2px;
  vertical-align: middle;
  animation: blink 0.8s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Copy code button  */
.code-block-wrap { position: relative; }
.copy-code-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--bg-active);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: inherit;
  padding: 4px 10px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  display: flex; align-items: center; gap: 4px;
}
.copy-code-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.copy-code-btn.copied { color: var(--brand-teal); border-color: var(--brand-teal); }

/* Message actions (below AI message) */
.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.msg-action-btn {
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  display: flex; align-items: center; gap: 4px;
  transition: background var(--transition), color var(--transition);
  font-family: inherit;
}
.msg-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.msg-action-btn.active { color: var(--brand-teal); }

/* ─── Input area ─────────────────────────────────────────────────── */
.input-area {
  padding: 12px max(16px, calc(50% - 400px)) 18px;
  background: var(--bg-base);
  flex-shrink: 0;
}

.input-wrap {
  position: relative;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px 10px 18px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-wrap:focus-within {
  border-color: var(--brand-purple);
  box-shadow: 0 0 0 3px rgba(124,111,255,0.12);
}

.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: none;
  max-height: 200px;
  overflow-y: auto;
  padding: 2px 0;
}
.chat-input::placeholder { color: var(--text-subtle); }

.btn-send {
  flex-shrink: 0;
  width: 38px; height: 38px;
  background: var(--brand-grad);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity var(--transition), transform var(--transition);
}
.btn-send:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-send:not(:disabled):hover { transform: scale(1.08); }

.input-disclaimer {
  font-size: 0.72rem;
  color: var(--text-subtle);
  text-align: center;
  margin-top: 8px;
}

/* ─── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.visible { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  max-width: 380px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px);
  transition: transform 0.2s ease;
}
.modal-overlay.visible .modal { transform: translateY(0); }

.modal h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 8px; }
.modal p  { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 22px; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-modal-cancel {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  background: var(--bg-active);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  font-family: inherit; font-size: 0.875rem; cursor: pointer;
  transition: background var(--transition);
}
.btn-modal-cancel:hover { background: var(--bg-hover); }
.btn-modal-confirm {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  background: #c23b2e;
  border: none;
  color: #fff;
  font-family: inherit; font-size: 0.875rem; font-weight: 500; cursor: pointer;
  transition: background var(--transition);
}
.btn-modal-confirm:hover { background: #e0453a; }

/* ─── Animations ─────────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar.collapsed {
    transform: translateX(-100%);
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
  }
  .topbar-logo { display: none; }
  .suggestion-grid { grid-template-columns: 1fr 1fr; }
  .message-row { padding: 14px 14px; }
  .input-area { padding: 10px 12px 14px; }
}
