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

:root {
  --bg-dark:       #0d0f14;
  --bg-card:       #13161e;
  --bg-sidebar:    #0f1117;
  --bg-input:      #1a1d27;
  --bg-hover:      #1e2130;
  --border:        rgba(255,255,255,0.06);
  --accent:        #6c63ff;
  --accent-light:  #8b85ff;
  --accent-glow:   rgba(108,99,255,0.25);
  --text-primary:  #e8eaf0;
  --text-secondary:#8a8fa8;
  --text-muted:    #555a72;
  --bot-bubble:    #1a1d2e;
  --user-bubble:   #2d2b52;
  --success:       #4ade80;
  --warning:       #fbbf24;
  --danger:        #f87171;
  --radius-sm:     8px;
  --radius-md:     14px;
  --radius-lg:     20px;
  --shadow-glow:   0 0 30px rgba(108,99,255,0.12);
  font-family: 'Inter', sans-serif;
}

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg-dark);
  color: var(--text-primary);
  display: flex;
  align-items: stretch;
}

/* ─────────────────────────────────────────────
   LAYOUT
───────────────────────────────────────────── */
.app-container {
  display: flex;
  width: 100%;
  height: 100vh;
}

/* ─────────────────────────────────────────────
   SIDEBAR
───────────────────────────────────────────── */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 24px;
}

.sidebar-header { padding-bottom: 16px; border-bottom: 1px solid var(--border); }

.logo { display: flex; align-items: center; gap: 12px; }

.logo-icon {
  font-size: 28px;
  width: 46px; height: 46px;
  background: linear-gradient(135deg, var(--accent), #9b59b6);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.logo-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.logo-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sidebar-section { display: flex; flex-direction: column; gap: 6px; }

.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.quick-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.quick-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text-primary);
  transform: translateX(3px);
}

/* Info card */
.sidebar-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.info-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: rgba(108,99,255,0.08);
  border: 1px solid rgba(108,99,255,0.15);
  border-radius: var(--radius-sm);
}

.info-icon { font-size: 20px; flex-shrink: 0; line-height: 1; margin-top: 2px; }
.info-title { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.info-desc  { font-size: 11px; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }

.powered-by {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

.sidebar-footer { margin-top: auto; }

.model-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
}

.model-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse 2s infinite;
}

/* ─────────────────────────────────────────────
   CHAT AREA
───────────────────────────────────────────── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
  overflow: hidden;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.header-info { display: flex; align-items: center; gap: 12px; }

.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #9b59b6);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  box-shadow: 0 0 16px var(--accent-glow);
}

.header-name   { font-size: 15px; font-weight: 600; }
.header-status { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; margin-top: 2px; }

.status-dot {
  width: 7px; height: 7px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--success);
}

.btn-clear {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-clear:hover { border-color: var(--danger); color: var(--danger); }

/* ─────────────────────────────────────────────
   MESSAGES
───────────────────────────────────────────── */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

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

/* Mensaje base */
.message {
  display: flex;
  gap: 12px;
  max-width: 800px;
  animation: fadeSlideIn 0.3s ease;
}

.message-bot  { align-self: flex-start; }
.message-user { align-self: flex-end; flex-direction: row-reverse; }

.message-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.message-user .message-avatar {
  background: linear-gradient(135deg, var(--accent), #9b59b6);
  border: none;
}

.message-content {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.65;
  max-width: calc(100% - 50px);
  position: relative;
}

.message-bot .message-content {
  background: var(--bot-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message-user .message-content {
  background: var(--user-bubble);
  border: 1px solid rgba(108,99,255,0.3);
  border-bottom-right-radius: 4px;
  color: #c8c4ff;
}

.message-time {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Markdown rendering inside messages */
.message-text strong { color: #c8c4ff; }
.message-user .message-text strong { color: #e0deff; }
.message-text em { font-style: italic; opacity: 0.85; }
.message-text code {
  background: rgba(108,99,255,0.15);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}
.message-text ul {
  margin: 8px 0 4px 0;
  padding-left: 16px;
  list-style: none;
}
.message-text ul li {
  position: relative;
  padding-left: 14px;
  margin-bottom: 4px;
  line-height: 1.5;
}
.message-text ul li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent-light);
  font-size: 11px;
}

/* Avatar emoji */
.avatar-emoji { font-size: 20px; }

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.message-bot .message-content:has(.typing-indicator) {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.typing-dot {
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

.typing-label {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  animation: fadeOscillate 2s ease-in-out infinite;
}

@keyframes fadeOscillate {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

/* ─────────────────────────────────────────────
   INPUT AREA
───────────────────────────────────────────── */
.input-area {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 10px 10px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
}

.chat-input::placeholder { color: var(--text-muted); }

.btn-send {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  border: none;
  cursor: pointer;
  color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-send:hover  { background: var(--accent-light); transform: scale(1.05); }
.btn-send:active { transform: scale(0.96); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-send.loading { animation: spin 0.8s linear infinite; }

.btn-clear.confirming {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(248,113,113,0.08);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.input-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  padding-left: 2px;
}

kbd {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: 'Inter', sans-serif;
}

/* ─────────────────────────────────────────────
   ANIMATIONS
───────────────────────────────────────────── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

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

/* ─────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────── */
@media (max-width: 640px) {
  .sidebar { display: none; }
  .messages-container { padding: 16px; }
  .input-area { padding: 12px 16px 16px; }
}
