/* ============================================================
   CLANDESTINO SYSTEM — Chatbot Styles v2.0
   Estética: laboratorio premium / editorial oscuro / mobile-first
   ============================================================ */

/* ─── VARIABLES ─────────────────────────────────────────────── */
:root {
  --cb-bg:          #060606;
  --cb-surface:     #0c0c0c;
  --cb-surface-2:   #101010;
  --cb-surface-3:   #151515;
  --cb-red:         #c40012;
  --cb-red-dark:    #8a000d;
  --cb-red-dim:     rgba(196, 0, 18, 0.18);
  --cb-red-subtle:  rgba(196, 0, 18, 0.10);
  --cb-text:        #e6e6e6;
  --cb-text-dim:    #4a4a4a;
  --cb-text-mid:    #808080;
  --cb-border:      rgba(196, 0, 18, 0.20);
  --cb-border-dim:  #1a1a1a;
  --cb-border-mid:  #262626;
  --cb-green:       #25D366;
  --cb-shadow:      0 24px 64px rgba(0,0,0,0.88), 0 0 0 1px rgba(196,0,18,0.09);
  --cb-font:        'IBM Plex Mono', 'Courier New', 'Lucida Console', monospace;
  --cb-radius:      10px;
  --cb-radius-lg:   14px;
  --cb-radius-pill: 999px;
  --cb-z:           99999;
}

/* ─── WIDGET RAÍZ ───────────────────────────────────────────── */
#clandestino-chatbot *,
#clandestino-chatbot *::before,
#clandestino-chatbot *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

#clandestino-chatbot {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--cb-z);
  font-family: var(--cb-font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--cb-text);
}

/* ─── BOTÓN FLOTANTE ────────────────────────────────────────── */
#cb-toggle {
  position: relative;
  width: 56px;
  height: 56px;
  background: var(--cb-red);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 28px rgba(196,0,18,0.38), 0 2px 8px rgba(0,0,0,0.5);
}

#cb-toggle:hover {
  background: #d4001a;
  transform: scale(1.05);
  box-shadow: 0 8px 36px rgba(196,0,18,0.50), 0 2px 8px rgba(0,0,0,0.5);
}

#cb-toggle:active {
  transform: scale(0.96);
}

#cb-toggle svg {
  width: 24px;
  height: 24px;
  fill: white;
  transition: transform 0.2s ease;
}

#cb-toggle.open svg {
  transform: scale(0.85);
}

/* Badge de notificación */
#cb-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 19px;
  height: 19px;
  background: white;
  color: var(--cb-red);
  font-family: var(--cb-font);
  font-size: 9px;
  font-weight: 700;
  border-radius: var(--cb-radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  letter-spacing: 0;
  animation: badgePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

@keyframes badgePop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

/* ─── VENTANA PRINCIPAL ─────────────────────────────────────── */
#cb-window {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 400px;
  height: 590px;
  background: var(--cb-bg);
  border: 1px solid var(--cb-border-mid);
  box-shadow: var(--cb-shadow);
  border-radius: var(--cb-radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transition: transform 0.22s cubic-bezier(0.34, 1.2, 0.64, 1),
              opacity 0.18s ease;
}

#cb-window.cb-hidden {
  transform: scale(0.84) translateY(10px);
  opacity: 0;
  pointer-events: none;
}

/* Línea decorativa superior — sutil */
#cb-window::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(196,0,18,0.45), transparent);
  border-radius: var(--cb-radius-lg) var(--cb-radius-lg) 0 0;
  z-index: 1;
}

/* ─── HEADER ────────────────────────────────────────────────── */
#cb-header {
  background: var(--cb-surface);
  border-bottom: 1px solid var(--cb-border-dim);
  padding: 12px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#cb-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Logo mark — cuadrado redondeado */
#cb-logo-mark {
  width: 29px;
  height: 29px;
  background: var(--cb-red);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#cb-logo-mark span {
  color: white;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1;
}

#cb-title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#cb-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--cb-text);
  text-transform: uppercase;
  line-height: 1;
}

#cb-status-line {
  font-size: 8px;
  letter-spacing: 1.2px;
  color: var(--cb-text-mid);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1;
}

#cb-status-dot {
  width: 5px;
  height: 5px;
  background: #3aaa5a;
  border-radius: 50%;
  animation: cbPulse 2.8s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes cbPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

/* Botones de control del header */
#cb-header-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

.cb-ctrl-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--cb-text-dim);
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
  border-radius: 6px;
}

.cb-ctrl-btn:hover {
  color: var(--cb-text-mid);
  background: var(--cb-border-dim);
}

.cb-ctrl-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ─── ÁREA DE MENSAJES ──────────────────────────────────────── */
#cb-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: var(--cb-bg);
}

/* Scrollbar custom */
#cb-messages::-webkit-scrollbar {
  width: 3px;
}
#cb-messages::-webkit-scrollbar-track {
  background: transparent;
}
#cb-messages::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border-radius: 2px;
}
#cb-messages::-webkit-scrollbar-thumb:hover {
  background: #3a3a3a;
}

