/* ═══════════════════════════════════════════════════════════════
   NexusAI — Chat Interface Styles
   ═══════════════════════════════════════════════════════════════ */

.chat-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ─── App Layout ─────────────────────────────────────────── */
.chat-body { flex-direction: row; }
.chat-body .chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; }

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: transform .3s ease, width .3s ease;
  z-index: 200;
}
.sidebar.collapsed { transform: translateX(-100%); width: 0; min-width: 0; }

.sidebar-header {
  padding: 1rem 1rem .8rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

/* ─── API Key Section ─────────────────────────────────────── */
.api-key-section {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(124,106,255,.04);
}
.section-label {
  font-size: 11px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: .06em;
  display: block; margin-bottom: .5rem;
}
.api-input-wrap { display: flex; gap: .4rem; margin-bottom: .4rem; }
.api-input-wrap input { flex: 1; font-size: 12px; padding: .45rem .7rem; }
.btn-save-key {
  background: var(--accent); color: var(--white);
  border: none; padding: .45rem .8rem;
  border-radius: var(--radius-sm); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: opacity .2s; white-space: nowrap;
}
.btn-save-key:hover { opacity: .85; }
.api-hint { font-size: 11px; color: var(--text3); }
.api-hint a { color: var(--accent2); }
.key-status { margin-top: .4rem; font-size: 11px; }
.key-status.ok { color: var(--green); }
.key-status.err { color: var(--red); }

/* ─── Model Section ────────────────────────────────────────── */
.model-section { padding: .9rem 1rem; border-bottom: 1px solid var(--border); }
.model-select { margin-bottom: .4rem; font-size: 13px; padding: .4rem .7rem; }
.btn-load-models {
  background: none; border: 1px solid var(--border);
  color: var(--text3); font-size: 11px; padding: .3rem .7rem;
  border-radius: var(--radius-sm); cursor: pointer; transition: all .2s;
  width: 100%;
}
.btn-load-models:hover { border-color: var(--accent); color: var(--accent2); }

/* ─── Temperature ─────────────────────────────────────────── */
.temp-section { padding: .9rem 1rem; border-bottom: 1px solid var(--border); }
.temp-slider {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 4px; background: var(--border2); border-radius: 2px;
  margin: .4rem 0; cursor: pointer;
}
.temp-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px;
  background: var(--accent); border-radius: 50%;
}
.temp-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--text3); }

/* ─── Mode Tabs ──────────────────────────────────────────── */
.mode-section { padding: .9rem 1rem; border-bottom: 1px solid var(--border); }
.mode-tabs { display: flex; gap: .4rem; }
.mode-tab {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  color: var(--text2); font-size: 12px; padding: .4rem .3rem;
  border-radius: var(--radius-sm); cursor: pointer; transition: all .2s;
}
.mode-tab.active { background: var(--accent); border-color: var(--accent); color: var(--white); }

/* ─── History ─────────────────────────────────────────────── */
.history-section { padding: .9rem 1rem; flex: 1; overflow-y: auto; }
.history-list { display: flex; flex-direction: column; gap: .3rem; }
.history-item {
  padding: .5rem .7rem; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s;
  font-size: 12px; color: var(--text2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: .4rem;
}
.history-item:hover { background: var(--surface2); color: var(--text); }
.history-item.active { background: var(--surface2); color: var(--accent2); }
.history-empty { color: var(--text3); font-size: 12px; text-align: center; padding: 1rem 0; }

.sidebar-footer {
  padding: .8rem 1rem;
  border-top: 1px solid var(--border);
  display: flex; gap: .5rem;
}
.sidebar-link {
  flex: 1; text-align: center; padding: .4rem;
  font-size: 12px; color: var(--text3);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: all .2s;
}
.sidebar-link:hover { border-color: var(--border2); color: var(--text2); }

/* ─── Topbar ──────────────────────────────────────────────── */
.chat-topbar {
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  background: var(--bg2);
  flex-shrink: 0;
}
.topbar-title { flex: 1; font-size: 14px; font-weight: 600; color: var(--text); font-family: var(--font-head); }
.topbar-actions { display: flex; gap: .4rem; }

/* ─── Messages Area ───────────────────────────────────────── */
.messages-area {
  flex: 1; overflow-y: auto; padding: 2rem 1.5rem;
  display: flex; flex-direction: column; gap: 0;
  background: var(--bg);
}

/* ─── Welcome Screen ──────────────────────────────────────── */
.welcome-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 80%;
  padding: 2rem; text-align: center; position: relative;
}
.welcome-glow {
  position: absolute; width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(124,106,255,.12) 0%, transparent 70%);
  border-radius: 50%; pointer-events: none;
}
.welcome-title {
  font-size: clamp(1.8rem, 4vw, 2.8rem); color: var(--white);
  margin-bottom: .8rem; position: relative;
}
.welcome-sub { color: var(--text2); font-size: 15px; margin-bottom: 2.5rem; max-width: 460px; }
.suggestion-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: .8rem; max-width: 740px; width: 100%;
}
.suggestion-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  text-align: left; cursor: pointer; transition: all .2s;
  display: flex; flex-direction: column; gap: .5rem;
  font-family: var(--font-body); color: var(--text2); font-size: 13px;
}
.suggestion-card:hover { border-color: var(--accent); background: var(--surface2); color: var(--text); transform: translateY(-2px); box-shadow: 0 4px 20px var(--accent-glow); }
.sug-icon { font-size: 1.4rem; }

