/* ==========================================================================
   NOVA IA 2.1 — Asistente Multi-Sucursal (Misceláneas ELY)
   ========================================================================== */

.nova-ai-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 19500;
  height: 52px;
  padding: 0 18px 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(139, 92, 246, 0.5);
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 55%, #5b21b6 100%);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.2px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.nova-ai-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 38px rgba(91, 33, 182, 0.45), 0 0 0 1px rgba(167, 139, 250, 0.45) inset;
}

.nova-ai-fab-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

.nova-ai-panel {
  position: fixed;
  right: 22px;
  bottom: 86px;
  z-index: 19600;
  width: min(460px, calc(100vw - 24px));
  height: min(670px, calc(100vh - 108px));
  background: #0a0f1e;
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 22px;
  box-shadow: 0 28px 70px rgba(2, 6, 23, 0.72), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  transition: width 0.22s ease, height 0.22s ease;
}

.nova-ai-panel.hidden {
  display: none !important;
}

.nova-ai-panel.expanded {
  width: min(860px, calc(100vw - 32px));
  height: min(780px, calc(100vh - 102px));
}

/* Header */
.nova-ai-header {
  padding: 14px 16px 12px;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 75%, #2e1065 100%);
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nova-ai-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.nova-ai-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.4);
}

.nova-ai-title {
  font-size: 14px;
  font-weight: 800;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 7px;
}

.nova-ai-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.nova-ai-subtitle {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 1px;
}

.nova-ai-header-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nova-ai-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  outline: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nova-ai-icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(167, 139, 250, 0.45);
  color: #ffffff;
}

.nova-ai-icon-btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.6);
}

/* Scope pills */
.nova-ai-scope-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 1px;
  scrollbar-width: none;
}

.nova-ai-scope-bar::-webkit-scrollbar {
  display: none;
}

.nova-ai-scope-pill {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.55);
  color: #cbd5e1;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}

.nova-ai-scope-pill:hover {
  border-color: rgba(167, 139, 250, 0.55);
  color: #fff;
}

.nova-ai-scope-pill.active {
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 3px 12px rgba(124, 58, 237, 0.4);
}

/* Messages area */
.nova-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: radial-gradient(circle at top right, rgba(76, 29, 149, 0.12), transparent 55%), #0a0f1e;
}

.nova-ai-messages::-webkit-scrollbar {
  width: 6px;
}

.nova-ai-messages::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.22);
  border-radius: 999px;
}

/* Welcome Dashboard */
.nova-ai-welcome {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nova-ai-welcome-hero {
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.85), rgba(30, 27, 75, 0.7));
  border: 1px solid rgba(139, 92, 246, 0.24);
}

.nova-ai-welcome-hero h3 {
  margin: 0 0 4px 0;
  font-size: 14.5px;
  font-weight: 800;
  color: #f8fafc;
}

.nova-ai-welcome-hero p {
  margin: 0;
  font-size: 12.2px;
  color: #94a3b8;
  line-height: 1.45;
}

.nova-ai-kpi-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.nova-ai-kpi-card {
  padding: 10px 11px;
  border-radius: 13px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.14);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nova-ai-kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #94a3b8;
}

.nova-ai-kpi-val {
  font-size: 14px;
  font-weight: 800;
  color: #f8fafc;
}

