/* ============================================================
   ComboWeb - Estilos del Chatbot y Panel /config
   Reutiliza las variables de color de styles.css
   ============================================================ */

/* ---------- Cursores (puntero "manita" + caret de texto) ---------- */
a,
button,
[role="button"],
.btn,
.cw-mode,
.cw-send,
.cw-fab-btn,
.cw-panel-close,
.cfg-tab,
.cfg-chat-item,
.cfg-link-row .rm,
summary,
label.option,
.option,
select {
  cursor: pointer;
}

input,
textarea,
[contenteditable] {
  cursor: text;
  caret-color: var(--fire-2);   /* cursor de escritura bien visible (naranja) */
}

button:disabled,
.btn:disabled,
.cw-send:disabled {
  cursor: not-allowed;
}

/* ---------- Layout base full-screen del chatbot ---------- */
.cw-chat-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(600px 600px at 85% -10%, rgba(255,59,31,.18), transparent 60%),
    radial-gradient(700px 700px at -10% 110%, rgba(255,122,26,.14), transparent 60%),
    var(--bg-0);
}

/* ---------- Encabezado del chat ---------- */
.cw-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(10,10,15,.6);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.cw-top .brand { font-size: 1.05rem; }
.cw-top-actions { display: flex; gap: 10px; align-items: center; }
.cw-status { display: flex; align-items: center; gap: 7px; font-size: .8rem; color: var(--text-mute); }
.cw-dot { width: 8px; height: 8px; border-radius: 50%; background: #2ecc71; box-shadow: 0 0 10px #2ecc71; }

/* ---------- Pantallas (gate de nombre / modo) ---------- */
.cw-gate {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 40px 20px;
}
.cw-gate-card {
  width: 100%;
  max-width: 620px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 42px 38px;
  box-shadow: var(--shadow-card);
  text-align: center;
  animation: cw-rise .5s cubic-bezier(.2,.7,.3,1);
}
@keyframes cw-rise { from { opacity:0; transform: translateY(18px); } to { opacity:1; transform:none; } }
.cw-gate-card .eyebrow { margin-bottom: 22px; }
.cw-gate-card h2 { margin-bottom: 12px; }
.cw-gate-card .lead { color: var(--text-dim); font-size: 1.05rem; max-width: 460px; margin: 0 auto 26px; }
.cw-gate-card .field { text-align: left; max-width: 420px; margin: 0 auto 18px; }

.cw-mascot {
  width: 92px; height: 92px; margin: 0 auto 18px;
  filter: drop-shadow(0 10px 24px rgba(255,59,31,.45));
  animation: float 6s ease-in-out infinite;
}

/* ---------- Selector de modo (tarjetas) ---------- */
.cw-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 8px auto 4px;
  max-width: 520px;
}
@media (max-width: 560px) { .cw-modes { grid-template-columns: 1fr; } }
.cw-mode {
  border: 1px solid var(--border);
  background: var(--bg-3);
  border-radius: var(--radius);
  padding: 22px 18px;
  cursor: pointer;
  transition: transform .15s, border-color .15s, box-shadow .2s;
  text-align: center;
}
.cw-mode:hover { transform: translateY(-3px); border-color: var(--fire-2); box-shadow: var(--shadow-fire); }
.cw-mode-ico {
  width: 64px; height: 44px; margin: 0 auto 14px;
  border-radius: 8px;
  border: 1.5px solid var(--border-2);
  position: relative;
  background: var(--bg-1);
}
/* mini-ilustración full */
.cw-mode-ico.full::after {
  content: ""; position: absolute; inset: 6px;
  border-radius: 4px; background: var(--grad-fire-soft);
  border: 1px solid rgba(255,122,26,.4);
}
/* mini-ilustración floating */
.cw-mode-ico.float::after {
  content: ""; position: absolute; right: 6px; bottom: 6px;
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--grad-fire); box-shadow: var(--shadow-fire);
}
.cw-mode h4 { margin-bottom: 6px; font-size: 1.05rem; }
.cw-mode p { font-size: .85rem; color: var(--text-mute); line-height: 1.4; }

