/**
 * GoSolutions — Widget de asistente virtual (chatbot)
 * Estilos desacoplados del JS para cache y mantenimiento
 */

:root {
  --gs-chat-primary: #2563eb;
  --gs-chat-primary-dark: #1d4ed8;
  --gs-chat-accent: #0ea5e9;
  --gs-chat-surface: #ffffff;
  --gs-chat-bg: #f1f5f9;
  --gs-chat-border: rgba(15, 23, 42, 0.08);
  --gs-chat-text: #0f172a;
  --gs-chat-text-muted: #64748b;
  --gs-chat-bot-bubble: #ffffff;
  --gs-chat-user-bubble: #eff6ff;
  --gs-chat-user-text: #1e40af;
  --gs-chat-header-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 45%, #0f172a 100%);
  --gs-chat-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  --gs-chat-shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.08);
  --gs-chat-radius: 16px;
  --gs-chat-radius-sm: 12px;
  --gs-chat-z-fab: 1040;
  --gs-chat-z-panel: 1050;
}

/* ========== FAB ========== */
.gs-chat__fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: var(--gs-chat-z-fab);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(145deg, var(--gs-chat-primary) 0%, #4f46e5 50%, var(--gs-chat-primary-dark) 100%);
  box-shadow: 0 10px 40px rgba(37, 99, 235, 0.45), 0 0 0 0 rgba(37, 99, 235, 0.4);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  animation: gs-chat-fab-pulse 2.5s ease-in-out infinite;
}

.gs-chat__fab:hover {
  transform: scale(1.08);
  box-shadow: 0 14px 48px rgba(37, 99, 235, 0.55);
}

.gs-chat__fab:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.5);
  outline-offset: 3px;
}

.gs-chat__fab i {
  font-size: 1.45rem;
  position: relative;
  z-index: 1;
}

.gs-chat__fab-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border: 2px solid #fff;
  border-radius: 50%;
  z-index: 2;
}

@keyframes gs-chat-fab-pulse {
  0%, 100% { box-shadow: 0 10px 40px rgba(37, 99, 235, 0.45), 0 0 0 0 rgba(37, 99, 235, 0.35); }
  50% { box-shadow: 0 10px 40px rgba(37, 99, 235, 0.5), 0 0 0 8px rgba(37, 99, 235, 0); }
}

/* ========== Panel ========== */
.gs-chat__panel {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: min(400px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 100px));
  max-height: calc(100vh - 100px);
  background: var(--gs-chat-surface);
  border-radius: var(--gs-chat-radius);
  box-shadow: var(--gs-chat-shadow);
  z-index: var(--gs-chat-z-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--gs-chat-border);
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.gs-chat__panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.gs-chat__panel[hidden] {
  display: none !important;
}

/* ========== Header ========== */
.gs-chat__header {
  flex-shrink: 0;
  padding: 1rem 1.1rem;
  background: var(--gs-chat-header-bg);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.gs-chat__avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.gs-chat__avatar i {
  font-size: 1.35rem;
  color: #93c5fd;
}

.gs-chat__headline {
  flex: 1;
  min-width: 0;
}

.gs-chat__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.gs-chat__subtitle {
  display: block;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 2px;
}

.gs-chat__subtitle-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  animation: gs-chat-blink 2s ease-in-out infinite;
}

@keyframes gs-chat-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.gs-chat__toolbar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.gs-chat__icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.gs-chat__icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.gs-chat__icon-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 2px;
}

.gs-chat__icon-btn.is-muted {
  opacity: 0.55;
}

/* ========== Messages ========== */
.gs-chat__messages {
  flex: 1;
  min-height: 0;
  padding: 1rem 1rem 0.75rem;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--gs-chat-bg);
  scroll-behavior: smooth;
}

.gs-chat__messages::-webkit-scrollbar {
  width: 6px;
}

.gs-chat__messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.gs-chat__welcome {
  text-align: center;
  padding: 2rem 1rem;
}

.gs-chat__typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 0.5rem 0;
}

.gs-chat__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gs-chat-primary);
  animation: gs-chat-typing 1.3s ease-in-out infinite;
}

.gs-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.gs-chat__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes gs-chat-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.gs-chat__msg {
  margin-bottom: 0.85rem;
  animation: gs-chat-msg-in 0.35s ease;
}

@keyframes gs-chat-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.gs-chat__msg--bot {
  display: flex;
  justify-content: flex-start;
}

.gs-chat__msg--user {
  display: flex;
  justify-content: flex-end;
}

.gs-chat__bubble {
  max-width: 92%;
  padding: 0.65rem 0.95rem;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--gs-chat-text);
  box-shadow: var(--gs-chat-shadow-sm);
}

.gs-chat__msg--bot .gs-chat__bubble {
  background: var(--gs-chat-bot-bubble);
  border: 1px solid var(--gs-chat-border);
  border-bottom-left-radius: 4px;
}

.gs-chat__msg--user .gs-chat__bubble {
  background: var(--gs-chat-user-bubble);
  color: var(--gs-chat-user-text);
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-bottom-right-radius: 4px;
}

.gs-chat__bubble p {
  margin: 0 0 0.5rem;
}

.gs-chat__bubble p:last-child {
  margin-bottom: 0;
}

.gs-chat__list {
  margin: 0.65rem 0 0;
  padding: 0;
  list-style: none;
}

.gs-chat__list li {
  position: relative;
  padding: 0.35rem 0 0.35rem 1.1rem;
  font-size: 0.8125rem;
  color: var(--gs-chat-text-muted);
  line-height: 1.45;
}

.gs-chat__list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65rem;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gs-chat-accent);
}

/* ========== Options ========== */
.gs-chat__options-wrap {
  margin-top: 0.5rem;
}

.gs-chat__options {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.gs-chat__opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gs-chat-primary);
  background: #fff;
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.gs-chat__opt:hover:not(:disabled) {
  background: #eff6ff;
  border-color: rgba(37, 99, 235, 0.45);
  transform: translateX(2px);
}

.gs-chat__opt:focus-visible {
  outline: 2px solid var(--gs-chat-primary);
  outline-offset: 2px;
}

.gs-chat__opt:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.gs-chat__opt.is-selected {
  background: #dbeafe;
  border-color: var(--gs-chat-primary);
}

/* Inner options block inside bot bubble */
.gs-chat__msg--bot .gs-chat__options-wrap .gs-chat__bubble {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid var(--gs-chat-border);
  max-width: 100%;
}

/* ========== Footer / input area ========== */
.gs-chat__footer {
  flex-shrink: 0;
  padding: 0.65rem 1rem 0.85rem;
  background: #fff;
  border-top: 1px solid var(--gs-chat-border);
  font-size: 0.7rem;
  color: var(--gs-chat-text-muted);
  text-align: center;
}

.gs-chat__footer kbd {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}

/* ========== Responsive ========== */
@media (max-width: 576px) {
  .gs-chat__fab {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
  }

  .gs-chat__panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }

}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .gs-chat__fab,
  .gs-chat__panel,
  .gs-chat__msg,
  .gs-chat__typing span,
  .gs-chat__subtitle-dot {
    animation: none !important;
    transition: none !important;
  }
}
