/* Support chat widget — bottom-right FAB + panel */
.aka-chat-root {
  --aka-chat-accent: #22d3ee;
  --aka-chat-accent-dim: rgba(34, 211, 238, 0.15);
  --aka-chat-bg: rgba(11, 12, 16, 0.96);
  --aka-chat-panel-border: rgba(255, 255, 255, 0.1);
  --aka-chat-text: rgba(248, 250, 252, 0.95);
  --aka-chat-muted: rgba(148, 163, 184, 0.9);
  --aka-chat-avatar-bg: linear-gradient(135deg, #1e2030 0%, #13151e 52%, #0b0c10 100%);
  --aka-chat-avatar-border: rgba(0, 212, 255, 0.22);
  --aka-chat-avatar-glow: inset 0 0 10px rgba(0, 212, 255, 0.1), inset -6px -6px 14px rgba(237, 33, 76, 0.08);
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 99990;
  font-family: "Google Sans", system-ui, sans-serif;
  pointer-events: none;
}

.aka-chat-root *,
.aka-chat-root *::before,
.aka-chat-root *::after {
  box-sizing: border-box;
}

.aka-chat-root.is-open {
  pointer-events: auto;
}

.aka-chat-fab {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.75rem;
  height: 3.75rem;
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 9999px;
  background: linear-gradient(145deg, rgba(34, 211, 238, 0.22), rgba(15, 23, 42, 0.95));
  color: var(--aka-chat-accent);
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.aka-chat-fab:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 24px rgba(34, 211, 238, 0.15);
}

.aka-chat-fab:focus-visible {
  outline: 2px solid var(--aka-chat-accent);
  outline-offset: 3px;
}

.aka-chat-fab svg {
  width: 1.5rem;
  height: 1.5rem;
}

.aka-chat-badge {
  position: absolute;
  top: -0.15rem;
  right: -0.15rem;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 9999px;
  background: #f472b6;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.25rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.aka-chat-badge[hidden] {
  display: none;
}

.aka-chat-panel {
  pointer-events: auto;
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.75rem);
  display: flex;
  flex-direction: column;
  width: min(22rem, calc(100vw - 2rem));
  max-height: min(52rem, calc(100vh - 2.5rem));
  border: 1px solid var(--aka-chat-panel-border);
  border-radius: 1.25rem;
  background: var(--aka-chat-bg);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}

.aka-chat-root.is-open .aka-chat-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.aka-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.aka-chat-header-avatar.aka-chat-avatar--brand {
  width: 2.25rem;
  height: 2.25rem;
}

.aka-chat-header-avatar {
  flex-shrink: 0;
  border-radius: 9999px;
  background: var(--aka-chat-avatar-bg);
  border: 1px solid var(--aka-chat-avatar-border);
  box-shadow: var(--aka-chat-avatar-glow);
  overflow: hidden;
}

.aka-chat-avatar--brand .aka-chat-avatar-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.aka-chat-header-main {
  flex: 1 1 auto;
  min-width: 0;
}

.aka-chat-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--aka-chat-text);
}

.aka-chat-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--aka-chat-muted);
}

.aka-chat-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--aka-chat-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.aka-chat-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--aka-chat-text);
}

.aka-chat-messages {
  flex: 1 1 auto;
  min-height: 22rem;
  max-height: 35rem;
  overflow-y: auto;
  padding: 0.85rem 0.85rem 0.5rem;
  scroll-behavior: smooth;
}

.aka-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.aka-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
}

.aka-chat-empty {
  margin: 2rem 0.5rem;
  text-align: center;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--aka-chat-muted);
}

.aka-chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.aka-chat-msg--visitor {
  justify-content: flex-end;
}

.aka-chat-msg--admin {
  justify-content: flex-start;
}

.aka-chat-avatar {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
}

.aka-chat-avatar--brand {
  overflow: hidden;
  background: var(--aka-chat-avatar-bg);
  border: 1px solid var(--aka-chat-avatar-border);
  box-shadow: var(--aka-chat-avatar-glow);
}

.aka-chat-avatar--visitor {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--aka-chat-avatar-bg);
  border: 1px solid var(--aka-chat-avatar-border);
  box-shadow: var(--aka-chat-avatar-glow);
  color: rgba(0, 212, 255, 0.85);
}

.aka-chat-avatar--visitor svg {
  width: 1rem;
  height: 1rem;
}

.aka-chat-bubble {
  flex: 0 1 auto;
  width: fit-content;
  min-width: 0;
  max-width: 78%;
  padding: 0.55rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  word-break: break-word;
}

.aka-chat-msg--visitor .aka-chat-bubble {
  border-bottom-right-radius: 0.35rem;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.25), rgba(34, 211, 238, 0.12));
  border: 1px solid rgba(34, 211, 238, 0.25);
  color: var(--aka-chat-text);
}

.aka-chat-msg--admin .aka-chat-bubble {
  border-bottom-left-radius: 0.35rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--aka-chat-text);
}

.aka-chat-time {
  display: block;
  width: max-content;
  max-width: 100%;
  margin-top: 0.2rem;
  font-size: 0.625rem;
  color: var(--aka-chat-muted);
}

.aka-chat-form-wrap {
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}

.aka-chat-textarea {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--aka-chat-text);
  font: inherit;
  font-size: 0.8125rem;
  line-height: 1.45;
  height: 2.75rem;
  min-height: 2.75rem;
  max-height: 6rem;
  padding: 0.625rem 0.7rem;
  resize: none;
  overflow-y: hidden;
  box-sizing: border-box;
}

.aka-chat-textarea:focus {
  outline: none;
  border-color: rgba(34, 211, 238, 0.45);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.12);
}

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

.aka-chat-form-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.aka-chat-send {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, #22d3ee, #06b6d4);
  color: #0b0c10;
  cursor: pointer;
  box-sizing: border-box;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.aka-chat-send:hover:not(:disabled) {
  transform: scale(1.04);
}

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

.aka-chat-send svg {
  width: 1.1rem;
  height: 1.1rem;
}

.aka-chat-status {
  min-height: 1rem;
  margin-top: 0.35rem;
  font-size: 0.6875rem;
  color: var(--aka-chat-muted);
}

.aka-chat-status.is-error {
  color: #fca5a5;
}

@media (max-width: 1024px) {
  .aka-chat-panel {
    position: fixed;
    inset: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border: none;
    border-radius: 0;
    transform-origin: center;
    transform: translateY(16px) scale(1);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .aka-chat-root.is-open .aka-chat-panel {
    transform: translateY(0) scale(1);
  }

  .aka-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .aka-chat-fab,
  .aka-chat-panel {
    transition: none;
  }
}
