/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:          #0d0d1a;
  --bg-card:     #161625;
  --bg-sidebar:  #111120;
  --border:      #2a2a4a;
  --accent:      #6c63ff;
  --accent-h:    #5a52e0;
  --text:        #e4e4f0;
  --text-muted:  #8888aa;
  --green:       #22c55e;
  --red:         #ef4444;
  --radius:      12px;
  --radius-s:    8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
}

/* ── LOGIN ──────────────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrap {
  width: 100%;
  max-width: 400px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.login-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 6px;
}
.logo-icon { font-size: 2rem; }
.logo-text  { font-size: 1.55rem; font-weight: 700; color: var(--accent); }

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 32px;
}

.login-footer { font-size: 0.78rem; color: var(--text-muted); }

/* ── FIELDS ─────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.field input:focus      { border-color: var(--accent); }
.field input::placeholder { color: var(--text-muted); }

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-s);
  padding: 12px;
  font-size: 0.97rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  margin-top: 6px;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── MESSAGES ───────────────────────────────────────────────────────────── */
.msg {
  border-radius: var(--radius-s);
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-bottom: 12px;
}
.error-msg   { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.3);  color: var(--red);   }
.success-msg { background: rgba(34,197,94,.1);  border: 1px solid rgba(34,197,94,.3);  color: var(--green); }
.hidden { display: none !important; }

/* ── DASHBOARD ──────────────────────────────────────────────────────────── */
.dashboard-page { display: flex; height: 100vh; overflow: hidden; }

/* SIDEBAR */
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-logo .logo-text { font-size: 1.2rem; }

.sidebar-nav { flex: 1; padding: 0 12px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-s);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
  margin-bottom: 4px;
}
.nav-item:hover  { background: rgba(108,99,255,.1);  color: var(--text); }
.nav-item.active { background: rgba(108,99,255,.15); color: var(--accent); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 0;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.88rem; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.84rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.74rem; color: var(--text-muted); }

.btn-logout {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1.2rem; padding: 4px;
  border-radius: 4px; transition: color 0.2s;
}
.btn-logout:hover { color: var(--red); }

/* MAIN */
.main-content { flex: 1; overflow-y: auto; padding: 32px; }

.section        { display: none; }
.section.active { display: block; }

.section-header {
  display: flex; align-items: center;
  gap: 16px; margin-bottom: 28px;
}
.section-header h1 { font-size: 1.55rem; font-weight: 700; }

.badge {
  background: rgba(108,99,255,.15);
  color: var(--accent);
  border: 1px solid rgba(108,99,255,.3);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.78rem; font-weight: 600;
}

