/* Avtoskola Martin — Chatbot (matches brand: blue #2955A4, yellow #FDDE1F) */

.am-chat-root,
.am-chat-dock {
  --am-blue: #2955A4;
  --am-blue-dark: #1E3F7A;
  --am-yellow: #FDDE1F;
  --am-dark: #111827;
  --am-muted: #6B7280;
  --am-border: #E5E7EB;
  --am-bg: #F9FAFB;
  --am-shadow: 0 12px 40px rgba(17, 24, 39, 0.18);
  font-family: 'DM Sans', 'Plus Jakarta Sans', sans-serif;
}

.am-chat-root {
  z-index: 99980;
}

.am-chat-dock {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 99990;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

.am-chat-nudge {
  pointer-events: auto;
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  width: min(278px, calc(100vw - 88px));
  margin: 0;
  padding: 11px 12px 0;
  border: 1px solid rgba(253, 222, 31, 0.55);
  border-radius: 18px 18px 8px 18px;
  background:
    linear-gradient(180deg, rgba(253, 222, 31, 0.12) 0%, transparent 42%),
    linear-gradient(145deg, #1A3A78 0%, #2955A4 62%, #16325F 100%);
  color: #fff;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.28);
  animation: am-nudge-in 0.55s cubic-bezier(.22,1,.36,1) both,
             am-nudge-bob 2.8s ease-in-out 1.2s 3;
}

.am-chat-nudge-badge {
  grid-row: 1;
  grid-column: 1;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.am-chat-nudge-badge svg {
  display: block;
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 4px 8px rgba(11, 18, 32, 0.28));
}

.am-chat-nudge-copy {
  grid-row: 1;
  grid-column: 2;
  min-width: 0;
  padding-bottom: 2px;
}

.am-chat-nudge-kicker {
  display: block;
  margin-bottom: 2px;
  color: var(--am-yellow);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.am-chat-nudge-text {
  display: block;
  color: #fff;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.3;
}

.am-chat-nudge-lane {
  grid-column: 1 / -1;
  position: relative;
  height: 22px;
  margin: 8px -12px 0;
  overflow: hidden;
  background:
    repeating-linear-gradient(
      90deg,
      #FDDE1F 0 10px,
      transparent 10px 20px
    ) 0 10px / 40px 2px no-repeat,
    linear-gradient(#2A2F38, #15181E);
  animation: am-lane-scroll 1.6s linear infinite;
}

.am-chat-nudge-car {
  position: absolute;
  left: 0;
  bottom: 1px;
  width: 36px;
  height: 16px;
  animation: am-car-drive 5.4s linear infinite;
}

.am-chat-nudge-car svg {
  display: block;
  width: 36px;
  height: 16px;
}

.am-chat-nudge::after {
  content: '';
  position: absolute;
  right: 22px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #FDDE1F;
  transform: rotate(45deg);
  border-right: 1px solid rgba(253, 222, 31, 0.9);
  border-bottom: 1px solid rgba(253, 222, 31, 0.9);
  border-radius: 2px;
}

.am-chat-nudge:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 36px rgba(17, 24, 39, 0.34);
}

.am-chat-nudge:hover .am-chat-nudge-lane {
  animation-duration: 0.9s;
}

.am-chat-nudge:hover .am-chat-nudge-car {
  animation-duration: 2.8s;
}

.am-chat-nudge:focus-visible {
  outline: 3px solid var(--am-yellow);
  outline-offset: 3px;
}

.am-chat-dock--open .am-chat-nudge {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  animation: none;
  visibility: hidden;
}

@keyframes am-nudge-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes am-nudge-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes am-lane-scroll {
  from { background-position: 0 10px, 0 0; }
  to { background-position: -40px 10px, 0 0; }
}

@keyframes am-car-drive {
  from { transform: translateX(-40px); }
  to { transform: translateX(280px); }
}

.am-chat-launcher {
  pointer-events: auto;
  position: relative;
  width: 62px;
  height: 62px;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #2955A4 0%, #1A3A78 100%);
  color: #fff;
  box-shadow: 0 10px 30px rgba(41, 85, 164, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  cursor: pointer;
  transition: transform 0.22s cubic-bezier(.22,1,.36,1), box-shadow 0.22s ease, background 0.2s ease;
  border: 2px solid #FDDE1F;
}

.am-chat-launcher::before {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 2px dashed rgba(253, 222, 31, 0.55);
  animation: am-wheel-orbit 12s linear infinite;
  pointer-events: none;
}

.am-chat-car,
.am-chat-car svg {
  display: block;
  width: 52px;
  height: 52px;
}

.am-wave {
  transform-box: fill-box;
  transform-origin: 18% 92%;
  animation: am-wave 1.35s ease-in-out infinite;
}

.am-chat-launcher:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 12px 32px rgba(41, 85, 164, 0.55);
}

.am-chat-launcher:hover .am-chat-car {
  animation: am-car-nudge 0.45s ease-in-out;
}

.am-chat-launcher:focus-visible {
  outline: 3px solid var(--am-yellow);
  outline-offset: 3px;
}

.am-chat-launcher[aria-expanded="true"] {
  background: var(--am-dark);
  border-color: var(--am-blue);
}

.am-chat-launcher[aria-expanded="true"]::before {
  animation: none;
  opacity: 0.35;
}

@keyframes am-wheel-orbit {
  to { transform: rotate(360deg); }
}

@keyframes am-car-nudge {
  0% { transform: translateX(0); }
  45% { transform: translateX(3px); }
  100% { transform: translateX(0); }
}

@keyframes am-wave {
  0%, 100% { transform: rotate(10deg); }
  50% { transform: rotate(-16deg); }
}

.am-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 96px;
  width: min(392px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 120px));
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(11, 18, 32, 0.22);
  border: 1px solid var(--am-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99991;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.22s cubic-bezier(.22,1,.36,1), transform 0.22s cubic-bezier(.22,1,.36,1);
}

.am-chat-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.am-chat-header {
  background: linear-gradient(135deg, var(--am-blue) 0%, var(--am-blue-dark) 100%);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.am-chat-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(253, 222, 31, 0.95);
  color: var(--am-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.am-chat-header-logo {
  height: 36px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  flex-shrink: 0;
  background: #fff;
  border-radius: 8px;
  padding: 4px 6px;
}

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

.am-chat-header-text strong {
  display: block;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.am-chat-header-text span {
  display: block;
  font-size: 0.78rem;
  opacity: 0.85;
  margin-top: 2px;
}

.am-chat-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.am-chat-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.am-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--am-bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.am-chat-msg {
  max-width: 88%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.am-chat-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: var(--am-dark);
  border: 1px solid var(--am-border);
  border-bottom-left-radius: 4px;
}

.am-chat-msg.user {
  align-self: flex-end;
  background: var(--am-blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.am-chat-msg.error {
  align-self: flex-start;
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

.am-chat-photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.am-chat-photos--single {
  grid-template-columns: 1fr;
}

.am-chat-photo {
  width: 100%;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  background: #E5E7EB;
}

.am-chat-photos--single .am-chat-photo {
  height: 150px;
}

.am-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 2px 4px;
}

.am-chat-suggestion {
  border: 1px solid var(--am-border);
  background: #fff;
  color: var(--am-blue);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  text-align: left;
  line-height: 1.3;
}

.am-chat-suggestion:hover {
  background: rgba(41, 85, 164, 0.08);
  border-color: var(--am-blue);
  transform: translateY(-1px);
}

.am-chat-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 5px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--am-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.am-chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--am-blue);
  opacity: 0.45;
  animation: am-chat-bounce 1.1s infinite ease-in-out;
}

.am-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.am-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

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

.am-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--am-border);
  background: #fff;
  flex-shrink: 0;
  align-items: flex-end;
}

.am-chat-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border: 1px solid var(--am-border);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--am-dark);
  background: var(--am-bg);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.am-chat-input:focus {
  border-color: var(--am-blue);
  box-shadow: 0 0 0 3px rgba(41, 85, 164, 0.15);
  background: #fff;
}

.am-chat-send {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--am-yellow);
  color: var(--am-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.am-chat-send:hover:not(:disabled) {
  background: #D4B800;
}

.am-chat-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.am-chat-footer-note {
  font-size: 0.68rem;
  color: var(--am-muted);
  text-align: center;
  padding: 0 14px 10px;
  background: #fff;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .am-chat-dock {
    right: 14px;
    bottom: 14px;
  }

  .am-chat-nudge {
    width: min(236px, calc(100vw - 80px));
    padding: 10px 10px 0;
    column-gap: 8px;
  }

  .am-chat-nudge-text {
    font-size: 0.78rem;
  }

  .am-chat-nudge-badge,
  .am-chat-nudge-badge svg {
    width: 34px;
    height: 34px;
  }

  .am-chat-launcher {
    width: 56px;
    height: 56px;
  }

  .am-chat-car,
  .am-chat-car svg {
    width: 46px;
    height: 46px;
  }

  .am-chat-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100vw;
    height: min(92vh, 640px);
    border-radius: 18px 18px 0 0;
  }

  @keyframes am-car-drive {
    from { transform: translateX(-40px); }
    to { transform: translateX(230px); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .am-chat-nudge,
  .am-chat-nudge-lane,
  .am-chat-nudge-car,
  .am-chat-launcher::before,
  .am-chat-launcher:hover .am-chat-car,
  .am-wave {
    animation: none;
  }
}
