/**
 * AI Chat — Frontend Styles (nuevo markup, con posiciones)
 * Clases: .aichat-widget, .aichat-inner, .aichat-header, .aichat-messages,
 *         .aichat-inputbar, .aichat-input, .aichat-send, .message, etc.
 */

/* Base aislada */
.aichat-widget, .aichat-widget * {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.45;
}

/* Contenedor flotante (global) */
.aichat-widget.is-global {
  position: fixed;
  width: 320px;
  max-width: min(92vw, 420px);
  z-index: 99999;
}

/* Posiciones del widget flotante */
.aichat-widget.is-global.pos-bottom-right { right: 20px; bottom: 20px; left: auto; top: auto; }
.aichat-widget.is-global.pos-bottom-left  { left: 20px;  bottom: 20px; right: auto; top: auto; }
.aichat-widget.is-global.pos-top-right    { right: 20px; top: 20px;    left: auto; bottom: auto; }
.aichat-widget.is-global.pos-top-left     { left: 20px;  top: 20px;    right: auto; bottom: auto; }

/* Fallback (si no viene clase de posición, usa bottom-right) */
.aichat-widget.is-global:not(.pos-bottom-right):not(.pos-bottom-left):not(.pos-top-right):not(.pos-top-left) {
  right: 20px; bottom: 20px;
}

/* Contenedor embebido (shortcode) */
.aichat-widget:not(.is-global) {
  position: relative;
  width: 100%;
  max-width: 760px;
  margin: 1rem 0;
}

/* Tarjeta */
.aichat-inner {
  display: flex;
  flex-direction: column;
  background: #fff !important;
  border: 1px solid #ddd !important;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  position: relative; /* necesario para posicionar overlay */
}

