/* Intetron Chat Bot (Lite) - Modern UX */
:root{
  --itcb-bg: #0b1220;
  --itcb-surface: rgba(255,255,255,.08);
  --itcb-surface-2: rgba(255,255,255,.12);
  --itcb-border: rgba(255,255,255,.14);
  --itcb-text: rgba(255,255,255,.92);
  --itcb-text-dim: rgba(255,255,255,.72);

  --itcb-primary: #2563eb;       /* blue-600 */
  --itcb-primary-2: #1d4ed8;     /* blue-700 */
  --itcb-accent: #22c55e;        /* green-500 */
  --itcb-warn: #f59e0b;          /* amber-500 */

  --itcb-shadow: 0 18px 60px rgba(0,0,0,.45);
  --itcb-radius: 16px;
  --itcb-radius-sm: 12px;

  --itcb-font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

/* Root wrapper */
.itcb-front{
  font-family: var(--itcb-font);
  color: var(--itcb-text);
}

.itcb-front--floating{
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 2147483647;
}

/* Floating action button */
.itcb-fab{
  width: 58px;
  height: 58px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  cursor: pointer;
  color: #fff;
  font-weight: 700;
  letter-spacing: .2px;
  background: radial-gradient(120% 120% at 20% 10%, #60a5fa 0%, #2563eb 35%, #1e40af 100%);
  box-shadow: 0 14px 40px rgba(37,99,235,.35), 0 10px 26px rgba(0,0,0,.35);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  user-select: none;
}

.itcb-fab:hover{
  transform: translateY(-1px);
  filter: saturate(1.05);
  box-shadow: 0 18px 55px rgba(37,99,235,.40), 0 12px 30px rgba(0,0,0,.38);
}

.itcb-fab:active{
  transform: translateY(0);
}

/* Panel */
.itcb-panel{
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 360px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - 120px);
  border-radius: var(--itcb-radius);
  overflow: hidden;

  background:
    radial-gradient(120% 120% at 20% 0%, rgba(96,165,250,.18) 0%, rgba(37,99,235,.10) 35%, rgba(11,18,32,.92) 100%),
    linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border: 1px solid var(--itcb-border);
  box-shadow: var(--itcb-shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  transform-origin: bottom right;
  transition: transform .14s ease, opacity .14s ease;
}

.itcb-panel--hidden{
  opacity: 0;
  transform: scale(.96);
  pointer-events: none;
}

/* Header */
.itcb-front__header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px;
  background: linear-gradient(135deg, rgba(37,99,235,.55), rgba(29,78,216,.30));
  border-bottom: 1px solid rgba(255,255,255,.16);
}

.itcb-front__title{
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .2px;
}

.itcb-close{
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.20);
  color: #fff;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}

.itcb-close:hover{
  background: rgba(0,0,0,.28);
  transform: translateY(-1px);
}

.itcb-close:active{
  transform: translateY(0);
}

/* Chat area layout */
.itcb-chat{
  display: flex;
  flex-direction: column;
  height: calc(100% - 0px);
}

.itcb-chat__messages{
  flex: 1;
  padding: 14px 12px;
  overflow: auto;
  scroll-behavior: smooth;
}

/* Nice scrollbar (webkit) */
.itcb-chat__messages::-webkit-scrollbar{ width: 10px; }
.itcb-chat__messages::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.14);
  border-radius: 999px;
  border: 2px solid rgba(0,0,0,.0);
  background-clip: padding-box;
}
.itcb-chat__messages::-webkit-scrollbar-thumb:hover{
  background: rgba(255,255,255,.20);
  background-clip: padding-box;
}

/* Message bubbles */
.itcb-msg{
  max-width: 84%;
  padding: 10px 12px;
  border-radius: 14px;
  margin: 8px 0;
  line-height: 1.35;
  font-size: 13.5px;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  word-wrap: break-word;
  white-space: normal;
}

.itcb-msg--bot{
  background: rgba(255,255,255,.08);
  color: var(--itcb-text);
  border-top-left-radius: 8px;
}

.itcb-msg--user{
  margin-left: auto;
  background: linear-gradient(135deg, rgba(37,99,235,.95), rgba(29,78,216,.85));
  border-color: rgba(255,255,255,.18);
  border-top-right-radius: 8px;
}

/* Buttons under bot messages */
.itcb-buttons{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px 0;
  padding-left: 2px;
}

