/* ============================================================
   AgentMark — Dark Professional Theme
   ============================================================ */

:root {
  --bg-base:       #1e1e1e;
  --bg-surface:    #252526;
  --bg-raised:     #2d2d30;
  --bg-input:      #3c3c3c;
  --border:        #404040;
  --accent:        #0e639c;
  --accent-hover:  #1177bb;
  --accent-dim:    #1e3a4d;
  --text-primary:  #ececec;
  --text-secondary:#b0b0b0;
  --text-muted:    #909090;
  --user-bubble:   #1084d7;
  --user-text:     #ffffff;
  --agent-bubble:  #2d2d30;
  --sidebar-width: 260px;
  --radius:        12px;
  --radius-sm:     8px;
  --transition:    0.2s ease;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-base) !important;
  color: var(--text-primary) !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Override Bootstrap defaults */
body, body * {
  background-color: transparent;
  color: var(--text-primary);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* Bootstrap overrides */
.btn { color: var(--text-primary); }
input, textarea, select { background: var(--bg-input) !important; color: var(--text-primary) !important; border-color: var(--border) !important; }
input::placeholder, textarea::placeholder { color: var(--text-muted) !important; }

/* ── Layout ─────────────────────────────────────────────────── */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 28px 20px 20px;
}

/* Profile block */
.profile-block {
  text-align: center;
  margin-bottom: 28px;
}

.profile-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 3px solid var(--border);
  object-fit: cover;
  margin-bottom: 12px;
}

.profile-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.profile-tagline {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Nav links */
.profile-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}

.profile-link:hover {
  background: var(--bg-raised);
  color: var(--text-primary);
  text-decoration: none;
}

.profile-link i {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  color: var(--accent);
}

.profile-link:hover i { color: var(--accent-hover); }

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
}

.powered-by {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.powered-by a {
  color: var(--text-muted);
  text-decoration: none;
}

.powered-by a:hover { color: var(--accent); text-decoration: none; }

/* ── Chat Area ───────────────────────────────────────────────── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

/* Chat header */
.chat-header {
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.chat-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.chat-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 620px;
}

/* Suggested questions */
.suggested-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.suggestion-btn {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  padding: 6px 14px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition);
  white-space: nowrap;
}

.suggestion-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Message wrappers */
.message-wrapper {
  display: flex;
  max-width: 780px;
}

.user-wrapper {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.agent-wrapper {
  align-self: flex-start;
}

/* Message bubbles */
.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  line-height: 1.65;
  word-break: break-word;
  font-size: 0.93rem;
}

.user-bubble {
  background: var(--user-bubble);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
  max-width: 580px;
}

.agent-bubble {
  background: var(--agent-bubble);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  max-width: 700px;
}

/* Markdown inside agent bubble */
.agent-bubble h1, .agent-bubble h2, .agent-bubble h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 12px 0 6px;
  color: var(--text-primary);
}
.agent-bubble h1 { font-size: 1.1rem; }
.agent-bubble p  { margin: 0 0 8px; }
.agent-bubble p:last-child { margin-bottom: 0; }
.agent-bubble ul, .agent-bubble ol {
  margin: 4px 0 8px 20px;
}
.agent-bubble li { margin-bottom: 4px; }
.agent-bubble code {
  background: var(--bg-input);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: "SFMono-Regular", Consolas, monospace;
}
.agent-bubble pre {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
}
.agent-bubble pre code { background: none; padding: 0; }
.agent-bubble a { color: var(--accent); }
.agent-bubble strong { color: var(--text-primary); font-weight: 600; }

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  display: inline-block;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* Streaming cursor */
.cursor-blink {
  display: inline-block;
  color: var(--accent);
  animation: blink 0.8s step-end infinite;
  font-weight: 300;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Chat input ──────────────────────────────────────────────── */
.chat-input-area {
  padding: 16px 32px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px 6px 16px;
  transition: border-color var(--transition);
}

.chat-form:focus-within { border-color: var(--accent); }

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.93rem;
  line-height: 1.5;
  resize: none;
  max-height: 160px;
  overflow-y: auto;
  padding: 4px 0;
}

.chat-input::placeholder { color: var(--text-muted); }
.chat-input::-webkit-scrollbar { width: 4px; }
.chat-input::-webkit-scrollbar-thumb { background: var(--border); }

.send-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform var(--transition);
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.disclaimer {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
}

.disclaimer a { color: var(--text-muted); }
.disclaimer a:hover { color: var(--accent); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 680px) {
  :root { --sidebar-width: 220px; }

  .chat-header    { padding: 18px 18px 14px; }
  .chat-messages  { padding: 14px 18px; }
  .suggested-questions { padding: 12px 18px; }
  .chat-input-area { padding: 12px 18px 10px; }
  .chat-title     { font-size: 1.2rem; }
}

@media (max-width: 520px) {
  .app-container { flex-direction: column; }

  .sidebar {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .sidebar-inner { padding: 12px 16px; }

  .profile-block { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 8px 12px; align-items: start; }
  .profile-avatar { grid-row: 1 / 3; width: 48px; height: 48px; margin: 0; }
  .profile-name { grid-column: 2; grid-row: 1; font-size: 1rem; margin: 0; text-align: left; }
  .profile-tagline { grid-column: 2; grid-row: 2; font-size: 0.7rem; margin: 0; text-align: left; }

  .profile-links { flex-direction: row; flex-wrap: nowrap; gap: 4px; overflow-x: auto; overflow-y: hidden; }
  .profile-links::-webkit-scrollbar { height: 4px; }
  .profile-links::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

  .profile-link { padding: 6px 8px; font-size: 0.75rem; flex-shrink: 0; white-space: nowrap; }

  .sidebar-footer { display: none; }

  .chat-area { flex: 1; display: flex; flex-direction: column; min-height: 0; }

  .chat-header { padding: 12px 14px 10px; }
  .chat-title { font-size: 1rem; margin-bottom: 4px; }
  .chat-subtitle { font-size: 0.8rem; }

  .suggested-questions { padding: 8px 14px; gap: 6px; overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap; }
  .suggested-questions::-webkit-scrollbar { height: 4px; }
  .suggested-questions::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
  .suggestion-btn { padding: 5px 10px; font-size: 0.75rem; flex-shrink: 0; white-space: nowrap; }

  .chat-messages { padding: 12px 14px; flex: 1; }

  .chat-input-area { padding: 10px 14px 8px; flex-shrink: 0; }
  .disclaimer { font-size: 0.65rem; margin-top: 4px; }

  .message-bubble { padding: 10px 14px; font-size: 0.88rem; }
  .user-bubble { max-width: 100%; }
  .agent-bubble { max-width: 100%; }
}
