/* ============ APP CHAT WIDGET (Messenger-style, draggable) ============ */
.app-chat-root {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9999;
  font-family: var(--font);
  touch-action: none;
  transition:
    left 0.42s cubic-bezier(0.34, 1.2, 0.64, 1),
    top 0.42s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.app-chat-root.is-dragging {
  transition: none;
  z-index: 10000;
}

.app-chat-toggle {
  width: 62px;
  height: 62px;
  border: none;
  border-radius: 50%;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
  box-shadow:
    0 12px 40px rgba(14, 165, 233, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.12) inset;
  transition:
    transform 0.28s cubic-bezier(0.34, 1.3, 0.64, 1),
    box-shadow 0.25s ease;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

.app-chat-toggle:hover {
  transform: scale(1.06);
  box-shadow:
    0 16px 48px rgba(14, 165, 233, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.16) inset;
}

.app-chat-root.is-dragging .app-chat-toggle {
  cursor: grabbing;
  transform: scale(1.1);
  box-shadow:
    0 20px 56px rgba(14, 165, 233, 0.65),
    0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}

.app-chat-toggle.is-open {
  transform: scale(0.95);
}

.app-chat-root.is-dragging .app-chat-toggle.is-open {
  transform: scale(1.1);
}

.app-chat-toggle-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #4ade80;
  border: 2px solid #04121f;
  animation: chat-badge-pulse 2s ease-in-out infinite;
  pointer-events: none;
}

.app-chat-toggle-badge.is-hidden {
  display: none;
}

@keyframes chat-badge-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.85; }
}

.app-chat-panel {
  position: absolute;
  width: min(520px, calc(100vw - 36px));
  height: min(780px, calc(100vh - 100px));
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  background: #0a1524;
  border: 1px solid rgba(56, 189, 248, 0.22);
  box-shadow:
    0 24px 80px rgba(2, 8, 18, 0.85),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.38s cubic-bezier(0.34, 1.35, 0.64, 1),
    visibility 0.32s;
}

.app-chat-panel.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(0, 0) scale(1);
}

/* —— Panel pozíció + animáció sarok szerint —— */
.app-chat-root[data-corner="br"] .app-chat-panel {
  right: 0;
  left: auto;
  bottom: calc(62px + 14px);
  top: auto;
  transform-origin: bottom right;
  transform: translateY(24px) scale(0.86);
}

.app-chat-root[data-corner="bl"] .app-chat-panel {
  left: 0;
  right: auto;
  bottom: calc(62px + 14px);
  top: auto;
  transform-origin: bottom left;
  transform: translateY(24px) scale(0.86);
}

.app-chat-root[data-corner="tr"] .app-chat-panel {
  right: 0;
  left: auto;
  top: calc(62px + 14px);
  bottom: auto;
  transform-origin: top right;
  transform: translateY(-24px) scale(0.86);
}

.app-chat-root[data-corner="tl"] .app-chat-panel {
  left: 0;
  right: auto;
  top: calc(62px + 14px);
  bottom: auto;
  transform-origin: top left;
  transform: translateY(-24px) scale(0.86);
}

.app-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(180deg, #0f2138 0%, #0a1524 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.app-chat-root.is-dragging .app-chat-header {
  cursor: grabbing;
}

.app-chat-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35);
}

.app-chat-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-chat-header-text {
  flex: 1;
  min-width: 0;
}

.app-chat-header-title {
  font-size: 16px;
  font-weight: 700;
  color: #f1f5f9;
  line-height: 1.2;
}

.app-chat-header-sub {
  font-size: 12.5px;
  color: rgba(148, 163, 184, 0.95);
  margin-top: 2px;
}

.app-chat-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.app-chat-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
}

.app-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    radial-gradient(ellipse at top, rgba(56, 189, 248, 0.06), transparent 55%),
    #070f1a;
}

.app-chat-bubble {
  white-space: pre-line;
  max-width: 94%;
  padding: 13px 16px;
  border-radius: 18px;
  font-size: 15.5px;
  line-height: 1.55;
  word-wrap: break-word;
}

.app-chat-bubble.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.07);
  color: #e2e8f0;
  border-bottom-left-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.app-chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #0284c7, #4f46e5);
  color: #f8fafc;
  border-bottom-right-radius: 6px;
}

.app-chat-bubble.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-height: 38px;
}

.app-chat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.9);
  animation: chat-typing 1.2s infinite ease-in-out;
}

.app-chat-dot:nth-child(2) { animation-delay: 0.15s; }
.app-chat-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-typing {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.app-chat-suggestions {
  padding: 0 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: #070f1a;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.app-chat-suggestion {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.app-chat-suggestion:hover {
  background: rgba(56, 189, 248, 0.18);
  transform: translateY(-1px);
}

.app-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: #0a1524;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.app-chat-input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  color: #f1f5f9;
  font-family: var(--font);
  font-size: 14.5px;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.app-chat-input:focus {
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.app-chat-input::placeholder {
  color: rgba(148, 163, 184, 0.75);
}

.app-chat-send {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #04121f;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.app-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.app-chat-send:not(:disabled):hover {
  transform: scale(1.05);
}

@media (max-width: 520px) {
  .app-chat-panel {
    width: min(520px, calc(100vw - 24px));
    height: min(780px, calc(100vh - 90px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-chat-root,
  .app-chat-panel,
  .app-chat-toggle {
    transition: none !important;
  }

  .app-chat-toggle-badge {
    animation: none;
  }
}
