/* Bubbler tuoteneuvoja — right-side product advisor */

#apn-root {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

.apn-widget {
  --apn-navy: #0d2137;
  --apn-navy-2: #16324f;
  --apn-ice: #8fd3ea;
  --apn-ice-2: #e7f5fb;
  --apn-text: #16324a;
  --apn-muted: #5d7386;
  --apn-line: #d5e4ee;
  --apn-accent: #1d6f9c;
  --apn-shadow: 0 18px 50px rgba(13, 33, 55, 0.28);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 999999;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--apn-text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.apn-widget * {
  box-sizing: border-box;
}

.apn-widget button,
.apn-widget input,
.apn-widget textarea {
  font-family: inherit;
}

/* ---------- Launcher (minimized) ---------- */

.apn-launcher {
  display: none;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: inherit;
}

.apn-widget.is-min .apn-launcher {
  display: flex;
}

.apn-launcher-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 0;
  background: #fff;
  color: #fff;
  box-shadow: var(--apn-shadow);
  display: grid;
  place-items: center;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
}

.apn-launcher-btn svg {
  width: 30px;
  height: 30px;
}

.apn-launcher-btn .apn-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.apn-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--apn-ice);
  animation: apn-pulse 2.2s ease-out infinite;
  pointer-events: none;
}

.apn-widget.is-min.is-seen .apn-pulse {
  display: none;
}

@keyframes apn-pulse {
  0% { transform: scale(0.92); opacity: 0.7; }
  100% { transform: scale(1.18); opacity: 0; }
}

.apn-launcher-label {
  background: #fff;
  color: var(--apn-navy);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(13, 33, 55, 0.16);
  max-width: 180px;
  text-align: left;
}

.apn-hide-full {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: #fff;
  color: var(--apn-navy);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ---------- Edge tab when fully hidden ---------- */

.apn-edge {
  display: none;
  position: fixed;
  right: 0;
  top: 42%;
  z-index: 999999;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  border: 0;
  border-radius: 8px 0 0 8px;
  background: var(--apn-navy);
  color: #fff;
  padding: 14px 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: var(--apn-shadow);
}

.apn-widget.is-hidden + .apn-edge,
.apn-widget.is-hidden .apn-edge {
  display: block;
}

.apn-widget.is-hidden .apn-launcher,
.apn-widget.is-hidden .apn-panel {
  display: none !important;
}

/* ---------- Panel ---------- */

.apn-panel {
  display: none;
  width: min(392px, calc(100vw - 24px));
  height: min(620px, calc(100vh - 36px));
  background: #f6fafc;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--apn-shadow);
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.apn-widget.is-open .apn-panel {
  display: flex;
  animation: apn-in 0.32s ease;
}

@keyframes apn-in {
  from { opacity: 0; transform: translateX(18px) translateY(10px); }
  to { opacity: 1; transform: none; }
}

.apn-head {
  background: linear-gradient(155deg, var(--apn-navy) 0%, var(--apn-navy-2) 60%, #1a4f72 100%);
  color: #fff;
  padding: 14px 14px 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.apn-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.apn-avatar svg {
  width: 24px;
  height: 24px;
}

.apn-avatar .apn-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.apn-head-text {
  flex: 1;
  min-width: 0;
}

.apn-head-text strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
}

.apn-head-text span {
  display: block;
  font-size: 12px;
  opacity: 0.78;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apn-head-actions {
  display: flex;
  gap: 4px;
}

.apn-iconbtn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.apn-iconbtn:hover,
.apn-iconbtn:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

.apn-iconbtn svg {
  width: 16px;
  height: 16px;
  display: block;
  margin: 0 auto;
}

.apn-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    radial-gradient(1200px 200px at 100% -40%, rgba(143, 211, 234, 0.28), transparent 50%),
    #f6fafc;
}

.apn-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14.5px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.apn-msg p {
  margin: 0 0 0.55em;
}

.apn-msg p:last-child {
  margin-bottom: 0;
}

.apn-msg a {
  color: var(--apn-accent);
  font-weight: 600;
  text-decoration: underline;
}

.apn-msg.bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--apn-line);
  border-bottom-left-radius: 5px;
}

.apn-msg.user {
  align-self: flex-end;
  background: var(--apn-navy);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.apn-msg.user a {
  color: var(--apn-ice);
}

.apn-cards {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.apn-card {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--apn-line);
  border-radius: 12px;
  padding: 8px;
  text-decoration: none;
  color: inherit;
}

.apn-card:hover,
.apn-card:focus-visible {
  border-color: var(--apn-ice);
  outline: none;
}

.apn-card img,
.apn-card-ph {
  width: 64px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--apn-ice-2);
  flex-shrink: 0;
}

.apn-card-ph {
  display: grid;
  place-items: center;
  color: var(--apn-accent);
}

.apn-card-ph svg {
  width: 22px;
  height: 22px;
}

.apn-card-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.apn-card-body strong {
  font-size: 13px;
  line-height: 1.25;
}

.apn-card-body span {
  font-size: 13px;
  font-weight: 700;
  color: var(--apn-navy);
}

.apn-card-body em {
  font-style: normal;
  font-size: 12px;
  color: var(--apn-accent);
  font-weight: 600;
}

.apn-typing {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--apn-line);
  border-radius: 14px;
}

.apn-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--apn-accent);
  opacity: 0.35;
  animation: apn-dot 1s infinite ease-in-out;
}

.apn-typing i:nth-child(2) { animation-delay: 0.15s; }
.apn-typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes apn-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
  40% { transform: translateY(-3px); opacity: 1; }
}

.apn-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 14px 10px;
  flex-shrink: 0;
}

.apn-chip {
  border: 1px solid var(--apn-line);
  background: #fff;
  color: var(--apn-navy);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.apn-chip:hover,
.apn-chip:focus-visible {
  background: var(--apn-ice-2);
  border-color: var(--apn-ice);
  outline: none;
}

.apn-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  background: #fff;
  border-top: 1px solid var(--apn-line);
  flex-shrink: 0;
}

.apn-form textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 96px;
  border: 1px solid var(--apn-line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--apn-text);
  background: #fbfefe;
}

.apn-form textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--apn-accent) 45%, white);
  border-color: var(--apn-accent);
}

.apn-send {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: var(--apn-accent);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

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

.apn-send svg {
  width: 18px;
  height: 18px;
}

.apn-foot {
  font-size: 11px;
  color: var(--apn-muted);
  text-align: center;
  padding: 0 12px 10px;
  background: #fff;
}

.apn-error {
  color: #9b1c1c;
  font-size: 13px;
  padding: 0 14px 8px;
}

/* Confirm hide */

.apn-confirm {
  display: none;
  padding: 10px 14px 12px;
  background: #fff8e8;
  border-top: 1px solid #ead8a4;
  font-size: 13px;
}

.apn-confirm.is-on {
  display: block;
}

.apn-confirm-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.apn-confirm-actions button {
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
}

.apn-confirm-yes {
  background: var(--apn-navy);
  color: #fff;
}

.apn-confirm-no {
  background: #eee;
}

@media (max-width: 520px) {
  .apn-widget {
    right: 10px;
    bottom: 10px;
  }

  .apn-panel {
    width: calc(100vw - 16px);
    height: min(78vh, 640px);
    border-radius: 16px;
  }

  .apn-launcher-label {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .apn-panel,
  .apn-pulse,
  .apn-typing i {
    animation: none !important;
  }
}
