/* ===================================
   ASISTENTEÍA — MAIN CSS
   Mente Activa © 2026
=================================== */

:root {
  --bg: #0a0b0f;
  --bg2: #111318;
  --bg3: #181b22;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --text: #e8eaf0;
  --text2: #8a8f9e;
  --text3: #555a6a;
  --accent: #7c6af7;
  --accent2: #5b4fd4;
  --accent-glow: rgba(124, 106, 247, 0.25);
  --cyan: #00d4b8;
  --green: #3ecf8e;
  --orange: #f59e0b;
  --red: #ef4444;
  --sidebar-w: 240px;
  --header-h: 60px;
  --radius: 12px;
  --radius-sm: 8px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---- LOGIN PAGE ---- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
}

.orb-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #7c6af7 0%, transparent 70%);
  top: -100px; right: -100px;
  animation: float1 8s ease-in-out infinite;
}

.orb-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #00d4b8 0%, transparent 70%);
  bottom: -80px; left: -80px;
  animation: float2 10s ease-in-out infinite;
}

@keyframes float1 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-30px,30px)} }
@keyframes float2 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(20px,-20px)} }

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 40px 40px;
}

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  animation: fadeUp 0.6s ease both;
}

@keyframes fadeUp {
  from { opacity:0; transform:translateY(24px); }
  to   { opacity:1; transform:translateY(0); }
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 42px; height: 42px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-icon.small {
  width: 34px; height: 34px;
  border-radius: 9px;
}

.brand-name {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: var(--text);
  letter-spacing: -0.3px;
}

.login-card {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 36px;
  backdrop-filter: blur(20px);
  box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04) inset;
}

.login-card h1 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 26px;
  color: var(--text);
  margin-bottom: 6px;
}

.login-sub {
  color: var(--text2);
  margin-bottom: 28px;
  font-size: 14px;
}

.login-footer {
  color: var(--text3);
  font-size: 12px;
}

/* ---- FORMS ---- */

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field textarea { resize: vertical; min-height: 100px; }
.field select { cursor: pointer; }

/* ---- BUTTONS ---- */

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--accent2);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:active { transform: scale(0.98); }

.btn-primary.full-width { width: 100%; justify-content: center; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-secondary:hover { background: var(--bg2); border-color: var(--accent); }
.btn-secondary.small { padding: 6px 12px; font-size: 12px; }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  padding: 0;
  transition: opacity 0.2s;
}
.btn-link:hover { opacity: 0.7; }

.error-msg {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: #f87171;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 12px;
}

.success-msg {
  background: rgba(62,207,142,0.12);
  border: 1px solid rgba(62,207,142,0.3);
  color: var(--green);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 12px;
}

/* ---- PANEL LAYOUT ---- */

.panel-page {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 400;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  width: 100%;
}

.nav-item:hover {
  background: var(--bg3);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 500;
}

.sidebar-footer {
  padding: 16px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.user-avatar {
  width: 32px; height: 32px;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  font-family: 'Syne', sans-serif;
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-logout {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text2);
  border-radius: 8px;
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* MAIN CONTENT */

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-header {
  height: var(--header-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 4px;
}

.page-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.cliente-badge {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 12px;
  color: var(--text2);
}

/* SECTIONS */

.section {
  display: none;
  padding: 28px 24px;
  flex: 1;
  animation: fadeIn 0.25s ease both;
}

.section.active { display: block; }

@keyframes fadeIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* STATS */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.2s;
}

.stat-card:hover { border-color: var(--border2); }

.stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.cyan { background: rgba(0,212,184,0.12); color: var(--cyan); }
.stat-icon.green { background: rgba(62,207,142,0.12); color: var(--green); }
.stat-icon.orange { background: rgba(245,158,11,0.12); color: var(--orange); }

.stat-info { display: flex; flex-direction: column; }
.stat-label { font-size: 12px; color: var(--text2); margin-bottom: 2px; }
.stat-value { font-family: 'Syne', sans-serif; font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.1; }

/* WIDGETS */

.dashboard-widgets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.widget {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.widget-header h3 {
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* TOOLBAR */

.section-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.search-input {
  flex: 1;
  max-width: 320px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus { border-color: var(--accent); }

/* CARDS GRID */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.articulo-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
}

.articulo-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.articulo-card .art-titulo {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--text);
}

.articulo-card .art-categoria {
  display: inline-block;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 8px;
  font-weight: 500;
}

.articulo-card .art-preview {
  font-size: 13px;
  color: var(--text2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.articulo-card .art-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: flex-end;
}

.btn-icon {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  cursor: pointer;
  color: var(--text2);
  font-size: 12px;
  transition: all 0.2s;
  font-family: 'DM Sans', sans-serif;
}

.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon.danger:hover { border-color: var(--red); color: var(--red); }

/* CONV TABLE */

.conv-table-wrapper { overflow-x: auto; }

.conv-table {
  width: 100%;
  border-collapse: collapse;
}

.conv-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.conv-table td {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.conv-table tr:hover td { background: var(--bg2); cursor: pointer; }

.session-code {
  font-family: monospace;
  font-size: 12px;
  background: var(--bg3);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--cyan);
}

/* MODAL */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease both;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 18px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 40px 100px rgba(0,0,0,0.6);
  animation: scaleIn 0.25s ease both;
}

.modal.modal-wide { max-width: 700px; }

@keyframes scaleIn { from{opacity:0;transform:scale(0.95)} to{opacity:1;transform:scale(1)} }

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

.modal-header h3 {
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--red); }

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* CHAT */

.chat-wrapper {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h) - 56px);
  min-height: 400px;
  overflow: hidden;
}