/* ---------- Ventana de conversación ---------- */
.cw-conv {
  flex: 1;
  min-height: 0;            /* permite que .cw-messages encoja y haga scroll */
  display: none;
  flex-direction: column;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px;
}
.cw-conv.active { display: flex; }
.cw-messages {
  flex: 1;
  min-height: 0;           /* clave para el scroll dentro del panel flotante */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 28px 4px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.cw-msg { display: flex; gap: 12px; max-width: 88%; animation: cw-rise .35s ease; }
.cw-msg .av {
  flex: none; width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; font-weight: 800; font-size: .85rem;
}
.cw-msg.bot .av { background: var(--grad-fire); color: #fff; box-shadow: var(--shadow-fire); }
.cw-msg.me { margin-left: auto; flex-direction: row-reverse; }
.cw-msg.me .av { background: var(--bg-3); border: 1px solid var(--border-2); color: var(--fire-1); }
.cw-bubble {
  padding: 13px 16px;
  border-radius: 14px;
  font-size: .97rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.cw-msg.bot .cw-bubble { background: var(--bg-2); border: 1px solid var(--border); border-top-left-radius: 4px; }
.cw-msg.me  .cw-bubble { background: var(--grad-fire-soft); border: 1px solid rgba(255,122,26,.35); border-top-right-radius: 4px; color: #fff; }
.cw-bubble a { color: var(--fire-1); text-decoration: underline; font-weight: 600; }

.cw-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.cw-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--fire-2); animation: cw-blink 1.2s infinite; }
.cw-typing span:nth-child(2){ animation-delay:.2s } .cw-typing span:nth-child(3){ animation-delay:.4s }
@keyframes cw-blink { 0%,60%,100%{ opacity:.25; transform:translateY(0) } 30%{ opacity:1; transform:translateY(-3px) } }

/* ---------- Barra de entrada ---------- */
.cw-input {
  position: sticky;
  bottom: 0;
  padding: 14px 4px 20px;
  background: linear-gradient(180deg, transparent, var(--bg-0) 30%);
}
.cw-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 8px 8px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.cw-input-row:focus-within { border-color: var(--fire-2); box-shadow: 0 0 0 3px rgba(255,122,26,.16); }
.cw-input-row textarea {
  flex: 1; background: transparent; border: none; color: var(--text);
  font: inherit; font-size: 1rem; resize: none; max-height: 140px; padding: 8px 0;
}
.cw-input-row textarea:focus { outline: none; }
.cw-send {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  background: var(--grad-fire); display: grid; place-items: center;
  box-shadow: var(--shadow-fire); transition: transform .15s;
}
.cw-send:hover { transform: scale(1.06); }
.cw-send:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.cw-send svg { width: 20px; height: 20px; stroke: #fff; }

/* ============================================================
   MODO FLOTANTE
   ============================================================ */
.cw-float-bg {
  display: none;
  min-height: 100vh; min-height: 100dvh;
  place-items: center;
  text-align: center;
  padding: 40px 20px 120px;
}
.cw-float-bg.active { display: grid; }
.cw-float-bg .bg-brand {
  font-size: clamp(3rem, 12vw, 8rem);
  font-weight: 900;
  letter-spacing: -.03em;
  background: var(--grad-fire);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  line-height: 1;
}
.cw-rotator {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: clamp(1rem, 2.6vw, 1.5rem);
  color: var(--text-dim);
  min-height: 1.6em;
}
.cw-rotator b { color: var(--fire-1); }
.cw-cursor { color: var(--fire-2); animation: cw-caret 1s steps(2) infinite; }
@keyframes cw-caret { 50% { opacity: 0; } }

/* Burbuja flotante abajo a la derecha */
.cw-fab {
  display: none;
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 60;
}
.cw-fab.active { display: block; }
.cw-fab-btn {
  width: 62px; height: 62px; border-radius: 50%;
  background: var(--grad-fire); box-shadow: var(--shadow-fire);
  display: grid; place-items: center;
  transition: transform .15s;
}
.cw-fab-btn:hover { transform: scale(1.07); }
.cw-fab-btn svg { width: 28px; height: 28px; }

.cw-panel {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 61;
  width: min(400px, calc(100vw - 32px));
  height: min(620px, calc(100dvh - 40px));
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: 20px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.8);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: cw-pop .25s cubic-bezier(.2,.8,.3,1);
}
.cw-panel.active { display: flex; }
@keyframes cw-pop { from { opacity:0; transform: translateY(24px) scale(.96); } to { opacity:1; transform:none; } }
.cw-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--grad-fire); color: #fff;
}
.cw-panel-head .ph-title { display: flex; align-items: center; gap: 9px; font-weight: 800; }
.cw-panel-head small { display: block; font-weight: 500; opacity: .9; font-size: .72rem; }
.cw-panel-close { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; }
.cw-panel-close:hover { background: rgba(255,255,255,.18); }
.cw-panel .cw-messages { padding: 18px 14px; }
.cw-panel .cw-input { padding: 10px; background: var(--bg-1); }
.cw-panel .cw-msg { max-width: 92%; }