.nova-ai-kpi-val.green { color: #4ade80; }
.nova-ai-kpi-val.amber { color: #fbbf24; }
.nova-ai-kpi-val.blue { color: #60a5fa; }

.nova-ai-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.nova-ai-action-card {
  text-align: left;
  padding: 11px 12px;
  border-radius: 14px;
  background: rgba(19, 28, 49, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.15);
  color: #e2e8f0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  outline: none;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.nova-ai-action-card:hover {
  transform: translateY(-1px);
  border-color: rgba(139, 92, 246, 0.55);
  background: rgba(30, 41, 75, 0.92);
}

.nova-ai-action-title {
  font-size: 12.2px;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nova-ai-action-desc {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.3;
}

/* Message Bubbles */
.nova-ai-msg-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: novaFadeUp 0.18s ease;
}

.nova-ai-msg-wrap.user {
  align-items: flex-end;
}

.nova-ai-msg-wrap.assistant {
  align-items: flex-start;
}

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

.nova-ai-msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  color: #64748b;
  padding: 0 4px;
}

.nova-ai-copy-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 1px 6px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.nova-ai-copy-btn:hover {
  background: rgba(148, 163, 184, 0.16);
  color: #f8fafc;
}

.nova-ai-msg {
  max-width: 92%;
  padding: 11px 14px;
  border-radius: 15px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}

.nova-ai-msg.user {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}

.nova-ai-msg.assistant {
  background: #131c31;
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-bottom-left-radius: 4px;
  width: 100%;
  max-width: 100%;
}

.nova-ai-msg h3 {
  font-size: 13.5px;
  font-weight: 800;
  color: #f8fafc;
  margin: 0 0 8px 0;
}

.nova-ai-msg p {
  margin: 0 0 6px 0;
}

.nova-ai-msg p:last-child {
  margin-bottom: 0;
}

.nova-ai-msg ul {
  margin: 4px 0 8px 18px;
  padding: 0;
}

.nova-ai-msg li {
  margin-bottom: 3px;
}

.nova-ai-msg code {
  background: rgba(148, 163, 184, 0.16);
  color: #93c5fd;
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.nova-ai-table-wrap {
  overflow-x: auto;
  margin: 8px 0;
  border-radius: 11px;
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.nova-ai-msg table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.8px;
  background: #0f172a;
}

.nova-ai-msg th {
  background: rgba(30, 41, 59, 0.95);
  color: #94a3b8;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.4px;
  padding: 7px 9px;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  white-space: nowrap;
}

.nova-ai-msg td {
  padding: 7px 9px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.09);
  color: #e2e8f0;
  white-space: nowrap;
}

.nova-ai-msg tbody tr:hover td {
  background: rgba(139, 92, 246, 0.08);
}

.nova-ai-msg td.num,
.nova-ai-msg th.num {
  text-align: right;
}

/* Follow-up chips inside thread */
.nova-ai-followups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.nova-ai-followup-btn {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(139, 92, 246, 0.32);
  background: rgba(124, 58, 237, 0.12);
  color: #c4b5fd;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.nova-ai-followup-btn:hover {
  background: rgba(124, 58, 237, 0.28);
  color: #ffffff;
}

/* Quick bar */
.nova-ai-quick-bar {
  padding: 8px 12px;
  background: #0d1426;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nova-ai-quick-bar.hidden {
  display: none;
}

.nova-ai-quick-bar::-webkit-scrollbar {
  display: none;
}

.nova-ai-chip {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(30, 41, 59, 0.7);
  color: #cbd5e1;
  font-size: 11.2px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  transition: all 0.15s;
}

.nova-ai-chip:hover {
  background: rgba(124, 58, 237, 0.25);
  border-color: rgba(167, 139, 250, 0.5);
  color: #ffffff;
}

/* Input Form */
.nova-ai-form {
  padding: 10px 12px 12px;
  background: #0f172a;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  display: flex;
  gap: 8px;
  align-items: center;
}

.nova-ai-input {
  flex: 1;
  height: 42px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: #0a0f1e;
  color: #f8fafc;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.nova-ai-input:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18);
}

.nova-ai-send {
  height: 42px;
  padding: 0 16px;
  border-radius: 13px;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.15s, transform 0.15s;
}

.nova-ai-send:hover:not(:disabled) {
  transform: translateY(-1px);
}

.nova-ai-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.nova-ai-typing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
  font-size: 12px;
}

.nova-ai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8b5cf6;
  animation: novaAiBounce 1.2s infinite ease-in-out;
}

.nova-ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.nova-ai-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes novaAiBounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

@media (max-width: 640px) {
  .nova-ai-panel,
  .nova-ai-panel.expanded {
    right: 8px;
    left: 8px;
    bottom: 76px;
    width: auto;
    height: calc(100vh - 94px);
  }
  .nova-ai-cards-grid {
    grid-template-columns: 1fr;
  }
  .nova-ai-fab {
    right: 14px;
    bottom: 14px;
  }
}