.chat-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text2);
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-msg {
  display: flex;
  gap: 10px;
  max-width: 80%;
}

.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.assistant { align-self: flex-start; }

.msg-bubble {
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
}

.chat-msg.user .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant .msg-bubble {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-input-area {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
}

.chat-input-area input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input-area input:focus { border-color: var(--accent); }

.btn-send {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 42px; height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.btn-send:hover { background: var(--accent2); }
.btn-send:active { transform: scale(0.95); }

/* CHAT HISTORY en modal */
.chat-history {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-history .chat-msg {
  max-width: 90%;
}

/* TYPING INDICATOR */
.typing-dot {
  display: inline-block;
  width: 7px; height: 7px;
  background: var(--text2);
  border-radius: 50%;
  animation: blink 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100%{opacity:0.2} 40%{opacity:1} }

/* CONFIGURACION */

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.config-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.config-card h3 {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

/* CONV LIST (dashboard widget) */
.conv-list, .articulos-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.conv-list-item {
  padding: 10px 12px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.conv-list-item .ci-session { color: var(--cyan); font-family: monospace; font-size: 11px; }
.conv-list-item .ci-date { font-size: 11px; color: var(--text3); }

/* EMPTY STATE */

.empty-state {
  color: var(--text3);
  font-size: 13px;
  text-align: center;
  padding: 24px;
  width: 100%;
}

/* LOADING */
.loading-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* RESPONSIVE */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-widgets { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0,0,0,0.6);
  }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; }
  .stats-grid { grid-template-columns: 1fr; }
}
/* Token usage bar */
.token-usage-bar {
  background: var(--card-bg, #1e1e2e);
  border: 1px solid var(--border, #2a2a3e);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
}
.token-usage-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted, #888);
  margin-bottom: 10px;
}
.token-bar-track {
  background: var(--border, #2a2a3e);
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
}
.token-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #7c3aed, #a855f7);
  transition: width 0.6s ease;
}
.token-bar-fill.warning { background: linear-gradient(90deg, #d97706, #f59e0b); }
.token-bar-fill.danger  { background: linear-gradient(90deg, #dc2626, #ef4444); }
.token-usage-footer {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted, #888);
  margin-top: 8px;
}
.stat-icon.purple { background: rgba(124,58,237,0.15); color: #a855f7; }
/* Token usage bar */
.token-usage-bar {
  background: var(--card-bg, #1e1e2e);
  border: 1px solid var(--border, #2a2a3e);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
}
.token-usage-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted, #888);
  margin-bottom: 10px;
}
.token-bar-track {
  background: var(--border, #2a2a3e);
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
}
.token-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #7c3aed, #a855f7);
  transition: width 0.6s ease;
}
.token-bar-fill.warning { background: linear-gradient(90deg, #d97706, #f59e0b); }
.token-bar-fill.danger  { background: linear-gradient(90deg, #dc2626, #ef4444); }
.token-usage-footer {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted, #888);
  margin-top: 8px;
}
.stat-icon.purple { background: rgba(124,58,237,0.15); color: #a855f7; }
