/**
 * MSBela – AI Průvodce (Sovička)  v1.0.0
 *
 * Chat widget: FAB bublina vlevo od scroll-to-top sovy.
 * Panel: 380×520px card s message thread.
 *
 * z-index: 490 (pod sovičkou scroll-to-top 500, nad ostatním)
 *
 * @package MSBela
 * @since   2.55.26
 */

/* ==========================================================================
   1. BUBBLE (FAB)
   ========================================================================== */

.msbelaAI__bubble {
  position: fixed;
  right: 104px;
  bottom: 32px;
  z-index: 490;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--ds-teal-dark, #1D8A7D), var(--ds-teal, #26B5A5));
  box-shadow:
    0 4px 16px rgba(29, 138, 125, 0.35),
    0 2px 6px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 200ms ease;
  padding: 0;
}

.msbelaAI__bubble:hover {
  transform: scale(1.1);
  box-shadow:
    0 6px 24px rgba(29, 138, 125, 0.45),
    0 3px 10px rgba(0, 0, 0, 0.15);
}

.msbelaAI__bubble:active {
  transform: scale(0.95);
}

.msbelaAI__bubble:focus-visible {
  outline: 3px solid var(--ds-teal, #26B5A5);
  outline-offset: 4px;
}

/* Ikona v bublině */
.msbelaAI__bubble-icon {
  width: 40px;
  height: 40px;
  pointer-events: none;
}

/* Badge otazník */
.msbelaAI__bubble-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ds-red, #E84040);
  color: white;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  transition: transform 200ms ease;
}

/* Skrýt badge když je panel otevřený */
.msbelaAI__bubble--open .msbelaAI__bubble-badge {
  transform: scale(0);
}

/* Posun bubliny nahoru pokud je cookie banner viditelný */
.cookie-banner.is-visible ~ * .msbelaAI__bubble,
body.cookie-banner-open .msbelaAI__bubble {
  bottom: calc(32px + 80px);
}

/* ==========================================================================
   2. PANEL (chat window)
   ========================================================================== */

.msbelaAI__panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  z-index: 491;
  width: 380px;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  background: var(--ds-white, #fff);
  border-radius: var(--radius-lg, 24px);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.15),
    0 4px 16px rgba(29, 138, 125, 0.1);
  overflow: hidden;
  animation: msbelaAI-slideUp 300ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.msbelaAI__panel[hidden] {
  display: none;
}

@keyframes msbelaAI-slideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Posun panelu nahoru pokud je cookie banner viditelný */
.cookie-banner.is-visible ~ * .msbelaAI__panel,
body.cookie-banner-open .msbelaAI__panel {
  bottom: calc(100px + 80px);
}

/* ==========================================================================
   3. HEADER
   ========================================================================== */

.msbelaAI__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--ds-teal-dark, #1D8A7D), var(--ds-teal, #26B5A5));
  color: white;
  flex-shrink: 0;
}

.msbelaAI__header-icon {
  font-size: 22px;
  line-height: 1;
}

.msbelaAI__header-title {
  font-family: var(--font-display, 'Fredoka One', cursive);
  font-size: 1rem;
  font-weight: 400;
  flex: 1;
}

.msbelaAI__header-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
  flex-shrink: 0;
}

.msbelaAI__header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.msbelaAI__header-btn:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* ==========================================================================
   4. MESSAGES
   ========================================================================== */

.msbelaAI__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 340px;
  scroll-behavior: smooth;
  background: var(--ds-cream, #FFF8F0);
}

/* Scrollbar */
.msbelaAI__messages::-webkit-scrollbar {
  width: 6px;
}

.msbelaAI__messages::-webkit-scrollbar-track {
  background: transparent;
}

.msbelaAI__messages::-webkit-scrollbar-thumb {
  background: var(--ds-teal-light, #A8E6DF);
  border-radius: 3px;
}

/* Message bubble */
.msbelaAI__msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-break: break-word;
}

.msbelaAI__msg--user {
  align-self: flex-end;
  background: var(--ds-teal-dark, #1D8A7D);
  color: white;
  border-bottom-right-radius: 4px;
}

.msbelaAI__msg--assistant {
  align-self: flex-start;
  background: var(--ds-white, #fff);
  color: var(--ds-text-dark, #2D2D2D);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.msbelaAI__msg--assistant strong {
  color: var(--ds-teal-dark, #1D8A7D);
}

.msbelaAI__msg--assistant a {
  color: var(--ds-teal-dark, #1D8A7D);
  text-decoration: underline;
}

/* Loading dots animation */
.msbelaAI__msg--loading {
  color: var(--ds-text-light, #8A8A8A);
  font-style: italic;
}

/* ==========================================================================
   5. FOOTER (input)
   ========================================================================== */

.msbelaAI__footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--ds-green-light, #DDEEBB);
  background: var(--ds-white, #fff);
  flex-shrink: 0;
}

.msbelaAI__input {
  flex: 1;
  border: 1.5px solid var(--ds-green-light, #DDEEBB);
  border-radius: var(--radius-full, 9999px);
  padding: 8px 16px;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--ds-text-dark, #2D2D2D);
  background: var(--ds-cream, #FFF8F0);
  outline: none;
  transition: border-color 0.15s;
}

.msbelaAI__input:focus {
  border-color: var(--ds-teal, #26B5A5);
}

.msbelaAI__input::placeholder {
  color: var(--ds-text-light, #8A8A8A);
}

.msbelaAI__send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--ds-teal-dark, #1D8A7D);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.msbelaAI__send:hover {
  background: var(--ds-teal, #26B5A5);
}

.msbelaAI__send:active {
  transform: scale(0.92);
}

.msbelaAI__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.msbelaAI__send:focus-visible {
  outline: 3px solid var(--ds-teal, #26B5A5);
  outline-offset: 3px;
}

/* ==========================================================================
   6. RESPONSIVE
   ========================================================================== */

@media (max-width: 480px) {
  .msbelaAI__panel {
    right: 8px;
    left: 8px;
    bottom: 80px;
    width: auto;
    max-height: 70vh;
    border-radius: var(--radius-md, 16px);
  }

  .msbelaAI__bubble {
    right: 80px;
    bottom: 20px;
    width: 48px;
    height: 48px;
  }

  .msbelaAI__bubble-icon {
    width: 32px;
    height: 32px;
  }
}

/* ==========================================================================
   7. PRINT – skrýt
   ========================================================================== */

@media print {
  .msbelaAI__bubble,
  .msbelaAI__panel {
    display: none !important;
  }
}

/* ==========================================================================
   8. REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .msbelaAI__panel {
    animation: none;
  }

  .msbelaAI__bubble {
    transition: none;
  }
}
