/* ============================================================
   AutoDealer AI Chat Widget – Premium Styles
   Barvy: tmavě navy + zlatá. Glassmorphism. Mobile-first.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Dynamic vars passed from WP */
  --ad-gradient-start: #6a11cb;
  --ad-gradient-end: #2575fc;
  --ad-bg-dark: #0f172a;

  --ad-white: #ffffff;
  --ad-gray-100: #f0f4f8;
  --ad-gray-200: #d8e0ec;
  --ad-gray-400: #8898b0;
  --ad-gray-600: #4a5568;
  --ad-user-bubble: var(--ad-gradient-start);
  --ad-user-text: #ffffff;
  --ad-bot-bubble: rgba(255, 255, 255, 0.05);
  /* slightly lighter than bg-dark */
  --ad-bot-text: #e8edf5;
  --ad-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  --ad-shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.25);
  --ad-radius: 20px;
  --ad-radius-sm: 12px;
  --ad-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --ad-widget-width: 380px;
  --ad-widget-height: 580px;
  --ad-z: 9999;
}

/* ---- Launcher Button ---- */
#ad-chat-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ad-gradient-start) 0%, var(--ad-gradient-end) 100%);
  border: none;
  cursor: pointer;
  z-index: var(--ad-z);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease;
  outline: none;
}

#ad-chat-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(201, 168, 76, 0.6), 0 4px 12px rgba(0, 0, 0, 0.35);
}

#ad-chat-launcher:active {
  transform: scale(0.96);
}

#ad-chat-launcher svg {
  width: 28px;
  height: 28px;
  fill: #ffffff;
  transition: transform 0.3s ease, opacity 0.2s ease;
}

#ad-chat-launcher .ad-icon-chat {
  display: block;
}

#ad-chat-launcher .ad-icon-close {
  display: none;
}

#ad-chat-launcher.is-open .ad-icon-chat {
  display: none;
}

#ad-chat-launcher.is-open .ad-icon-close {
  display: block;
}

/* Notif badge */
#ad-chat-launcher .ad-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 18px;
  height: 18px;
  background: #e53e3e;
  border-radius: 50%;
  border: 2px solid var(--ad-white);
  animation: ad-pulse 2s ease-in-out infinite;
}

@keyframes ad-pulse {

  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.5);
  }

  50% {
    transform: scale(1.1);
    box-shadow: 0 0 0 6px rgba(229, 62, 62, 0);
  }
}

/* ---- Chat Window ---- */
#ad-chat-window {
  position: fixed;
  bottom: 104px;
  right: 28px;
  width: var(--ad-widget-width);
  height: var(--ad-widget-height);
  background: var(--ad-bg-dark);
  /* Changed from primary/secondary to strictly use our dynamic background variable */
  border-radius: var(--ad-radius);
  box-shadow: var(--ad-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--ad-z);
  border: 1px solid rgba(201, 168, 76, 0.2);

  /* Hidden state */
  transform: translateY(24px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.25s ease;
}

#ad-chat-window.is-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ---- Header ---- */
#ad-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(90deg, var(--ad-gradient-start) 0%, var(--ad-gradient-end) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

.ad-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  /* Zaručí perfektní obříznutí img loga na kruh */
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
}

.ad-header-info {
  flex: 1;
  min-width: 0;
}

.ad-header-name {
  font-family: var(--ad-font);
  font-weight: 700;
  font-size: 14px;
  color: var(--ad-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ad-header-status {
  font-family: var(--ad-font);
  font-size: 11.5px;
  color: #5cb85c;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.ad-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5cb85c;
  display: inline-block;
  animation: ad-blink 2s ease-in-out infinite;
}

@keyframes ad-blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.ad-header-actions {
  display: flex;
  gap: 6px;
}

.ad-header-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.ad-header-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.ad-header-btn svg {
  width: 15px;
  height: 15px;
  fill: var(--ad-gray-400);
}

/* ---- Messages Area ---- */
#ad-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

#ad-chat-messages::-webkit-scrollbar {
  width: 4px;
}

#ad-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

#ad-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* ---- Message Bubbles ---- */
.ad-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: ad-fadeUp 0.3s ease forwards;
}

@keyframes ad-fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ad-msg.ad-msg--bot {
  flex-direction: row;
}

.ad-msg.ad-msg--user {
  flex-direction: row-reverse;
}

.ad-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  /* Zaručí obříznutí img loga v chatu */
  background: linear-gradient(135deg, var(--ad-gradient-start) 0%, var(--ad-gradient-end) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.ad-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: var(--ad-radius-sm);
  font-family: var(--ad-font);
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.ad-msg--bot .ad-bubble {
  background: var(--ad-bot-bubble);
  color: var(--ad-bot-text);
  border-radius: 4px var(--ad-radius-sm) var(--ad-radius-sm) var(--ad-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.ad-msg--user .ad-bubble {
  background: linear-gradient(135deg, var(--ad-gradient-start) 0%, var(--ad-gradient-end) 100%);
  color: var(--ad-user-text);
  border-radius: var(--ad-radius-sm) 4px var(--ad-radius-sm) var(--ad-radius-sm);
  font-weight: 500;
}

/* Markdown-like bold */
.ad-bubble strong {
  font-weight: 700;
}

.ad-bubble a {
  color: var(--ad-accent-light);
  text-decoration: underline;
}

/* ---- Typing / Loading Indicator ---- */
.ad-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--ad-bot-bubble);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px var(--ad-radius-sm) var(--ad-radius-sm) var(--ad-radius-sm);
  width: fit-content;
}

.ad-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ad-gradient-start);
  display: block;
  animation: ad-typing-bounce 1.2s ease-in-out infinite;
}

