/* ─── AI Chat widget ──────────────────────────────────────────── */
.aic-fab {
  position: fixed;
  right: clamp(16px, 2.5vw, 28px);
  bottom: clamp(16px, 2.5vw, 28px);
  z-index: 9000;
  display: flex; align-items: center; gap: 0;
  padding: 16px;
  background: var(--morkbla, #1c1a5f);
  color: #fff;
  border: none; border-radius: 999px;
  font-family: var(--sans, "Montserrat", sans-serif);
  font-size: 14px; font-weight: 600; letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow:
    0 12px 32px -8px #1c1a5f55,
    0 2px 6px -1px #00000022;
  transition: gap .35s cubic-bezier(.2,.8,.3,1), padding .35s cubic-bezier(.2,.8,.3,1), background .2s ease, box-shadow .2s ease, transform .2s ease;
}
.aic-fab span:not(.aic-fab-icon) {
  max-width: 0; opacity: 0; overflow: hidden; white-space: nowrap;
  transition: max-width .35s cubic-bezier(.2,.8,.3,1), opacity .25s ease;
}
.aic-fab:hover, .aic-fab:focus-visible {
  transform: translateY(-2px);
  background: var(--bla, #0955B1);
  gap: 11px;
  padding: 16px 22px 16px 18px;
  box-shadow:
    0 18px 40px -8px #0955B166,
    0 2px 6px -1px #00000022;
}
.aic-fab:hover span:not(.aic-fab-icon),
.aic-fab:focus-visible span:not(.aic-fab-icon) {
  max-width: 240px; opacity: 1;
}
.aic-fab .aic-fab-icon {
  width: 24px; height: 24px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  position: relative;
}
.aic-fab .aic-fab-icon::before {
  content: ""; width: 22px; height: 22px;
  background: #fff;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.6l1.9 7.1c.18.66.7 1.18 1.36 1.36L22.4 12l-7.14 1.94c-.66.18-1.18.7-1.36 1.36L12 22.4l-1.94-7.1c-.18-.66-.7-1.18-1.36-1.36L1.6 12l7.1-1.94c.66-.18 1.18-.7 1.36-1.36z'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.6l1.9 7.1c.18.66.7 1.18 1.36 1.36L22.4 12l-7.14 1.94c-.66.18-1.18.7-1.36 1.36L12 22.4l-1.94-7.1c-.18-.66-.7-1.18-1.36-1.36L1.6 12l7.1-1.94c.66-.18 1.18-.7 1.36-1.36z'/%3E%3C/svg%3E") center/contain no-repeat;
}
@media (prefers-reduced-motion: no-preference) {
  .aic-fab .aic-fab-icon::after {
    content: ""; position: absolute; inset: -6px;
    border-radius: 50%;
    box-shadow: 0 0 0 0 #76b0ff80;
    animation: aic-pulse 2.6s ease-out infinite;
  }
}
@keyframes aic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 #76b0ff70; }
  60% { box-shadow: 0 0 0 9px #76b0ff00; }
}
.aic-fab.is-open { opacity: 0; pointer-events: none; transform: scale(0.92); }

/* ─── Panel ────────────────────────────────────────────────────── */
.aic-panel {
  position: fixed;
  right: clamp(16px, 2.5vw, 28px);
  bottom: clamp(16px, 2.5vw, 28px);
  z-index: 9001;
  width: min(420px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 48px));
  display: flex; flex-direction: column;
  background: var(--surface, #fff);
  border: 1px solid var(--rule-2, #00000022);
  border-radius: 20px;
  box-shadow:
    0 32px 80px -16px #1c1a5f44,
    0 8px 24px -4px #00000022;
  overflow: hidden;
  font-family: var(--sans, "Montserrat", sans-serif);
  transform: translateY(20px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s cubic-bezier(.2,.8,.3,1), opacity .2s ease;
}
.aic-panel.is-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Header */
.aic-head {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 18px 16px;
  background: var(--morkbla, #1c1a5f);
  color: #fff;
  border-bottom: 1px solid #ffffff15;
}
.aic-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bla, #0955B1), var(--ljusbla, #76b0ff));
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}
.aic-avatar::after {
  content: ""; position: absolute;
  bottom: -1px; right: -1px;
  width: 11px; height: 11px;
  background: #4ade80;
  border: 2px solid var(--morkbla, #1c1a5f);
  border-radius: 50%;
}
.aic-head-text { flex: 1; min-width: 0; }
.aic-head-title {
  font-size: 14px; font-weight: 700; letter-spacing: -0.01em;
  margin: 0;
}
.aic-head-sub {
  font-size: 11px; font-weight: 500;
  color: #ffffffaa; margin-top: 2px;
  display: flex; align-items: center; gap: 6px;
}
.aic-head-sub::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: #4ade80;
}
.aic-close {
  width: 32px; height: 32px;
  border: none; border-radius: 50%;
  background: #ffffff10;
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 18px; line-height: 1;
  transition: background .15s;
}
.aic-close:hover { background: #ffffff25; }

/* Messages */
.aic-body {
  flex: 1; overflow-y: auto;
  padding: 20px 18px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--paper, #f6f6f6);
  scroll-behavior: smooth;
}
.aic-body::-webkit-scrollbar { width: 6px; }
.aic-body::-webkit-scrollbar-thumb { background: #00000020; border-radius: 3px; }

.aic-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px; line-height: 1.5;
  color: var(--ink-2, #27262e);
  word-wrap: break-word;
  animation: aic-fade-in .25s ease;
}
@keyframes aic-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.aic-msg.bot {
  background: var(--surface, #fff);
  border: 1px solid var(--rule-2, #00000022);
  border-bottom-left-radius: 6px;
  align-self: flex-start;
}
.aic-msg.user {
  background: var(--morkbla, #1c1a5f);
  color: #fff;
  border-bottom-right-radius: 6px;
  align-self: flex-end;
}
.aic-msg.bot a {
  color: var(--bla, #0955B1);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.aic-msg p { margin: 0 0 8px; }
.aic-msg p:last-child { margin-bottom: 0; }
.aic-msg ul, .aic-msg ol { margin: 4px 0 8px; padding-left: 20px; }
.aic-msg li { margin-bottom: 3px; }
.aic-msg strong { font-weight: 700; }

/* Typing indicator */
.aic-typing {
  align-self: flex-start;
  display: flex; gap: 4px;
  padding: 14px 18px;
  background: var(--surface, #fff);
  border: 1px solid var(--rule-2, #00000022);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
}
.aic-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ljusgra, #b7b4bd);
  animation: aic-bounce 1.2s ease-in-out infinite;
}
.aic-typing span:nth-child(2) { animation-delay: 0.15s; }
.aic-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes aic-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Suggestions */
.aic-sugg {
  display: flex; flex-direction: column; gap: 8px;
  padding: 4px 0 2px;
}
.aic-sugg-label {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3, #827f88); margin-bottom: 2px;
}
.aic-sugg button {
  text-align: left;
  padding: 10px 14px;
  background: var(--surface, #fff);
  border: 1px solid var(--rule-2, #00000022);
  border-radius: 14px;
  font-family: inherit;
  font-size: 13px; font-weight: 500;
  color: var(--ink-2, #27262e);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.aic-sugg button:hover {
  border-color: var(--bla, #0955B1);
  background: var(--accent-soft, #e6efff);
  transform: translateX(2px);
}

/* Input */
.aic-foot {
  padding: 14px 14px 14px;
  border-top: 1px solid var(--rule-2, #00000022);
  background: var(--surface, #fff);
}
.aic-input-row {
  display: flex; gap: 8px; align-items: flex-end;
  background: var(--paper, #f6f6f6);
  border: 1px solid var(--rule-2, #00000022);
  border-radius: 16px;
  padding: 6px 6px 6px 14px;
  transition: border-color .15s;
}
.aic-input-row:focus-within {
  border-color: var(--bla, #0955B1);
}
.aic-input {
  flex: 1; resize: none;
  border: none; outline: none; background: transparent;
  font-family: inherit;
  font-size: 14px; line-height: 1.4;
  color: var(--ink, #000);
  padding: 8px 0;
  max-height: 120px;
  min-height: 24px;
}
.aic-input::placeholder { color: var(--ink-3, #827f88); }
.aic-send {
  width: 36px; height: 36px; flex-shrink: 0;
  border: none; border-radius: 50%;
  background: var(--bla, #0955B1);
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background .15s, transform .15s, opacity .15s;
}
.aic-send:hover:not(:disabled) {
  background: var(--morkbla, #1c1a5f);
  transform: scale(1.05);
}
.aic-send:disabled {
  opacity: 0.35; cursor: not-allowed;
}
.aic-send svg { width: 16px; height: 16px; }
.aic-disclaimer {
  font-size: 10.5px; font-weight: 500;
  color: var(--ink-3, #827f88);
  text-align: center; margin-top: 10px;
  letter-spacing: 0.02em;
}

/* Mobile */
@media (max-width: 540px) {
  .aic-panel {
    right: 0; bottom: 0;
    width: 100vw; height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .aic-fab span:not(.aic-fab-icon) { display: none; }
  .aic-fab { padding: 14px; }
}