/* Cabecera */
.aichat-header {
  background: #0073aa;
  color: #fff !important;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 14px;
  position: relative; /* para posicionar el avatar */
  min-height: 48px;
  display: flex;
  align-items: center;
}
.aichat-header.with-avatar{
  justify-content: flex-start;
  padding-left: 84px; /* espacio para avatar (60px) + margen */
  min-height: 72px;   /* altura suficiente para 60px de avatar + padding */
}
.aichat-avatar-badge{
  position: absolute;
  left: 10px;
  top: 8px;
  width: 60px; height: 60px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
  object-fit: cover;
  background: #fff;
}
.aichat-header-text{
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  overflow: hidden;
}
.aichat-header-title{
  color: rgba(255,255,255,0.9) !important;
  font-weight: 700;
}
.aichat-header-subtitle{
  color: rgba(255,255,255,0.85) !important;
  font-weight: 500;
  font-size: 12.5px;
  line-height: 1.2;
}
.aichat-start-sentence{
  color: #fff !important;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Controles cabecera */
.aichat-header .aichat-header-controls{
  margin-left: auto;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.aichat-header .aichat-header-controls .aichat-btn{
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.aichat-btn{
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  width: 24px; height: 24px;
  border: none !important;
  border-radius: 6px;
  background: rgba(255,255,255,.18) !important;
  color: #fff !important;
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.aichat-btn:hover{ background: rgba(255,255,255,.28) !important; }

/* Mejora targets táctiles en móviles */
@media (max-width: 600px){
  .aichat-header .aichat-header-controls{ gap: 8px; }
  .aichat-header .aichat-header-controls .aichat-btn{
    width: 32px; height: 32px; font-size: 18px;
  }
}

/* Icon sizing */
.aichat-btn .aichat-ico-max{ width: 16px; height: 16px; display:block }

/* === Force CSS isolation (when .css-forced is on the widget) === */
.aichat-widget.css-forced,
.aichat-widget.css-forced * {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif !important;
  line-height: 1.45 !important;
}
.aichat-widget.css-forced .message       { font-size: 14px !important; }
.aichat-widget.css-forced .aichat-header  { font-size: 14px !important; }
.aichat-widget.css-forced .aichat-input   { font-size: 14px !important; }
.aichat-widget.css-forced .aichat-send    { font-size: 14px !important; }
.aichat-widget.css-forced .aichat-footer{ font-size: 11px !important; }
.aichat-widget.css-forced .aichat-suggestion { font-size: 13px !important; }
.aichat-widget.css-forced .aichat-qq-btn { font-size: 13px !important; }
/* Cap markdown headings inside chat bubbles */
.aichat-widget.css-forced .bot-message h1,
.aichat-widget.css-forced .bot-message h2,
.aichat-widget.css-forced .bot-message h3,
.aichat-widget.css-forced .bot-message h4,
.aichat-widget.css-forced .bot-message h5,
.aichat-widget.css-forced .bot-message h6 {
  font-size: 15px !important;
  margin: 4px 0 2px !important;
  line-height: 1.4 !important;
  font-weight: 600 !important;
}

/* +New conversation button (floats inside messages area, no space taken) */
.aichat-newconv-btn{
  appearance: none;
  position: sticky;
  top: 2px;
  left: 2px;
  z-index: 2;
  border: 1px solid #ccc !important;
  border-radius: 4px;
  background: rgba(245,245,245,.92) !important;
  color: #888 !important;
  font-size: 10px;
  line-height: 1.4;
  padding: 1px 6px;
  cursor: pointer;
  font-family: inherit;
  float: left;
  margin: 0 4px 4px 0;
}
.aichat-newconv-btn:hover{
  background: rgba(230,230,230,.95) !important;
  color: #555 !important;
}

/* Mensajes */
.aichat-messages {
  padding: 10px 12px;
  overflow-y: auto;
  background: #fff !important;
}

/* Alturas por defecto (el JS puede sobreescribir con data-height) */
.aichat-widget.is-global .aichat-messages { height: 280px; }
.aichat-widget:not(.is-global) .aichat-messages { min-height: 160px; }

/* Burbujas */
.message {
  margin: 6px 0;
  padding: 8px 10px;
  border-radius: 8px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  color: #333 !important;
}
.user-message {
  background: #e1f5fe !important;
  color: #1a1a1a !important;
  margin-left: 20%;
}
.bot-message {
  background: transparent !important;
  color: #222 !important;
  margin-right: 0;
  width: 100%;
  display: block;
}
.bot-message img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 8px 0;
  display: block;
}
.aichat-suggestions{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 8px 0;
}
.aichat-suggestions .aichat-suggestion{
  appearance: none;
  border: 1px solid rgba(0,0,0,.10) !important;
  background: var(--aichat-sugg-bg, #f1f3f4) !important;
  color: var(--aichat-sugg-text, #1a73e8) !important;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
  transition: background .15s, color .15s;
}
.aichat-suggestions .aichat-suggestion:hover{
  background: var(--aichat-sugg-text, #1a73e8) !important;
  color: var(--aichat-sugg-bg, #f1f3f4) !important;
}
.aichat-suggestions .aichat-suggestion:disabled{
  opacity: .6;
  cursor: not-allowed;
}

/* Quick Questions bar (above input) */
.aichat-quick-questions-bar{
  overflow: hidden;
  transition: max-height .3s ease;
  background: transparent;
}
.aichat-quick-questions-bar.collapsed{
  max-height: 0 !important;
}
.aichat-qq-toggle{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: #999;
  line-height: 1;
  transition: color .15s;
}
.aichat-qq-toggle:hover{ color: #555; }
.aichat-qq-toggle svg{
  width: 22px; height: 22px;
  transition: transform .25s;
}
/* open = list visible → arrow points down; collapsed → arrow points up */
.aichat-qq-toggle.open svg{ transform: rotate(180deg); }
.aichat-qq-list{
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  max-height: 152px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}
.aichat-qq-list::-webkit-scrollbar{ width: 5px; }
.aichat-qq-list::-webkit-scrollbar-thumb{ background: rgba(0,0,0,.18); border-radius: 4px; }
.aichat-qq-btn{
  appearance: none;
  border: 1px solid rgba(0,0,0,.10) !important;
  background: var(--aichat-sugg-bg, #f1f3f4) !important;
  color: var(--aichat-sugg-text, #1a73e8) !important;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
  font-family: inherit;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.aichat-qq-btn:hover{
  background: var(--aichat-sugg-text, #1a73e8) !important;
  color: var(--aichat-sugg-bg, #f1f3f4) !important;
}

.bot-message.error {
  background: #ffecec !important;
  color: #b00020 !important;
}

/* Indicador escribiendo */
.message.typing {
  background: #f5f5f5 !important;
  opacity: .8;
}
.message.typing .dots {
  display: inline-block;
  animation: aichat-blink 1s infinite;
}
@keyframes aichat-blink {
  0% { opacity: .2; } 50% { opacity: 1; } 100% { opacity: .2; }
}

/* Barra de entrada */
.aichat-inputbar {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid #eee;
  background: #fff !important;
}
/* Botón micrófono */
.aichat-mic{
   padding: 0 !important;   /* elimina padding heredado */
  width: 42px; min-width: 42px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0;
  border-radius: 8px;
  background: #f1f3f5;
  color: #333;
  font-size: 18px;
  cursor: pointer; 
}
/* Iconos SVG mic/stop */
.aichat-mic .icon-mic,
.aichat-mic .icon-stop {
  width: 24px; /* Tamaño aumentado */
  height: 24px;
}
.aichat-mic .icon-stop { display: none; }
.aichat-mic.is-recording { background: #c62828; color: #fff; }
.aichat-mic.is-recording .icon-mic { display: none; }
.aichat-mic.is-recording .icon-stop { display: inline; }
.aichat-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #ddd !important;
  border-radius: 8px;
  outline: none;
  background: #fff !important;
  color: #333 !important;
}
.aichat-input:focus {
  border-color: #0073aa !important;
  box-shadow: 0 0 0 3px rgba(0,115,170,.12);
}
.aichat-input::placeholder {
  color: #999 !important;
}
.aichat-send {
  padding: 10px 14px;
  border: 0 !important;
  border-radius: 8px;
  background: #0073aa;
  color: #fff !important;
  font-weight: 600;
  cursor: pointer;
  text-transform: none !important;
  font-variant: normal;
  letter-spacing: normal;
}
.aichat-send:hover { filter: brightness(0.95); }
.aichat-send:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* Altura unificada para cabecera e inputbar */
.aichat-widget {
  --aichat-bar-h: 44px;   /* altura total deseada de ambas barras */
  --aichat-bar-py: 6px;   /* padding vertical */
  --aichat-bar-px: 10px;  /* padding horizontal */
}

.aichat-header {
  min-height: var(--aichat-bar-h);
  padding: var(--aichat-bar-py) var(--aichat-bar-px);
  display: flex;
  align-items: center;
}

.aichat-inputbar {
  min-height: var(--aichat-bar-h);
  padding: var(--aichat-bar-py) var(--aichat-bar-px);
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #eee;
  background: #fff;
}

/* Controles ajustados a la altura unificada */
.aichat-input {
  height: calc(var(--aichat-bar-h) - 2 * var(--aichat-bar-py));
  padding: 0 12px;
}

.aichat-mic {
  padding: 0 !important;
  width: calc(var(--aichat-bar-h) - 2 * var(--aichat-bar-py));
  min-width: calc(var(--aichat-bar-h) - 2 * var(--aichat-bar-py));
  height: calc(var(--aichat-bar-h) - 2 * var(--aichat-bar-py));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: #f1f3f5;
}
.aichat-mic .icon-mic,
.aichat-mic .icon-stop { width: 22px; height: 22px; }

.aichat-send {
  height: calc(var(--aichat-bar-h) - 2 * var(--aichat-bar-py));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-transform: none !important;
}

/* Minimizado: oculta cuerpo */
.aichat-inner.is-minimized .aichat-messages,
.aichat-inner.is-minimized .aichat-inputbar,
.aichat-inner.is-minimized .aichat-quick-questions-bar{ display: none; }
.aichat-inner.is-minimized{ border-bottom-left-radius:10px; border-bottom-right-radius:10px; }

/* Super minimizado: solo avatar (o un círculo) */
.aichat-widget.is-superminimized{
  width:60px !important;
  height:60px !important;
  min-width:60px;
  min-height:60px;
  overflow:visible;
}
/* Explicit corner anchoring for super-minimized with safe-area insets */
.aichat-widget.is-global.is-superminimized.pos-bottom-right{ right: max(12px, env(safe-area-inset-right, 0px)); bottom: calc(62px + env(safe-area-inset-bottom, 0px)); left:auto; top:auto; }
.aichat-widget.is-global.is-superminimized.pos-bottom-left{  left:  max(12px, env(safe-area-inset-left, 0px));  bottom: calc(62px + env(safe-area-inset-bottom, 0px)); right:auto; top:auto; }
.aichat-widget.is-global.is-superminimized.pos-top-right{    right: max(12px, env(safe-area-inset-right, 0px)); top:    calc(12px + env(safe-area-inset-top, 0px));    left:auto; bottom:auto; }
.aichat-widget.is-global.is-superminimized.pos-top-left{     left:  max(12px, env(safe-area-inset-left, 0px));  top:    calc(12px + env(safe-area-inset-top, 0px));     right:auto; bottom:auto; }
/* Maximized: fills viewport with safe paddings */
.aichat-widget.is-global.is-maximized{
  inset: 12px !important;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  left: 12px !important; right: 12px !important; top: 12px !important; bottom: 12px !important;
}
/* Ensure inner takes full height and messages flex to fill */
.aichat-widget.is-global.is-maximized .aichat-inner{ height: 100%; }
.aichat-widget.is-global.is-maximized .aichat-messages{
  height: auto !important; /* override fixed heights */
  flex: 1 1 auto;
  min-height: 240px;
}
.aichat-widget.is-superminimized .aichat-inner{
  padding:0 !important;
  width:60px !important;
  height:60px !important;
  background:transparent !important;
  border:none !important;
  box-shadow:none !important;
  border-radius:0 !important;
  overflow:visible !important;
  outline:none !important;
}
/* Strip the widget wrapper too so themes cannot paint on the 320px box */
.aichat-widget.is-superminimized{
  width:60px !important;
  max-width:60px !important;
  background:transparent !important;
  border:none !important;
  box-shadow:none !important;
  outline:none !important;
}
.aichat-widget.is-superminimized .aichat-header,
.aichat-widget.is-superminimized .aichat-messages,
.aichat-widget.is-superminimized .aichat-inputbar,
.aichat-widget.is-superminimized .aichat-tts-overlay{ display:none !important; }
.aichat-super-avatar{
  position:relative;
  width:60px; height:60px;
  border-radius:50%;
  background:#0073aa;
  display:flex; align-items:center; justify-content:center;
  color:#fff !important; font-weight:600; font-size:15px;
  box-shadow:0 4px 14px rgba(0,0,0,.25);
  cursor:pointer;
  user-select:none;
}
.aichat-super-avatar img{width:100%;height:100%;object-fit:cover;border-radius:50%;}
.aichat-widget.is-superminimized .aichat-super-avatar{display:flex;}
.aichat-widget:not(.is-superminimized) .aichat-super-avatar{display:none;}

/* Avatar speech bubble (child of .aichat-super-avatar which is position:relative) */
.aichat-avatar-bubble{
  position:absolute;
  display:flex;
  align-items:center;
  gap:6px;
  max-width:220px;
  width:max-content;
  padding:8px 28px 8px 12px;
  background:#fff;
  color:#333;
  font-size:13px;
  line-height:1.35;
  border-radius:10px;
  box-shadow:0 2px 12px rgba(0,0,0,.15);
  z-index:10;
  animation:aichat-bubble-in .3s ease;
  white-space:normal;
  word-break:break-word;
}
.aichat-avatar-bubble::after{
  content:'';
  position:absolute;
  width:0; height:0;
  border:7px solid transparent;
}
/* Right-side positions: bubble appears to the LEFT of avatar */
.pos-bottom-right .aichat-avatar-bubble,
.pos-top-right .aichat-avatar-bubble{
  right:calc(100% + 10px);
  top:50%;
  transform:translateY(-50%);
}
.pos-bottom-right .aichat-avatar-bubble::after,
.pos-top-right .aichat-avatar-bubble::after{
  left:100%;
  top:50%;
  transform:translateY(-50%);
  border-left-color:#fff;
  border-right-width:0;
}
/* Left-side positions: bubble appears to the RIGHT of avatar */
.pos-bottom-left .aichat-avatar-bubble,
.pos-top-left .aichat-avatar-bubble{
  left:calc(100% + 10px);
  top:50%;
  transform:translateY(-50%);
}
.pos-bottom-left .aichat-avatar-bubble::after,
.pos-top-left .aichat-avatar-bubble::after{
  right:100%;
  top:50%;
  transform:translateY(-50%);
  border-right-color:#fff;
  border-left-width:0;
}
.aichat-avatar-bubble-close{
  position:absolute;
  top:2px; right:4px;
  background:none;
  border:none;
  color:#999;
  font-size:16px;
  line-height:1;
  cursor:pointer;
  padding:2px 4px;
}
.aichat-avatar-bubble-close:hover{ color:#333; }
.aichat-widget:not(.is-superminimized) .aichat-avatar-bubble{ display:none !important; }
@keyframes aichat-bubble-in{
  0%{ opacity:0; transform:translateY(-50%) scale(.85); }
  100%{ opacity:1; transform:translateY(-50%) scale(1); }
}

/* Arrastre */
.aichat-widget.is-global.is-draggable .aichat-header{ cursor: move; }
.aichat-widget.dragging{ opacity: .96; box-shadow: 0 10px 28px rgba(0,0,0,.18); }

/* Responsive */
@media (max-width: 600px) {
  .aichat-widget.is-global {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
    max-width: none;
  }
  .aichat-widget.is-global .aichat-messages {
    height: 46vh;
    min-height: 260px;
  }
}

/* Scrollbar suave (WebKit) */
.aichat-messages::-webkit-scrollbar { width: 10px; }
.aichat-messages::-webkit-scrollbar-track { background: #f1f1f1; }
.aichat-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 10px; }
.aichat-messages::-webkit-scrollbar-thumb:hover { background: #ccc; }

/* Toggle iconos mic */
.aichat-inputbar .aichat-mic .icon-stop { display: none; }
.aichat-inputbar .aichat-mic.is-recording .icon-mic { display: none !important; }
.aichat-inputbar .aichat-mic.is-recording .icon-stop { display: inline-block !important; }

/* Overlay TTS centrado */
.aichat-tts-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(1px);
  z-index: 5; /* por encima de la inputbar */
}
.aichat-tts-overlay.show { display: flex; }
.aichat-tts-overlay-btn {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 0;
  background: #c62828;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0,0,0,.25);
  cursor: pointer;
}
.aichat-tts-overlay-btn:hover { filter: brightness(.95); }
.aichat-tts-overlay-btn svg { width: 24px; height: 24px; }

.aichat-gdpr-overlay{ position:absolute; inset:0; background:rgba(0,0,0,.6); display:flex; align-items:center; justify-content:center; z-index:20; font-family:inherit; padding:1rem; } .aichat-gdpr-box{ background:#fff; color:#222; border-radius:8px; padding:1rem 1.25rem; max-width:320px; width:100%; box-shadow:0 4px 16px rgba(0,0,0,.25); font-size:14px; line-height:1.4; } .aichat-gdpr-box .aichat-gdpr-text{margin-bottom:.75rem;} .aichat-gdpr-box .aichat-gdpr-accept{ background:#0073aa; color:#fff; border:0; padding:.5rem .9rem; border-radius:4px; cursor:pointer; font-size:14px; } .aichat-gdpr-box .aichat-gdpr-accept:hover{background:#005f8a;}

.aichat-gdpr-consent{
  width: 100%;
  margin: 8px 0;
  padding: 12px 14px;
  background: #1f2937 !important;
  color: #fff !important;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.aichat-gdpr-consent .aichat-gdpr-text{
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.45;
  color: #fff !important;
}
.aichat-gdpr-consent .aichat-gdpr-actions{ display: flex; align-items: center; justify-content: center; }
.aichat-gdpr-consent .aichat-gdpr-accept{
  background:#0073aa !important;
  color:#fff !important;
  border:0 !important;
  padding:8px 16px;
  border-radius:8px;
  cursor:pointer;
  font-size:14px;
  font-weight:600;
}
.aichat-gdpr-consent .aichat-gdpr-accept:hover{ filter: brightness(.95); }
.aichat-gdpr-consent a{ color:#93c9ff !important; text-decoration: underline; }

.aichat-gdpr-emailform .aichat-gdpr-text{ text-align: left; }
.aichat-gdpr-emailform .aichat-gdpr-text h1,
.aichat-gdpr-emailform .aichat-gdpr-text h2,
.aichat-gdpr-emailform .aichat-gdpr-text h3 { font-size: 1em !important; font-weight: 700; margin: 0 0 6px !important; color: #fff !important; }
.aichat-gdpr-emailform .aichat-gdpr-text p  { margin: 0 0 8px !important; font-size: 13px; color: #e0e0e0 !important; }
.aichat-gdpr-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.aichat-gdpr-field {
  width: 100% !important;
  padding: 9px 11px !important;
  border: 1px solid rgba(255,255,255,.25) !important;
  border-radius: 8px !important;
  background: rgba(255,255,255,.1) !important;
  color: #fff !important;
  font-size: 14px !important;
  font-family: inherit !important;
  outline: none !important;
  box-sizing: border-box !important;
  transition: border-color .15s;
}
.aichat-gdpr-field::placeholder { color: rgba(255,255,255,.5) !important; }
.aichat-gdpr-field:focus { border-color: rgba(255,255,255,.6) !important; background: rgba(255,255,255,.15) !important; }
.aichat-gdpr-error { color: #ffb3b3 !important; font-size: 12px; padding: 2px 0; display: none; }
.aichat-gdpr-emailform .aichat-gdpr-accept { width: 100% !important; margin-top: 2px; }

/* ── Inline Lead Form (show_form tool) ── */
.aichat-lead-form { padding: 12px 14px !important; background: #1f2937 !important; color: #fff !important; border-radius: 10px !important; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.aichat-lf-inner { display: flex; flex-direction: column; gap: 8px; }
.aichat-lf-label {
  display: block;
  font-size: 12px !important;
  font-weight: 600;
  margin: 4px 0 2px !important;
  color: #fff !important;
}
.aichat-lf-req { color: #ff9b9b; }
.aichat-lf-field {
  width: 100% !important;
  padding: 9px 11px !important;
  border: 1px solid rgba(255,255,255,.25) !important;
  border-radius: 8px !important;
  background: rgba(255,255,255,.1) !important;
  color: #fff !important;
  font-size: 14px !important;
  font-family: inherit !important;
  outline: none !important;
  box-sizing: border-box !important;
  transition: border-color .15s;
}
.aichat-lf-field::placeholder { color: rgba(255,255,255,.5) !important; }
.aichat-lf-field:focus { border-color: rgba(255,255,255,.6) !important; background: rgba(255,255,255,.15) !important; }
.aichat-lf-field.aichat-lf-invalid { border-color: #ff9b9b !important; }
textarea.aichat-lf-field { resize: vertical; min-height: 48px; }
.aichat-lf-error { color: #ffb3b3 !important; font-size: 12px; padding: 2px 0; }
.aichat-lf-actions { margin-top: 4px; }
.aichat-lf-submit {
  width: 100%;
  padding: 8px 16px !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: #0073aa !important;
  color: #fff !important;
  font-size: 14px !important;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s;
}
.aichat-lf-submit:hover { filter: brightness(.95); }
.aichat-lf-submit:disabled { opacity: .5; cursor: default; }
.aichat-lf-success-msg {
  text-align: center;
  padding: 16px 12px;
  font-size: 14px;
  font-weight: 500;
  color: #fff !important;
  line-height: 1.5;
}
.aichat-lf-check { font-style: normal; font-size: 18px; color: #4ade80; margin-right: 6px; }
.aichat-lf-header { margin-bottom: 8px; line-height: 1.4; }
.aichat-lf-header h3 { font-size: 15px !important; margin: 0 0 4px !important; color: #fff !important; }
.aichat-lf-header p { font-size: 12px !important; margin: 0 !important; color: rgba(255,255,255,.7) !important; }
.aichat-lf-compact .aichat-lf-inner { gap: 6px; }
.aichat-lf-compact .aichat-lf-field { padding: 7px 10px !important; font-size: 13px !important; }

/* Enlace compacto estilizado para Google Calendar (prettified server-side) */
.aichat-gcal-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  background: #e8f0fe;       /* azul muy claro */
  color: #1a73e8;            /* azul Google-like */
  text-decoration: none;
  font-weight: 600;
}
.aichat-gcal-link:hover {
  filter: brightness(.97);
  text-decoration: underline;
}

/* ===== Widget Footer ===== */
.aichat-footer {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 4px;
  padding: 6px 10px !important;
  font-size: 11px !important;
  color: #888 !important;
  background: #fafafa !important;
  border-top: 1px solid #eee;
  visibility: visible !important;
  opacity: 1 !important;
  height: auto !important;
  min-height: 20px !important;
  overflow: visible !important;
  position: relative !important;
  clip: auto !important;
  clip-path: none !important;
  transform: none !important;
  pointer-events: auto !important;
}
.aichat-footer a {
  color: #555 !important;
  text-decoration: none;
  font-weight: 600;
}
.aichat-footer a:hover {
  text-decoration: underline;
}
.aichat-footer-icon {
  font-size: 12px;
}
/* Hide footer when minimized (legitimate) */
.aichat-inner.is-minimized .aichat-footer { display: none !important; }
.aichat-widget.is-superminimized .aichat-footer { display: none !important; }

/* ===== WhatsApp / Channels bar ===== */
.aichat-channels-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  background: #f8f9fa;
  border-top: 1px solid #eee;
}
.aichat-wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  background: var(--wa-bg, #ffffff);
  border: 1px solid #d4edda;
  color: var(--wa-ic, #25D366) !important;
  text-decoration: none !important;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  transition: box-shadow .2s, transform .15s, background .2s;
}
.aichat-wa-btn:hover {
  box-shadow: 0 2px 8px rgba(37,211,102,.25);
  transform: translateY(-1px);
  background: #e8fbe8;
}
.aichat-wa-btn:active {
  transform: translateY(0);
}
.aichat-wa-icon {
  flex-shrink: 0;
}
.aichat-wa-icon path {
  fill: var(--wa-ic, #25D366);
}
.aichat-wa-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
/* Disabled / offline state */
.aichat-wa-btn.wa-disabled {
  opacity: .5;
  cursor: default;
  pointer-events: none;
}
.aichat-channels-bar.wa-offline {
  background: #fff8f0;
  border-top-color: #fde2c8;
}
.aichat-wa-offline-label {
  font-size: 11px;
  color: #b00;
  font-style: italic;
}
/* Hide when minimized */
.aichat-inner.is-minimized .aichat-channels-bar { display: none; }
.aichat-widget.is-superminimized .aichat-channels-bar { display: none; }
/* CSS-forced overrides */
.aichat-widget.css-forced .aichat-channels-bar { font-size: 12px !important; }
.aichat-widget.css-forced .aichat-wa-btn { font-size: 12px !important; }

/* Cost-limit message shown above WhatsApp bar */
.aichat-cost-limit-msg {
  padding: 12px 16px;
  text-align: center;
  font-size: 0.9em;
  color: #666;
}

/* ──────────────────────────────────────
   File-upload attach button & chip
   ────────────────────────────────────── */
.aichat-attach {
  padding: 0 !important;
  width: 36px; min-width: 36px;
  height: calc(var(--aichat-bar-h) - 2 * var(--aichat-bar-py));
  display: inline-flex; align-items: center; justify-content: center;
  border: 0;
  border-radius: 8px;
  background: #f1f3f5;
  color: #555;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}
.aichat-attach:hover { background: #e2e6ea; }
.aichat-attach svg { width: 20px; height: 20px; pointer-events: none; }
.aichat-attach-input { display: none !important; }
/* File chip above the inputbar */
.aichat-file-chip-bar {
  display: none; /* shown via JS when file attached */
  padding: 4px var(--aichat-bar-px);
  background: #f9f9f9;
  border-top: 1px solid #eee;
}
.aichat-file-chip-bar.has-file { display: flex; align-items: center; gap: 6px; }
.aichat-file-chip {
  display: inline-flex; align-items: center; gap: 4px;
  max-width: 100%;
  padding: 3px 10px 3px 8px;
  background: #e8f0fe;
  border-radius: 12px;
  font-size: 12px;
  color: #1a73e8;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.aichat-file-chip .aichat-file-chip-icon {
  flex-shrink: 0; width: 14px; height: 14px;
}
.aichat-file-chip-remove {
  margin-left: auto; flex-shrink: 0;
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; padding: 0;
  cursor: pointer; color: #666; font-size: 14px; line-height: 1;
  border-radius: 50%;
}
.aichat-file-chip-remove:hover { background: rgba(0,0,0,.08); color: #333; }
/* Uploading state */
.aichat-attach.is-uploading {
  opacity: .55; pointer-events: none;
}
.aichat-file-chip.is-uploading {
  opacity: .6;
}
.aichat-file-chip.is-uploading::after {
  content: ''; display: inline-block;
  width: 12px; height: 12px; margin-left: 6px;
  border: 2px solid #1a73e8; border-top-color: transparent;
  border-radius: 50%;
  animation: aichat-spin .7s linear infinite;
}
@keyframes aichat-spin { to { transform: rotate(360deg); } }
/* CSS-forced overrides */
.aichat-widget.css-forced .aichat-attach { font-size: 16px !important; }
.aichat-widget.css-forced .aichat-file-chip { font-size: 12px !important; }

/* ── File attachment inside message bubbles ── */
.aichat-msg-file {
  margin-bottom: 6px;
}
.aichat-msg-file--image .aichat-msg-file-thumb {
  max-width: 180px;
  max-height: 140px;
  border-radius: 8px;
  display: block;
  object-fit: cover;
}
.aichat-msg-file--pdf {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(255,255,255,.65);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.3;
  color: inherit;
  opacity: .85;
}
.aichat-msg-file-icon {
  width: 16px; height: 16px; flex-shrink: 0; opacity: .7;
}
.aichat-msg-file-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}
.user-message.has-file-attachment {
  display: flex;
  flex-direction: column;
}
/* CSS-forced overrides for message file attachments */
.aichat-widget.css-forced .aichat-msg-file-thumb { max-width: 180px !important; max-height: 140px !important; }
.aichat-widget.css-forced .aichat-msg-file--pdf { font-size: 12px !important; }