/* ─── MENSAJES ──────────────────────────────────────────────── */
.cb-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: cbFadeUp 0.2s ease;
}

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

.cb-msg-row.bot {
  align-self: flex-start;
}

.cb-msg-row.user {
  align-self: flex-end;
}

/* Burbujas */
.cb-bubble {
  padding: 11px 14px;
  font-size: 13px;
  line-height: 1.55;
  letter-spacing: 0.15px;
  word-break: break-word;
}

.cb-msg-row.bot .cb-bubble {
  background: var(--cb-surface-2);
  color: var(--cb-text);
  border: 1px solid var(--cb-border-dim);
  border-left: 2px solid rgba(196, 0, 18, 0.35);
  border-radius: 2px 10px 10px 10px;
}

.cb-msg-row.user .cb-bubble {
  background: var(--cb-red);
  color: white;
  border-radius: 10px 2px 10px 10px;
  letter-spacing: 0.2px;
}

/* ─── TYPING INDICATOR ──────────────────────────────────────── */
.cb-typing-row {
  display: flex;
  align-self: flex-start;
  animation: cbFadeUp 0.15s ease;
}

.cb-typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 11px 15px;
  background: var(--cb-surface-2);
  border: 1px solid var(--cb-border-dim);
  border-left: 2px solid rgba(196, 0, 18, 0.30);
  border-radius: 2px 10px 10px 10px;
}

.cb-typing-dot {
  width: 5px;
  height: 5px;
  background: var(--cb-text-dim);
  border-radius: 50%;
  animation: cbTypingDot 1.3s ease-in-out infinite;
}
.cb-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.cb-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes cbTypingDot {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.35; }
  30%           { transform: translateY(-4px);  opacity: 0.9;  }
}

/* ─── QUICK REPLIES — chips premium ─────────────────────────── */
.cb-replies-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  align-self: flex-start;
  max-width: 96%;
  animation: cbFadeUp 0.25s ease;
}

.cb-reply-btn {
  background: var(--cb-surface-2);
  border: 1px solid rgba(196, 0, 18, 0.28);
  color: #d0d0d0;
  font-family: var(--cb-font);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.4px;
  padding: 8px 13px;
  border-radius: var(--cb-radius-pill);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  text-transform: none;
  line-height: 1;
}

.cb-reply-btn:hover {
  background: rgba(196, 0, 18, 0.12);
  border-color: rgba(196, 0, 18, 0.65);
  color: #f0f0f0;
}

.cb-reply-btn:active {
  background: rgba(196, 0, 18, 0.22);
  border-color: var(--cb-red);
  color: white;
}

.cb-reply-btn:disabled {
  opacity: 0.28;
  cursor: default;
  pointer-events: none;
}

/* ─── PRODUCT CARDS ─────────────────────────────────────────── */
.cb-card-wrap {
  margin-top: 6px;
  align-self: flex-start;
  width: 100%;
  max-width: 96%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: cbFadeUp 0.25s ease;
}

.cb-product-card {
  background: var(--cb-surface-2);
  border: 1px solid var(--cb-border-dim);
  border-left: 2px solid rgba(196, 0, 18, 0.30);
  border-radius: 0 8px 8px 8px;
  padding: 13px 15px;
  transition: border-left-color 0.2s ease;
}

.cb-product-card:hover {
  border-left-color: rgba(196, 0, 18, 0.65);
}

.cb-card-name {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--cb-red);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.cb-card-subtitle {
  font-size: 8.5px;
  letter-spacing: 1.2px;
  color: var(--cb-text-dim);
  text-transform: uppercase;
  margin-bottom: 7px;
}

.cb-card-desc {
  font-size: 12px;
  color: #c8c8c8;
  line-height: 1.6;
  margin-bottom: 9px;
  letter-spacing: 0.1px;
}

.cb-card-note {
  font-size: 11px;
  color: var(--cb-text-mid);
  line-height: 1.5;
  margin-bottom: 9px;
  padding: 6px 9px;
  border-left: 1px solid var(--cb-border-mid);
  border-radius: 0 4px 4px 0;
  background: rgba(255,255,255,0.02);
  letter-spacing: 0.1px;
}

.cb-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.cb-tag {
  background: var(--cb-surface-3);
  border: 1px solid var(--cb-border-dim);
  color: #555;
  font-size: 8.5px;
  font-weight: 600;
  padding: 3px 7px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-radius: 4px;
}

.cb-card-cta {
  display: inline-block;
  background: var(--cb-red);
  color: white;
  font-family: var(--cb-font);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 7px 14px;
  text-decoration: none;
  text-transform: uppercase;
  border-radius: 6px;
  transition: background 0.15s ease;
  cursor: pointer;
  border: none;
}

.cb-card-cta:hover {
  background: #d4001a;
  color: white;
  text-decoration: none;
}

/* ─── BOTÓN WHATSAPP ────────────────────────────────────────── */
.cb-wa-wrap {
  margin-top: 6px;
  align-self: flex-start;
  animation: cbFadeUp 0.25s ease;
}