.ad-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.ad-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes ad-typing-bounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }

  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ---- Input Area ---- */
#ad-chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

#ad-chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  color: var(--ad-white);
  font-family: var(--ad-font);
  font-size: 13.5px;
  line-height: 1.4;
  padding: 10px 14px;
  resize: none;
  outline: none;
  min-height: 40px;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.2s;
}

#ad-chat-input::placeholder {
  color: var(--ad-gray-400);
}

#ad-chat-input:focus {
  border-color: rgba(201, 168, 76, 0.5);
}

#ad-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--ad-gradient-start) 0%, var(--ad-gradient-end) 100%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.2s ease;
  box-shadow: 0 4px 16px rgba(201, 168, 76, 0.35);
}

#ad-chat-send:hover {
  transform: scale(1.08);
}

#ad-chat-send:active {
  transform: scale(0.94);
}

#ad-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

#ad-chat-send svg {
  width: 17px;
  height: 17px;
  fill: #ffffff;
}

/* ---- Welcome (empty state) ---- */
#ad-chat-welcome {
  text-align: center;
  padding: 20px 16px;
  animation: ad-fadeUp 0.4s ease forwards;
}

#ad-chat-welcome h3 {
  font-family: var(--ad-font);
  font-size: 16px;
  font-weight: 700;
  color: var(--ad-white);
  margin: 12px 0 6px;
}

#ad-chat-welcome p {
  font-family: var(--ad-font);
  font-size: 12.5px;
  color: var(--ad-gray-400);
  margin: 0 0 16px;
  line-height: 1.5;
}

.ad-quick-btns {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.ad-quick-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #ffffff;
  font-family: var(--ad-font);
  font-size: 12.5px;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, transform 0.15s;
}

.ad-quick-btn:hover {
  background: rgba(201, 168, 76, 0.2);
  transform: translateX(3px);
}

/* ---- Responsive (mobil) ---- */
@media (max-width: 450px) {
  #ad-chat-window {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: calc(100vh - 0px);
    border-radius: 0;
  }

  #ad-chat-launcher {
    right: 16px;
    bottom: 16px;
  }
}

/* ==========================================================================
   CAR CARDS UI
   ========================================================================== */
.ad-car-card {
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.15);
  /* Tmavší podklad uvnitř bubliny chatu */
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  overflow: hidden;
  margin: 10px 0;
  transition: transform 0.2s, background 0.2s;
}

.ad-car-card:first-child {
  margin-top: 4px;
}

.ad-car-card:last-child {
  margin-bottom: 4px;
}

.ad-car-card:hover {
  background: rgba(0, 0, 0, 0.25);
}

.ad-car-img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
}

.ad-car-content {
  padding: 10px 12px;
}

.ad-car-title {
  font-weight: 600;
  color: #ffffff;
  font-size: 14px;
  margin-bottom: 2px;
  line-height: 1.3;
}

.ad-car-price {
  color: var(--ad-gradient-start);
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
}

.ad-car-info {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 10px;
  line-height: 1.4;
}

.ad-car-btn {
  display: block;
  text-align: center;
  background: var(--ad-gradient-start);
  border: none;
  color: #ffffff;
  text-decoration: none;
  padding: 7px 0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
}

.ad-car-btn:hover {
  background: var(--ad-gradient-end);
  text-decoration: none;
}

.ad-car-btn:active {
  transform: scale(0.97);
}

/* ==========================================================================
   PRO FEATURES (Tooltip & Lead Form)
   ========================================================================== */
#ad-welcome-tooltip {
  position: fixed;
  bottom: 100px;
  right: 28px;
  background: var(--ad-white);
  color: var(--ad-primary);
  padding: 12px 18px;
  border-radius: var(--ad-radius-sm);
  box-shadow: var(--ad-shadow-sm);
  font-family: var(--ad-font);
  font-size: 13.5px;
  font-weight: 500;
  z-index: var(--ad-z);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#ad-welcome-tooltip.is-active {
  opacity: 1;
  transform: translateY(0);
}

#ad-welcome-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 24px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--ad-white);
}

.ad-widget-left #ad-welcome-tooltip {
  right: auto;
  left: 28px;
}

.ad-widget-left #ad-welcome-tooltip::after {
  right: auto;
  left: 24px;
}

#ad-lead-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  margin-top: 15px;
  animation: ad-fadeUp 0.4s ease forwards;
}

#ad-lead-form p {
  font-size: 12.5px;
  color: var(--ad-white);
  margin: 0 0 5px;
  line-height: 1.4;
  font-family: var(--ad-font);
  font-weight: 600;
}

.ad-lead-input {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--ad-white);
  font-family: var(--ad-font);
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

.ad-lead-input:focus {
  border-color: rgba(201, 168, 76, 0.5);
}

.ad-lead-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ad-gray-400);
  font-family: var(--ad-font);
  line-height: 1.4;
}

.ad-lead-checkbox a {
  color: var(--ad-gradient-start);
  text-decoration: underline;
}

.ad-lead-checkbox input {
  margin-top: 2px;
}

.ad-lead-btn {
  background: var(--ad-gradient-start);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 5px;
  transition: opacity 0.2s;
  font-family: var(--ad-font);
}

.ad-lead-btn:hover {
  opacity: 0.9;
}