/* =========================================================================
   hana.css — Widget de chat Hana
   Extraido del inline styles de _hana_widget_v3.html
   Paleta vinculada al sistema de tokens --t-* definido en core.css
   ========================================================================= */

.hana {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 99999;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Boton toggle (FAB) */
.hana__toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--t-primary);
  color: #fff;
  font-size: 1.6rem;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform var(--t-base) var(--ease);
}
.hana__toggle:hover { transform: scale(1.08); }
.hana__toggle:focus-visible {
  outline: 3px solid rgba(124, 92, 255, .5);
  outline-offset: 2px;
}

.hana__unread {
  display: none;
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--t-danger);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.hana__unread.is-visible { display: inline-flex; }

/* Panel principal */
.hana__panel {
  display: none;
  position: fixed;
  right: 1rem;
  bottom: 5rem;
  width: 340px;
  max-width: calc(100vw - 2rem);
  height: 520px;
  max-height: calc(100vh - 7rem);
  background: var(--t-panel);
  color: var(--t-text);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
  flex-direction: column;
  overflow: hidden;
}
.hana__panel.is-open { display: flex; }

@media (max-width: 480px) {
  .hana__panel.is-open {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    right: 0;
    bottom: 0;
    border-radius: 0;
  }
}

/* Header del panel */
.hana__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-4);
  background: var(--t-panel-2);
  border-bottom: 1px solid var(--t-line);
  cursor: move;
  user-select: none;
}
.hana__title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.hana__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--t-primary), var(--t-accent2));
  font-size: 1rem;
}
.hana__name { font-weight: 600; font-size: var(--fs-sm); color: #fff; }
.hana__status { font-size: var(--fs-xs); color: var(--t-success); }
.hana__status::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--t-success);
  margin-right: 4px;
}
.hana__close {
  background: none;
  border: none;
  color: var(--t-text-2);
  font-size: 1.2rem;
  cursor: pointer;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
}
.hana__close:hover { color: #fff; background: var(--t-line); }

/* Cuerpo (mensajes) */
.hana__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.hana__msg {
  max-width: 85%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  line-height: 1.4;
  word-wrap: break-word;
}
.hana__msg--bot {
  background: var(--t-panel-2);
  color: var(--t-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.hana__msg--user {
  background: var(--t-primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.hana__msg--typing { color: var(--t-text-2); font-style: italic; }

/* Typing indicator */
.hana__typing {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  padding: var(--sp-2) var(--sp-3);
}
.hana__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--t-text-2);
  animation: hana-bounce 1.4s infinite;
}
.hana__typing span:nth-child(2) { animation-delay: .2s; }
.hana__typing span:nth-child(3) { animation-delay: .4s; }
@keyframes hana-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Botones de sugerencia (quick replies) */
.hana__quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  padding: var(--sp-1) 0;
}
.hana__quick {
  padding: var(--sp-1) var(--sp-3);
  background: rgba(124, 92, 255, .15);
  border: 1px solid rgba(124, 92, 255, .4);
  color: var(--t-primary);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.hana__quick:hover { background: rgba(124, 92, 255, .3); }

/* Form de input */
.hana__form {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--t-line);
  background: var(--t-panel);
}
.hana__input {
  flex: 1;
  padding: var(--sp-2) var(--sp-3);
  background: var(--t-panel-2);
  border: 1px solid var(--t-line);
  border-radius: var(--r-md);
  color: var(--t-text);
  font-family: inherit;
  font-size: var(--fs-sm);
}
.hana__input:focus {
  outline: none;
  border-color: var(--t-primary);
}
.hana__send {
  padding: var(--sp-2) var(--sp-4);
  background: var(--t-primary);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.hana__send:hover { background: var(--t-primary-2); }
.hana__send:disabled { opacity: .5; cursor: not-allowed; }

/* Proactive bubble (popup despues de N segundos)
   Fondo panel elevado para encajar con el tema oscuro por defecto del sitio. */
.hana__proactive {
  display: none;
  position: absolute;
  right: 0;
  bottom: 70px;
  background: var(--t-panel-2);
  color: var(--t-text);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  max-width: 240px;
  font-size: var(--fs-sm);
  line-height: 1.4;
  cursor: pointer;
  animation: hana-slideup .3s var(--ease);
}
.hana__proactive.is-visible { display: block; }
@keyframes hana-slideup {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.hana__proactive-close {
  position: absolute;
  top: 4px;
  right: 6px;
  background: none;
  border: none;
  color: var(--t-text-3);
  font-size: .9rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.hana__ts {
  display: block;
  font-size: var(--fs-xs);
  color: var(--t-text-3);
  margin-top: var(--sp-1);
  opacity: .7;
}
.hana__msg-wrap.bot .hana__ts { padding-left: var(--sp-1); }
.hana__msg-wrap.user .hana__ts { text-align: right; }
