/* ═══════════════════════════════════════════════
   Chat Widget GasSantana — Estilos
   WhatsApp-like floating widget
   Prefijo: .gs-chat-  (sin colisiones con Bootstrap)
   ═══════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────── */
:root {
  --gs-primary: #075e54;
  --gs-primary-dark: #054c44;
  --gs-secondary: #25d366;
  --gs-bg: #e5ddd5;
  --gs-bg-chat: #ece5dd;
  --gs-bubble-bot: #ffffff;
  --gs-bubble-user: #dcf8c6;
  --gs-text: #303030;
  --gs-text-light: #667781;
  --gs-shadow: 0 2px 12px rgba(0,0,0,.15);
  --gs-radius: 12px;
  --gs-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Botón flotante ─────────────────────────── */
.gs-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gs-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--gs-shadow);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, background .2s;
}
.gs-chat-fab:hover {
  background: var(--gs-primary-dark);
  transform: scale(1.08);
}
.gs-chat-fab svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}
.gs-chat-fab .gs-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ff5252;
  font-size: 11px;
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
}

/* ── Contenedor principal ──────────────────── */
.gs-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--gs-bg-chat);
  border-radius: var(--gs-radius);
  box-shadow: var(--gs-shadow);
  z-index: 99998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--gs-font);
}
.gs-chat-window.gs-open {
  display: flex;
}

/* ── Header ────────────────────────────────── */
.gs-chat-header {
  background: var(--gs-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.gs-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gs-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.gs-chat-header-info {
  flex: 1;
  min-width: 0;
}
.gs-chat-header-info h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.gs-chat-header-info small {
  font-size: 12px;
  opacity: .85;
}
.gs-chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  opacity: .8;
}
.gs-chat-close:hover { opacity: 1; }

/* ── Sugerencias rápidas ──────────────────── */
.gs-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 6px;
  background: var(--gs-bg-chat);
  flex-shrink: 0;
}
.gs-chat-suggestions button {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--gs-primary);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.gs-chat-suggestions button:hover {
  background: var(--gs-primary);
  color: #fff;
  border-color: var(--gs-primary);
}

/* ── Mensajes ──────────────────────────────── */
.gs-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Crect fill='%23e5ddd5' width='200' height='200'/%3E%3Cpath d='M0 0h200v200H0z' fill='%23ddd8cf' opacity='.05'/%3E%3C/svg%3E");
}

.gs-msg {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--gs-text);
  position: relative;
  word-wrap: break-word;
}
.gs-msg-bot {
  align-self: flex-start;
  background: var(--gs-bubble-bot);
  border-top-left-radius: 2px;
}
.gs-msg-user {
  align-self: flex-end;
  background: var(--gs-bubble-user);
  border-top-right-radius: 2px;
}
.gs-msg-time {
  display: block;
  font-size: 11px;
  color: var(--gs-text-light);
  text-align: right;
  margin-top: 4px;
}

/* ── Estado de herramientas ───────────────── */
.gs-msg-status {
  align-self: flex-start;
  background: transparent;
  font-size: 12px;
  color: var(--gs-text-light);
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.gs-msg-status .gs-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #ccc;
  border-top-color: var(--gs-primary);
  border-radius: 50%;
  animation: gs-spin .8s linear infinite;
}
@keyframes gs-spin { to { transform: rotate(360deg); } }

/* ── Typing dots ──────────────────────────── */
.gs-typing {
  align-self: flex-start;
  background: var(--gs-bubble-bot);
  border-radius: 8px;
  padding: 10px 16px;
  display: none;
}
.gs-typing span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #90a4ae;
  margin: 0 2px;
  animation: gs-dot 1.4s ease-in-out infinite;
}
.gs-typing span:nth-child(2) { animation-delay: .2s; }
.gs-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes gs-dot {
  0%,80%,100% { transform: scale(.4); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Input ─────────────────────────────────── */
.gs-chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f0f0f0;
  border-top: 1px solid #ddd;
  flex-shrink: 0;
}
.gs-chat-input {
  flex: 1;
  border: none;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  background: #fff;
  outline: none;
  font-family: var(--gs-font);
  resize: none;
  max-height: 80px;
  line-height: 1.35;
}
.gs-chat-input:focus {
  box-shadow: 0 0 0 2px rgba(7,94,84,.25);
}
.gs-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--gs-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.gs-chat-send:hover { background: var(--gs-primary-dark); }
.gs-chat-send:disabled { background: #aaa; cursor: not-allowed; }
.gs-chat-send svg { width: 18px; height: 18px; fill: currentColor; }

/* ── Markdown básico dentro del bot ───────── */
.gs-msg-bot p { margin: 0 0 6px; }
.gs-msg-bot p:last-child { margin: 0; }
.gs-msg-bot ul, .gs-msg-bot ol {
  margin: 4px 0;
  padding-left: 18px;
}
.gs-msg-bot li { margin-bottom: 2px; }
.gs-msg-bot strong { font-weight: 600; }
.gs-msg-bot code {
  background: #f4f4f4;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 13px;
}

/* ── Ocultar WhatsApp float cuando el chat está abierto ── */
.gs-chat-window.gs-open ~ .whatsapp-float,
body.gs-chat-active .whatsapp-float {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

/* ── Session banners ───────────────────────── */
.gs-session-banner {
  padding: 8px 14px;
  font-size: 12px;
  text-align: center;
  border-bottom: 1px solid #e0e0e0;
  line-height: 1.4;
  animation: gs-slideDown 0.3s ease;
}
@keyframes gs-slideDown {
  from { max-height: 0; opacity: 0; padding: 0 14px; }
  to   { max-height: 60px; opacity: 1; padding: 8px 14px; }
}
.gs-session-warning {
  background: #fff3cd;
  color: #856404;
  border-bottom-color: #ffc107;
}
.gs-session-expired {
  background: #f8d7da;
  color: #721c24;
  border-bottom-color: #f5c6cb;
}
.gs-session-banner button {
  background: none;
  border: none;
  color: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  font-size: 12px;
  padding: 2px 4px;
}
.gs-session-banner button:hover {
  opacity: 0.8;
}

/* New chat button in header */
.gs-chat-new {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 50%;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gs-chat-new:hover {
  background: rgba(255,255,255,0.2);
}

/* System message */
.gs-msg-system {
  text-align: center;
  color: #888;
  font-size: 12px;
  padding: 8px 16px;
  margin: 8px 0;
}
.gs-msg-system em {
  background: #f0f0f0;
  padding: 6px 12px;
  border-radius: 12px;
  display: inline-block;
}

/* Disabled state for input */
.gs-chat-input:disabled {
  background: #f5f5f5;
  color: #999;
  cursor: not-allowed;
}

/* ── Responsive ────────────────────────────── */
@media (max-width: 480px) {
  .gs-chat-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .gs-chat-fab {
    bottom: 16px;
    right: 16px;
  }
  .whatsapp-float {
    bottom: 80px !important;
    right: 18px !important;
  }
}