/* WORKSPACE GRID */
.workspace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.workspace-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  user-select: none;
}
.workspace-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.ws-icon   { font-size: 2rem; margin-bottom: 12px; }
.ws-name   { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.ws-desc   { font-size: 0.82rem; color: var(--text-muted); line-height: 1.55; }

.ws-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.ws-agents { font-size: 0.78rem; color: var(--text-muted); }
.ws-dot    { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

.muted-msg { color: var(--text-muted); font-size: 0.9rem; padding: 8px 0; }

/* PROFILE */
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 480px;
}
.profile-row {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.profile-row label { width: 120px; font-size: 0.84rem; color: var(--text-muted); flex-shrink: 0; }
.profile-card h3   { margin: 22px 0 16px; font-size: 1rem; }
.divider           { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Responsive */
@media (max-width: 640px) {
  .sidebar        { display: none; }
  .main-content   { padding: 16px; }
  .workspace-grid { grid-template-columns: 1fr; }
}

/* ── CHAT / SESIONES ─────────────────────────────────────────────────────── */
.btn-outline {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--accent); color: var(--accent);
  border-radius: var(--radius-s); padding: 8px 16px;
  font-size: 0.85rem; font-weight: 600; text-decoration: none;
  transition: background 0.2s;
}
.btn-outline:hover { background: rgba(108,99,255,.12); }

.sessions-list { display: flex; flex-direction: column; gap: 10px; }

.session-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 14px 18px;
  display: flex; align-items: flex-start; gap: 14px;
  cursor: pointer; transition: border-color 0.15s;
}
.session-item:hover { border-color: var(--accent); }

.session-icon { font-size: 1.5rem; flex-shrink: 0; }
.session-meta { flex: 1; min-width: 0; }
.session-agent { font-size: 0.88rem; font-weight: 600; margin-bottom: 3px; }
.session-date  { font-size: 0.77rem; color: var(--text-muted); margin-bottom: 4px; }
.session-preview { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── ADMIN TABS ──────────────────────────────────────────────────────────── */
.admin-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  background: none; border: none; color: var(--text-muted);
  padding: 10px 18px; font-size: 0.88rem; font-weight: 600;
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all 0.15s;
  border-radius: var(--radius-s) var(--radius-s) 0 0;
}
.tab-btn:hover  { color: var(--text); background: rgba(255,255,255,.04); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.admintab-content { }

/* ── ADMIN CARD ──────────────────────────────────────────────────────────── */
.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.admin-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 10px;
}
.admin-card-header h3 { font-size: 1rem; font-weight: 700; }

/* ── BUTTONS SM ──────────────────────────────────────────────────────────── */
.btn-sm {
  padding: 7px 14px; border-radius: var(--radius-s);
  font-size: 0.82rem; font-weight: 600; cursor: pointer;
  border: none; transition: background 0.15s, opacity 0.15s;
}
.btn-accent  { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-h); }
.btn-ghost   { background: rgba(255,255,255,.07); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-danger  { background: rgba(239,68,68,.15); color: var(--red); border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-sm:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── INLINE FORM ─────────────────────────────────────────────────────────── */
.inline-form {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 20px;
  margin-bottom: 20px;
}
.inline-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.inline-form-actions { display: flex; gap: 8px; margin-top: 12px; }
.inline-form textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.88rem;
  resize: vertical;
  outline: none;
}
.inline-form textarea:focus { border-color: var(--accent); }

/* ── WORKSPACE CHECKBOXES ────────────────────────────────────────────────── */
.ws-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 12px;
  max-height: 180px;
  overflow-y: auto;
}
.ws-checkbox-item {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.82rem; cursor: pointer; padding: 3px 0;
}
.ws-checkbox-item input { cursor: pointer; }

/* ── TABLE ───────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th {
  text-align: left; padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted); font-weight: 600;
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.05);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,.03); }

.badge-role {
  display: inline-block; border-radius: 20px; padding: 3px 10px;
  font-size: 0.74rem; font-weight: 600;
}
.badge-admin { background: rgba(108,99,255,.15); color: var(--accent); }
.badge-user  { background: rgba(34,197,94,.12);  color: var(--green); }

.badge-ok   { background: rgba(34,197,94,.12);  color: var(--green); font-size: 0.74rem; padding: 2px 8px; border-radius: 20px; }
.badge-fail { background: rgba(239,68,68,.12);  color: var(--red);   font-size: 0.74rem; padding: 2px 8px; border-radius: 20px; }

.toggle-on  { color: var(--green); font-size: 0.8rem; font-weight: 600; }
.toggle-off { color: var(--text-muted); font-size: 0.8rem; }

/* ── PAGINATION ──────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination button {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 6px;
  padding: 5px 11px; font-size: 0.8rem; cursor: pointer;
}
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination button:hover:not(.active) { border-color: var(--accent); color: var(--accent); }

/* ── LOGS FILTER ─────────────────────────────────────────────────────────── */
.logs-filter { display: flex; gap: 8px; }
.logs-filter input {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-s);
  padding: 6px 12px; font-size: 0.85rem; outline: none;
}
.logs-filter input:focus { border-color: var(--accent); }


