/* =============================================================
   StageHub — AI chat asistent (plávajúca bublina)
   Načíta sa po tokens.css; využíva teplú paletu (jantárová, krém).
   Žiadny inline style. Panel je svetlý v štýle webu.
   ============================================================= */

.sh-chat {
  position: fixed;
  right: clamp(var(--sh-space-4), 3vw, var(--sh-space-8));
  bottom: clamp(var(--sh-space-4), 3vw, var(--sh-space-8));
  z-index: 1000;
  font-family: var(--sh-font-body);
}

/* ---------- Plávajúce tlačidlo (bublina) ---------- */
.sh-chat-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: var(--sh-radius-pill);
  background: var(--sh-amber);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--sh-shadow-amber), var(--sh-shadow-md);
  transition: transform var(--sh-transition), background var(--sh-transition);
}
.sh-chat-toggle:hover { background: var(--sh-amber-hover); transform: translateY(-2px); }
.sh-chat-toggle svg { width: 28px; height: 28px; display: block; }
.sh-chat-toggle .sh-chat-ic-close { display: none; }
.sh-chat.is-open .sh-chat-toggle .sh-chat-ic-open { display: none; }
.sh-chat.is-open .sh-chat-toggle .sh-chat-ic-close { display: block; }

/* ---------- Panel ---------- */
.sh-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(60px + var(--sh-space-3));
  width: min(380px, calc(100vw - 2 * var(--sh-space-4)));
  height: min(560px, calc(100vh - 2 * var(--sh-space-8) - 60px));
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--sh-cream-2);
  border: 1px solid var(--sh-ink-12);
  border-radius: var(--sh-radius-lg);
  box-shadow: var(--sh-shadow-lg);
}
.sh-chat.is-open .sh-chat-panel { display: flex; }

.sh-chat-head {
  display: flex;
  align-items: center;
  gap: var(--sh-space-3);
  padding: var(--sh-space-4) var(--sh-space-5);
  background: var(--sh-ink);
  color: var(--sh-cream-2);
}
.sh-chat-head-title { font-family: var(--sh-font-head); font-weight: var(--sh-weight-semibold); font-size: var(--sh-text-lg); margin: 0; }
.sh-chat-head-sub { font-size: var(--sh-text-xs); color: rgba(253, 243, 234, 0.75); margin: 2px 0 0; }
.sh-chat-close {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border: none; border-radius: var(--sh-radius-pill);
  background: rgba(253, 243, 234, 0.12);
  color: var(--sh-cream-2);
  cursor: pointer;
  font-size: 20px; line-height: 1;
  transition: background var(--sh-transition);
}
.sh-chat-close:hover { background: rgba(253, 243, 234, 0.24); }

/* ---------- Správy ---------- */
.sh-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: var(--sh-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--sh-space-3);
  background: var(--sh-cream-3);
}
.sh-chat-msg {
  max-width: 85%;
  padding: var(--sh-space-3) var(--sh-space-4);
  border-radius: var(--sh-radius-md);
  font-size: var(--sh-text-sm);
  line-height: var(--sh-leading-normal);
  white-space: pre-wrap;
  word-break: break-word;
}
.sh-chat-msg-bot {
  align-self: flex-start;
  background: var(--sh-surface-raised);
  border: 1px solid var(--sh-ink-12);
  color: var(--sh-ink);
}
.sh-chat-msg-user {
  align-self: flex-end;
  background: var(--sh-ink);
  color: var(--sh-cream-2);
}
.sh-chat-msg-error {
  align-self: center;
  background: color-mix(in srgb, var(--sh-coral) 18%, var(--sh-cream-2));
  border: 1px solid var(--sh-coral);
  color: #7a1f1a;
  font-size: var(--sh-text-xs);
  text-align: center;
  max-width: 100%;
}

/* Indikátor „píše…" */
.sh-chat-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: var(--sh-space-3) var(--sh-space-4); }
.sh-chat-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--sh-amber-text);
  opacity: 0.4;
  animation: sh-chat-blink 1.2s infinite ease-in-out;
}
.sh-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.sh-chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sh-chat-blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sh-chat-typing span { animation: none; } }

/* ---------- Zápätie / vstup ---------- */
.sh-chat-foot {
  border-top: 1px solid var(--sh-ink-12);
  padding: var(--sh-space-3) var(--sh-space-4) var(--sh-space-4);
  background: var(--sh-cream-2);
}
.sh-chat-form { display: flex; gap: var(--sh-space-2); align-items: flex-end; }
.sh-chat-input {
  flex: 1;
  resize: none;
  font-family: var(--sh-font-body);
  font-size: var(--sh-text-sm);
  line-height: var(--sh-leading-snug);
  max-height: 96px;
  overflow-y: auto;
  padding: var(--sh-space-3);
  border: 1px solid var(--sh-ink-12);
  border-radius: var(--sh-radius-md);
  background: var(--sh-cream-3);
  color: var(--sh-ink);
}
.sh-chat-input:focus { outline: 2px solid var(--sh-amber); outline-offset: -1px; }
.sh-chat-input:disabled { opacity: 0.6; cursor: not-allowed; }
.sh-chat-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  flex: none;
  border: none;
  border-radius: var(--sh-radius-md);
  background: var(--sh-amber);
  color: #fff;
  cursor: pointer;
  transition: background var(--sh-transition);
}
.sh-chat-send:hover:not(:disabled) { background: var(--sh-amber-hover); }
.sh-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
.sh-chat-send svg { width: 20px; height: 20px; }
.sh-chat-meta {
  margin: var(--sh-space-2) 0 0;
  font-size: var(--sh-text-xs);
  color: var(--sh-ink-50);
  text-align: right;
}

/* ---------- Responzívne (mobil) ---------- */
@media (max-width: 480px) {
  .sh-chat { right: var(--sh-space-3); bottom: var(--sh-space-3); }
  .sh-chat-panel {
    position: fixed;
    right: var(--sh-space-3);
    left: var(--sh-space-3);
    bottom: calc(60px + var(--sh-space-3));
    width: auto;
    height: min(70vh, 520px);
  }
}