.cb-wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: 1px solid rgba(37, 211, 102, 0.35);
  color: var(--cb-green);
  font-family: var(--cb-font);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.7px;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  text-transform: uppercase;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cb-wa-btn:hover {
  background: rgba(37, 211, 102, 0.10);
  border-color: var(--cb-green);
  color: var(--cb-green);
  text-decoration: none;
}

.cb-wa-btn svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
  flex-shrink: 0;
}

/* ─── SEPARADOR ─────────────────────────────────────────────── */
.cb-section-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--cb-text-dim);
  text-transform: uppercase;
  padding: 8px 0 3px;
  display: flex;
  align-items: center;
  gap: 9px;
  align-self: flex-start;
  width: 100%;
  max-width: 96%;
}

.cb-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--cb-border-dim);
}

/* ─── INPUT AREA ────────────────────────────────────────────── */
#cb-input-area {
  border-top: 1px solid var(--cb-border-dim);
  padding: 10px 12px;
  display: flex;
  gap: 7px;
  background: var(--cb-surface);
  flex-shrink: 0;
  align-items: center;
}

#cb-input {
  flex: 1;
  background: #0a0a0a;
  border: 1px solid #232323;
  color: var(--cb-text);
  font-family: var(--cb-font);
  font-size: 12.5px;
  padding: 9px 12px;
  outline: none;
  border-radius: 7px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  letter-spacing: 0.2px;
  line-height: 1.4;
  min-height: 38px;
}

#cb-input:focus {
  border-color: rgba(196, 0, 18, 0.40);
  box-shadow: 0 0 0 2px rgba(196,0,18,0.07);
}

#cb-input::placeholder {
  color: #3a3a3a;
  font-size: 11.5px;
  letter-spacing: 0.3px;
}

#cb-send {
  background: var(--cb-red);
  border: none;
  border-radius: 7px;
  cursor: pointer;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
}

#cb-send:hover  { background: #d4001a; }
#cb-send:active { transform: scale(0.92); }

#cb-send svg {
  width: 15px;
  height: 15px;
  fill: white;
}

/* ─── FOOTER ────────────────────────────────────────────────── */
#cb-footer {
  padding: 5px 12px;
  text-align: center;
  font-size: 8px;
  letter-spacing: 1px;
  color: #2e2e2e;
  text-transform: uppercase;
  border-top: 1px solid var(--cb-border-dim);
  flex-shrink: 0;
  background: var(--cb-bg);
  line-height: 1.5;
}

/* ─── MOBILE RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 480px) {
  #clandestino-chatbot {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
  }

  #cb-window {
    position: fixed;
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 72px;

    width: auto;
    height: auto;
    max-height: min(72vh, 560px);

    border-radius: 12px;
  }

  #cb-messages {
    min-height: 220px;
    max-height: calc(min(72vh, 560px) - 126px);
    overflow-y: auto;
    padding: 14px 12px;
  }

  #cb-input-area {
    padding: 10px;
    position: relative;
    z-index: 2;
  }

  #cb-input {
    font-size: 16px;
    padding: 10px 12px;
  }

  #cb-input::placeholder {
    font-size: 13px;
  }

  #cb-toggle {
    width: 52px;
    height: 52px;
    border-radius: 13px;
  }

  .cb-bubble {
    font-size: 13.5px;
    padding: 11px 13px;
    line-height: 1.55;
  }

  .cb-msg-row {
    max-width: 94%;
  }

  .cb-reply-btn {
    font-size: 12px;
    padding: 10px 14px;
  }

  .cb-replies-wrap {
    max-width: 100%;
    gap: 7px;
  }

  .cb-card-wrap {
    max-width: 100%;
  }

  .cb-card-desc {
    font-size: 12.5px;
  }

  .cb-card-cta {
    font-size: 9.5px;
    padding: 8px 15px;
  }

  .cb-wa-btn {
    font-size: 10.5px;
    padding: 9px 14px;
  }
}@supports (height: 100dvh) {
  @media (max-width: 480px) {
    #cb-window {
      max-height: min(72dvh, 560px);
    }

    #cb-messages {
      max-height: calc(min(72dvh, 560px) - 126px);
    }
  }
}

/* ─── ACCESIBILIDAD ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #cb-window,
  .cb-msg-row,
  .cb-replies-wrap,
  .cb-card-wrap {
    animation: none;
    transition: none;
  }

  #cb-status-dot,
  .cb-typing-dot {
    animation: none;
    opacity: 0.6;
  }
}
/* FIX MOBILE KEYBOARD / CHROME ANDROID */
@media (max-width: 768px) {
  #clandestino-chatbot {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    bottom: 10px !important;
    width: auto !important;
    z-index: 999999 !important;
  }

  #cb-window {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    top: 72px !important;
    bottom: 82px !important;

    width: auto !important;
    height: auto !important;
    max-height: none !important;

    display: flex !important;
    flex-direction: column !important;
  }

  #cb-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  #cb-input-area,
  #cb-footer {
    flex-shrink: 0 !important;
  }

  #cb-input {
    font-size: 16px !important;
  }
}