/* ─── Messages ────────────────────────────────────────────── */
.message-row {
  display: flex; gap: 1rem; padding: 1.2rem 0;
  animation: fadeUp .3s ease both;
}
.message-row + .message-row { border-top: 1px solid rgba(255,255,255,.04); }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; font-size: 14px;
  flex-shrink: 0; font-weight: 700; font-family: var(--font-head);
}
.msg-avatar.user-av { background: var(--accent); color: var(--white); }
.msg-avatar.ai-av { background: var(--surface2); color: var(--accent2); border: 1px solid var(--border2); }
.msg-body { flex: 1; min-width: 0; }
.msg-name { font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: .3rem; font-family: var(--font-head); }
.msg-name .msg-time { font-weight: 400; color: var(--text3); margin-left: .5rem; }
.msg-content { color: var(--text); font-size: 14.5px; line-height: 1.7; }
.msg-content p { margin-bottom: .6rem; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content pre {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1rem; overflow-x: auto;
  margin: .8rem 0; font-size: 13px;
}
.msg-content code {
  background: var(--surface2); padding: .1rem .4rem;
  border-radius: 4px; font-size: 13px; font-family: 'Courier New', monospace;
}
.msg-content pre code { background: none; padding: 0; }
.msg-content ul, .msg-content ol { padding-left: 1.4rem; margin: .5rem 0; }
.msg-content li { margin-bottom: .3rem; }
.msg-content h1,.msg-content h2,.msg-content h3 { color: var(--white); margin: 1rem 0 .4rem; }
.msg-content strong { color: var(--white); font-weight: 600; }
.msg-content blockquote {
  border-left: 3px solid var(--accent); padding-left: 1rem;
  color: var(--text2); margin: .8rem 0; font-style: italic;
}
.msg-actions {
  display: flex; gap: .4rem; margin-top: .6rem; opacity: 0; transition: opacity .2s;
}
.message-row:hover .msg-actions { opacity: 1; }
.msg-action-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text3); font-size: 11px; padding: .25rem .6rem;
  border-radius: var(--radius-sm); cursor: pointer; transition: all .15s;
}
.msg-action-btn:hover { border-color: var(--accent); color: var(--accent2); }

/* Generated Image */
.msg-image { border-radius: var(--radius); overflow: hidden; max-width: 500px; margin-top: .8rem; }
.msg-image img { width: 100%; border-radius: var(--radius); }

/* ─── Image Panel ─────────────────────────────────────────── */
.image-panel { padding: .6rem 1.25rem; background: var(--bg2); border-top: 1px solid var(--border); flex-shrink: 0; }
.image-options { display: flex; gap: .6rem; }
.img-select { flex: 1; font-size: 12px; padding: .35rem .6rem; }

/* ─── Input Area ─────────────────────────────────────────── */
.input-area {
  padding: 1rem 1.25rem .8rem;
  background: var(--bg); border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.input-wrap {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: .75rem 1rem;
  display: flex; align-items: flex-end; gap: .8rem;
  transition: border-color .2s;
}
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input-wrap textarea {
  flex: 1; background: none; border: none; outline: none;
  resize: none; font-size: 14.5px; color: var(--text); min-height: 24px; max-height: 200px;
  font-family: var(--font-body); line-height: 1.5; overflow-y: auto;
}
.input-wrap textarea::placeholder { color: var(--text3); }
.input-actions { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.char-count { font-size: 11px; color: var(--text3); }
.btn-send {
  background: var(--accent); border: none; color: var(--white);
  width: 36px; height: 36px; border-radius: 9px;
  display: grid; place-items: center; cursor: pointer;
  transition: all .2s; flex-shrink: 0;
}
.btn-send:hover:not(:disabled) { background: var(--accent2); transform: scale(1.05); }
.btn-send:disabled { background: var(--surface2); color: var(--text3); cursor: not-allowed; transform: none; }
.input-disclaimer { font-size: 11px; color: var(--text3); text-align: center; margin-top: .5rem; }

/* ─── Streaming cursor ───────────────────────────────────── */
.streaming-cursor {
  display: inline-block; width: 8px; height: 14px;
  background: var(--accent); border-radius: 2px; margin-left: 2px;
  animation: pulse .7s ease-in-out infinite;
  vertical-align: text-bottom;
}

/* ─── Chat footer bar ─────────────────────────────────────── */
.chat-footer-bar {
  background: var(--bg2); border-top: 1px solid var(--border);
  padding: .5rem 1.5rem; flex-shrink: 0;
}
.chat-footer-inner {
  display: flex; flex-wrap: wrap; gap: .8rem 1.2rem; justify-content: center;
}
.chat-footer-inner a { font-size: 11px; color: var(--text3); }
.chat-footer-inner a:hover { color: var(--accent2); }

/* ─── Sidebar overlay (mobile) ────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .3s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .chat-body { position: relative; }
}