.itcb-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.10);
  color: var(--itcb-text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1px;
  text-decoration: none;

  transition: transform .12s ease, background .12s ease, border-color .12s ease, box-shadow .12s ease;
  box-shadow: 0 8px 22px rgba(0,0,0,.18);
}

.itcb-btn:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.22);
}

.itcb-btn:active{
  transform: translateY(0);
}

.itcb-btn[disabled]{
  opacity: .65;
  cursor: not-allowed;
}

.itcb-btn:focus-visible,
.itcb-chat__btn:focus-visible,
.itcb-close:focus-visible,
.itcb-fab:focus-visible,
.itcb-chat__input:focus-visible{
  outline: 2px solid rgba(96,165,250,.95);
  outline-offset: 2px;
}

/* Input zone */
.itcb-chat__form{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.22);
}

.itcb-chat__input{
  width: 100%;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.16);
  padding: 0 12px;
  background: rgba(255,255,255,.06);
  color: var(--itcb-text);
  font-size: 14px;
}

.itcb-chat__input::placeholder{
  color: rgba(255,255,255,.55);
}

.itcb-chat__btn{
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.18);
  background: linear-gradient(135deg, rgba(34,197,94,.95), rgba(16,185,129,.90));
  color: #06210f;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: .2px;
  box-shadow: 0 12px 30px rgba(34,197,94,.18);
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}

.itcb-chat__btn:hover{
  transform: translateY(-1px);
  filter: saturate(1.05);
  box-shadow: 0 16px 38px rgba(34,197,94,.22);
}

.itcb-chat__btn:active{ transform: translateY(0); }

.itcb-chat__status{
  padding: 0 12px 10px 12px;
  font-size: 12px;
  color: var(--itcb-text-dim);
  min-height: 18px;
}

/* Responsive: mobile full height-ish */
@media (max-width: 420px){
  .itcb-front--floating{
    right: 12px;
    bottom: 12px;
  }

  .itcb-panel{
    width: min(420px, calc(100vw - 16px));
    height: min(640px, calc(100vh - 120px));
    bottom: 70px;
  }

  .itcb-fab{
    width: 56px;
    height: 56px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  .itcb-panel, .itcb-fab, .itcb-btn, .itcb-chat__btn, .itcb-close{
    transition: none !important;
  }
}

/* Links inside messages */
.itcb-msg a{
  color: #93c5fd;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.itcb-msg a:hover{
  color: #bfdbfe;
}

/* Typing indicator bubble */
.itcb-typing{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 14px;
  border-top-left-radius: 8px;
  margin: 8px 0;
  max-width: 70%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  color: rgba(255,255,255,.80);
  font-size: 13.5px;
}

.itcb-dots{
  display: inline-flex;
  gap: 4px;
}

.itcb-dot{
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.75);
  animation: itcb-bounce 1.05s infinite ease-in-out;
}

.itcb-dot:nth-child(2){ animation-delay: .12s; opacity: .85; }
.itcb-dot:nth-child(3){ animation-delay: .24s; opacity: .75; }

@keyframes itcb-bounce{
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5px); }
}

/* --- Mobile UX fixes (Android/iOS) --- */

/* Asegura que el widget siempre quede sobre el sitio */
.itcb-front {
  position: fixed;
  z-index: 2147483000;
}

/* Botón flotante: evita que se corte */
.itcb-fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 2147483001;
}

/* Panel: tamaño responsivo y sin desbordarse */
.itcb-panel {
  position: fixed;
  right: 16px;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px)); /* deja espacio para el FAB */
  width: min(420px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);

  /* alto razonable en móvil, evita fullscreen */
  height: min(640px, 80vh);
  max-height: calc(100vh - 120px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));

  border-radius: 16px;
  overflow: hidden; /* evita que el contenido se salga */
}

/* Layout interno: header + body con scroll */
.itcb-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0; /* clave para que el scroll funcione */
}

.itcb-front__header {
  flex: 0 0 auto;
}

.itcb-chat__messages {
  flex: 1 1 auto;
  min-height: 0;          /* clave */
  overflow-y: auto;       /* scroll interno */
  -webkit-overflow-scrolling: touch;
}

.itcb-chat__form,
.itcb-chat__status {
  flex: 0 0 auto;
}

/* En pantallas pequeñas, ajusta márgenes */
@media (max-width: 480px) {
  .itcb-panel {
    right: 12px;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    width: calc(100vw - 24px);
    height: min(620px, 78vh);
    border-radius: 14px;
  }

  .itcb-fab {
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

.flatpickr-calendar {
  z-index: 2147483647 !important;
}