/* ── Chat: workspace cards ──────────────────────────────────────────────── */
.chat-workspace-section { margin-bottom: 28px; }
.chat-section-title     { font-size: 1rem; font-weight: 600; color: var(--text-muted); margin-bottom: 12px; }
.chat-ws-grid           { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.chat-ws-card           { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.chat-ws-header         { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.chat-ws-name           { font-weight: 600; font-size: 0.92rem; }
.chat-ws-count          { font-size: 0.75rem; color: var(--text-muted); background: rgba(255,255,255,0.06); padding: 2px 8px; border-radius: 20px; }
.chat-agent-list        { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-agent-chip        { display: inline-block; font-size: 0.75rem; padding: 3px 10px;
                          background: rgba(99,102,241,0.12); border: 1px solid rgba(99,102,241,0.3);
                          border-radius: 20px; color: var(--accent); text-decoration: none;
                          transition: background .15s; white-space: nowrap; }
.chat-agent-chip:hover  { background: rgba(99,102,241,0.25); }
.chat-agent-more        { font-size: 0.73rem; color: var(--text-muted); align-self: center; padding: 0 4px; }

/* ── Cron: form mejorado ────────────────────────────────────────────────── */
.cron-form-row          { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; margin-bottom: 16px; }
@media (max-width: 700px) { .cron-form-row { grid-template-columns: 1fr; } }
.cron-agent-selector    { margin-bottom: 16px; }
.cron-agent-selector label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.cron-agent-row         { display: flex; gap: 10px; }
.cron-ws-select,
.cron-agent-select      { flex: 1; background: var(--surface); border: 1px solid var(--border);
                          color: var(--text); border-radius: var(--radius-s); padding: 8px 10px;
                          font-size: 0.87rem; outline: none; }
.cron-ws-select:focus,
.cron-agent-select:focus{ border-color: var(--accent); }
.cron-agent-select:disabled { opacity: 0.45; cursor: not-allowed; }
.cron-agent-hint        { font-size: 0.76rem; color: var(--text-muted); margin-top: 5px; }
@media (max-width: 600px) { .cron-agent-row { flex-direction: column; } }

/* ══════════════════════════════════════════════════════════════════════════
   Chat Panel — Estilos (panel lateral deslizable)
   ══════════════════════════════════════════════════════════════════════════ */

/* Botón chip de agente — ahora es <button> en lugar de <a> */
button.chat-agent-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  background: var(--bg-elevated, #2a2a3a);
  color: var(--text-secondary, #c0c0d0);
  border: 1px solid var(--border, #3a3a4a);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit;
}
button.chat-agent-chip:hover {
  background: var(--accent-bg, #3b4ef6);
  border-color: var(--accent, #5b6ef8);
  color: #fff;
}

/* ── Backdrop ─────────────────────────────────────────────────────────────── */
.chat-panel-backdrop {
  display: none; /* Backdrop desactivado — panel lateral no necesita overlay */
}

/* ── Panel contenedor ────────────────────────────────────────────────────── */
.chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 901;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
  width: 420px;
  max-width: 95vw;
}

.chat-panel.hidden {
  display: none;
}

/* backdrop desactivado */

.chat-panel-inner {
  pointer-events: all;
  width: 420px;
  max-width: 95vw;
  height: 100%;
  background: var(--bg-card, #1a1a2e);
  border-left: 1px solid var(--border, #3a3a4a);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border, #3a3a4a);
  flex-shrink: 0;
  background: var(--bg-elevated, #252538);
}

.chat-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-panel-icon {
  font-size: 1.5rem;
  line-height: 1;
}

#chatPanelName {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary, #eee);
  line-height: 1.2;
}

.chat-status {
  font-size: 0.72rem;
  margin-top: 2px;
}
.chat-status.connecting   { color: #f0a020; }
.chat-status.connected    { color: #4caf50; }
.chat-status.disconnected { color: #f44336; }

.chat-panel-close {
  background: transparent;
  border: none;
  color: var(--text-muted, #888);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.chat-panel-close:hover {
  background: rgba(255, 70, 70, 0.15);
  color: #f55;
}
#chatPanelMinimize:hover {
  background: rgba(100, 100, 255, 0.15);
  color: var(--accent, #7c7cff);
}

/* ── Panel minimizado ────────────────────────────────────────────────── */
.chat-panel.minimized .chat-panel-inner {
  display: none;
}
.chat-panel.minimized {
  pointer-events: none;
}

/* ── Tour primera vez ─────────────────────────────────────────────── */
.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  pointer-events: none;
  background: rgba(0,0,0,0.72);
  transition: opacity 0.3s;
}
.tour-overlay.hidden { display: none; }
.tour-overlay.active { pointer-events: all; }

/* Hueco brillante que resalta el elemento */
.tour-spotlight {
  position: absolute;
  border-radius: 12px;
  box-shadow:
    0 0 0 4px var(--accent, #7c7cff),
    0 0 0 9999px rgba(0,0,0,0.72);
  transition: all 0.35s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
  background: transparent;
}

/* Tooltip del tour */
.tour-tooltip {
  position: absolute;
  background: var(--bg-card, #1a1a2e);
  border: 1px solid var(--accent, #7c7cff);
  border-radius: 16px;
  padding: 24px 24px 18px;
  width: 320px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.6), 0 0 0 1px rgba(124,124,255,0.2);
  transition: all 0.35s cubic-bezier(.4,0,.2,1);
  pointer-events: all;
}
.tour-step-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent, #7c7cff);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.tour-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  line-height: 1;
}
.tour-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary, #eee);
  margin: 0 0 8px;
}
.tour-desc {
  font-size: 0.85rem;
  color: var(--text-muted, #aaa);
  line-height: 1.55;
  margin: 0 0 18px;
}
.tour-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tour-nav {
  display: flex;
  gap: 8px;
}
.tour-btn-skip {
  background: transparent;
  border: none;
  color: var(--text-muted, #888);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
}
.tour-btn-skip:hover { color: var(--text-primary, #eee); }
.tour-btn-prev,
.tour-btn-next {
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.tour-btn-prev {
  background: var(--bg-elevated, #252538);
  color: var(--text-primary, #eee);
}
.tour-btn-prev:hover { background: var(--border, #3a3a4a); }
.tour-btn-next {
  background: var(--accent, #7c7cff);
  color: #fff;
}
.tour-btn-next:hover { background: #6a6af0; transform: translateX(2px); }
.tour-btn-next.finish { background: #22c55e; }
.tour-btn-next.finish:hover { background: #16a34a; }
.tour-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
}
.tour-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border, #3a3a4a);
  transition: background 0.2s, transform 0.2s;
}
.tour-dot.active {
  background: var(--accent, #7c7cff);
  transform: scale(1.3);
}

/* Botón relanzar tour */
.tour-restart-btn {
  position: fixed;
  bottom: 72px;
  right: 24px;
  z-index: 900;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border, #3a3a4a);
  background: var(--bg-elevated, #1e1e2e);
  color: var(--text-muted, #888);
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, color 0.15s, transform 0.15s;
  line-height: 1;
}
.tour-restart-btn:hover {
  border-color: var(--accent, #7c7cff);
  color: var(--accent, #7c7cff);
  transform: scale(1.1);
}
/* ── fin Tour ────────────────────────────────────────────────────────── */

.restore-pill {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 950;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent, #7c7cff);
  color: #fff;
  padding: 10px 16px;
  border-radius: 24px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(124, 124, 255, 0.45);
  font-size: 0.88rem;
  font-weight: 600;
  transition: transform 0.15s, box-shadow 0.15s;
  user-select: none;
}
.restore-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(124, 124, 255, 0.6);
}
.restore-pill.hidden {
  display: none !important;
}
.restore-pill-icon {
  font-size: 1.1rem;
}

/* ── Agent Picker custom dropdown ───────────────────────────────────────── */
.agent-picker {
  position: relative;
  flex: 1;
  min-width: 0;
}
.agent-picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-elevated, #1e1e2e);
  border: 1px solid var(--border, #3a3a4a);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-primary, #eee);
  transition: border-color 0.15s;
  user-select: none;
  min-height: 38px;
}
.agent-picker-trigger:hover:not(.disabled) {
  border-color: var(--accent, #7c7cff);
}
.agent-picker-trigger.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.agent-picker-arrow {
  font-size: 0.75rem;
  color: var(--text-muted, #888);
  flex-shrink: 0;
}
.agent-picker-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 500;
  background: var(--bg-card, #1a1a2e);
  border: 1px solid var(--accent, #7c7cff);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 320px;
}
.agent-picker-dropdown.hidden { display: none; }
.agent-picker-search {
  padding: 10px 12px;
  background: var(--bg-elevated, #1e1e2e);
  border: none;
  border-bottom: 1px solid var(--border, #3a3a4a);
  color: var(--text-primary, #eee);
  font-size: 0.88rem;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.agent-picker-search::placeholder { color: var(--text-muted, #888); }
.agent-picker-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  overflow-y: auto;
  flex: 1;
}
.agent-picker-list li {
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.1s;
  border-radius: 0;
}
.agent-picker-list li:hover,
.agent-picker-list li.active {
  background: rgba(124,124,255,0.15);
}
.agent-picker-item-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary, #eee);
  text-transform: capitalize;
}
.agent-picker-item-desc {
  font-size: 0.76rem;
  color: var(--text-muted, #999);
  margin-top: 2px;
  line-height: 1.3;
}
/* ── fin Agent Picker ────────────────────────────────────────────────────── */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border, #3a3a4a) transparent;
}

.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted, #888);
  text-align: center;
  gap: 10px;
}

.chat-empty-icon {
  font-size: 2.5rem;
  opacity: 0.5;
}

/* Burbujas */
.chat-bubble {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--accent-bg, #3b4ef6);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.chat-bubble-assistant {
  align-self: flex-start;
  background: var(--bg-elevated, #252538);
  color: var(--text-primary, #eee);
  border: 1px solid var(--border, #3a3a4a);
  border-bottom-left-radius: 3px;
}

.chat-bubble-system {
  align-self: center;
  background: transparent;
  color: var(--text-muted, #888);
  font-size: 0.75rem;
  font-style: italic;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border, #3a3a4a);
}

/* ── Indicador de escritura ──────────────────────────────────────────────── */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 18px 6px 18px;
  flex-shrink: 0;
}

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

@keyframes typingPulse {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40%           { transform: scale(1.1); opacity: 1;   }
}

.typing-label {
  font-size: 0.72rem;
  color: var(--text-muted, #888);
  margin-left: 4px;
  font-style: italic;
}

/* ── Input row ───────────────────────────────────────────────────────────── */
.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border, #3a3a4a);
  background: var(--bg-elevated, #252538);
  flex-shrink: 0;
}

.chat-textarea {
  flex: 1;
  background: var(--bg-card, #1a1a2e);
  border: 1px solid var(--border, #3a3a4a);
  border-radius: 10px;
  color: var(--text-primary, #eee);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 9px 12px;
  resize: none;
  outline: none;
  line-height: 1.4;
  min-height: 40px;
  max-height: 120px;
  transition: border-color 0.15s;
}

.chat-textarea:focus {
  border-color: var(--accent, #5b6ef8);
}

.chat-textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent, #5b6ef8);
  color: #fff;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.chat-send-btn:hover:not(:disabled) {
  background: var(--accent-hover, #4a5de8);
  transform: scale(1.05);
}

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Botón adjuntar imagen ─────────────────────────────────────────────── */
.chat-attach-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg-card, #1a1a2e);
  border: 1px solid var(--border, #3a3a4a);
  color: var(--text-muted, #888);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s, transform 0.1s;
  line-height: 1;
}
.chat-attach-btn:hover:not(:disabled) {
  border-color: var(--accent, #5b6ef8);
  color: var(--accent, #5b6ef8);
  transform: scale(1.05);
}
.chat-attach-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Imagen en burbuja de chat ─────────────────────────────────────────── */
.chat-img-preview {
  max-width: 260px;
  max-height: 200px;
  border-radius: 10px;
  object-fit: contain;
  display: block;
  margin-top: 6px;
  border: 1px solid rgba(255,255,255,0.08);
}
.chat-img-caption {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  margin-top: 4px;
}

/* ── Indicador de carga de imagen ─────────────────────────────────────── */
.chat-img-uploading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted, #888);
  padding: 4px 0;
}
.chat-img-uploading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent, #5b6ef8);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .chat-panel-inner {
    width: 100vw;
    border-left: none;
  }
}

/* ── Quick Chat Button (sidebar) ─────────────────────────────────────────── */
.sidebar-chat-trigger {
  position: relative;
  padding: 0 12px 8px;
}
.quick-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-s);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.quick-chat-btn:hover { opacity: 0.82; }

.agent-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.55);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.agent-picker.hidden { display: none !important; }
.agent-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.agent-picker-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.agent-picker-close:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.agent-picker-search {
  margin: 8px 10px 4px;
  padding: 7px 10px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  flex-shrink: 0;
}
.agent-picker-search:focus { border-color: var(--accent); }
.agent-picker-list {
  overflow-y: auto;
  flex: 1;
  padding: 4px 8px 10px;
}
.ap-group-name {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  padding: 8px 6px 3px;
}
.ap-agent-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 8px;
  background: none;
  border: none;
  border-radius: var(--radius-s);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ap-agent-item:hover { background: rgba(108,99,255,0.15); color: var(--accent); }