/* En modo flotante, la conversación principal vive dentro del panel */
.cw-conv.in-panel { max-width: none; padding: 0; }

/* ============================================================
   PANEL /config
   ============================================================ */
.cfg-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg-0); }
.cfg-wrap { width: 100%; max-width: 980px; margin: 0 auto; padding: 32px 20px 80px; }
.cfg-login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(600px 600px at 80% -10%, rgba(255,59,31,.16), transparent 60%),
    var(--bg-0);
}
.cfg-login-card {
  width: 100%; max-width: 420px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px 34px; box-shadow: var(--shadow-card);
}
.cfg-login-card .brand { justify-content: center; margin-bottom: 22px; }

.cfg-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 26px 26px; margin-bottom: 22px;
}
.cfg-card h3 { margin-bottom: 4px; }
.cfg-card .hint { color: var(--text-mute); font-size: .88rem; margin-bottom: 20px; }

.cfg-tabs { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.cfg-tab {
  padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: .9rem;
  border: 1px solid var(--border); color: var(--text-dim); background: var(--bg-2);
}
.cfg-tab.active { background: var(--grad-fire); color: #fff; border-color: transparent; box-shadow: var(--shadow-fire); }
.cfg-section { display: none; } .cfg-section.active { display: block; }

.cfg-link-row { display: flex; gap: 10px; margin-bottom: 10px; }
.cfg-link-row input { flex: 1; }
.cfg-link-row .rm { flex: none; width: 46px; border-radius: 10px; border: 1px solid var(--border); color: #ff6b5b; }
.cfg-link-row .rm:hover { border-color: #ff6b5b; }

.cfg-flash {
  padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: .9rem; font-weight: 600;
  background: rgba(46,204,113,.12); border: 1px solid rgba(46,204,113,.4); color: #6ee7a8;
}
.cfg-flash.err { background: rgba(255,59,31,.12); border-color: rgba(255,59,31,.4); color: #ff8b7a; }

/* Lista de chats */
.cfg-chats { display: grid; grid-template-columns: 300px 1fr; gap: 18px; }
@media (max-width: 760px) { .cfg-chats { grid-template-columns: 1fr; } }
.cfg-chat-list { display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow-y: auto; }
.cfg-chat-item {
  text-align: left; padding: 13px 15px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg-3); transition: border-color .15s;
}
.cfg-chat-item:hover { border-color: var(--fire-2); }
.cfg-chat-item.active { border-color: var(--fire-2); background: var(--grad-fire-soft); }
.cfg-chat-item strong { display: block; font-size: .95rem; }
.cfg-chat-item span { font-size: .78rem; color: var(--text-mute); }
.cfg-chat-item .badge {
  font-size: .68rem; padding: 2px 8px; border-radius: 99px; font-weight: 700;
  background: rgba(255,122,26,.15); color: var(--fire-1); border: 1px solid rgba(255,122,26,.3);
}
.cfg-chat-detail {
  border: 1px solid var(--border); border-radius: 14px; background: var(--bg-1);
  padding: 18px; max-height: 70vh; overflow-y: auto;
}
.cfg-empty { color: var(--text-mute); text-align: center; padding: 40px 0; }

@media (max-width: 880px) {
  .cw-conv, .cfg-wrap { padding-left: 12px; padding-right: 12px; }
}
