/* ============================================================
   AutoDealer AI Chat Widget – Premium Styles
   Light theme s nastavitelnou primární modrou barvou.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap');

:root {
  /* Dynamic vars passed from WP */
  --akm-chat-gradient-start: #1c2536;
  --akm-chat-gradient-end: #1c2536;
  --akm-chat-bg-dark: #ffffff;

  --akm-chat-white: #ffffff;
  --akm-chat-bubble-gray: #f3f3f3;
  --akm-chat-gray-200: #e2e8f0;
  --akm-chat-gray-400: #94a3b8;
  --akm-chat-gray-600: #475569;
  --akm-chat-text: #000000;
  --akm-chat-primary: #162235;

  --akm-chat-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  --akm-chat-shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.08);
  --akm-chat-radius: 12px;
  --akm-chat-radius-sm: 10px;
  --akm-chat-radius-chat: 10px 10px 0px 10px;
  --akm-chat-radius-chat-inverted: 10px 10px 10px 0px;
  --akm-chat-font: 'Manrope', sans-serif;
  --akm-chat-widget-width: clamp(420px, 30vw, 500px);
  --akm-chat-widget-height: min(720px, calc(100dvh - 48px));
  --akm-chat-z: 999999;
}

/* ---- Chat Window ---- */
.akm-chat-window {
  display: none !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  width: var(--akm-chat-widget-width) !important;
  height: var(--akm-chat-widget-height) !important;
  background: var(--akm-chat-white) !important;
  border-radius: var(--akm-chat-radius) !important;
  box-shadow: var(--akm-chat-shadow) !important;
  flex-direction: column !important;
  overflow: hidden !important;
  z-index: var(--akm-chat-z) !important;
  border: 1px solid var(--akm-chat-gray-200) !important;
  contain: layout paint;
}

.akm-chat-window.is-open {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

.akm-chat-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.akm-chat-overlay.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ---- Header ---- */
.akm-chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--akm-chat-white);
  border-bottom: 1px solid var(--akm-chat-gray-200);
  flex-shrink: 0;
}

.akm-chat-avatar-wrapper {
  position: relative;
  display: flex;
  flex-shrink: 0;
}

.akm-chat-online-dot {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 11px;
  height: 11px;
  background-color: #22c55e;
  border-radius: 50%;
  border: 1.5px solid var(--akm-chat-white);
  z-index: 2;
}

.akm-chat-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--akm-chat-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 24px;
}

.akm-chat-header-info {
  flex: 1;
  min-width: 0;
}

.akm-chat-header-name {
  font-family: var(--akm-chat-font);
  font-weight: 700;
  font-size: 17px;
  color: #000000 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.akm-chat-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.akm-chat-header-btn {
  width: 44px !important;
  height: 44px !important;
  border: none !important;
  background: transparent !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background 0.2s, color 0.2s !important;
  padding: 0 !important;
  box-shadow: none !important;
  color: var(--akm-chat-text);
}

.akm-chat-end-btn:hover {
  background: #FFF1F5 !important;
  color: #D6336C !important;
}

.akm-chat-header-btn:hover {
  background: var(--akm-chat-bubble-gray);
}

.akm-chat-minimize-icon {
  width: 14px;
  height: 10px;
  color: var(--akm-chat-text);
}

.logoChat {
  width: 28px;
  height: auto;
}

/* ---- Messages Area ---- */
.akm-chat-messages {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 20px !important;
  padding: 30px 20px !important;
  margin: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  background: #ffffff !important;
  scroll-behavior: auto !important;
  position: relative;
  z-index: 1;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.akm-chat-messages::-webkit-scrollbar {
  width: 4px;
}

.akm-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.akm-chat-messages::-webkit-scrollbar-thumb {
  background: var(--akm-chat-gray-200);
  border-radius: 2px;
}

/* ---- Message Bubbles ---- */
.akm-chat-msg {
  display: flex !important;
  align-items: flex-end !important;
  gap: 8px !important;
  width: 100% !important;
  margin-bottom: 0px !important;
}

.akm-chat-msg--bot {
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 4px !important;
}

.akm-chat-msg--user {
  flex-direction: row-reverse !important;
  text-align: left !important;
}

.akm-chat-bot-name-label {
  font-family: var(--akm-chat-font);
  font-size: 13px;
  font-weight: 700;
  color: #000000 !important;
  margin-bottom: 2px;
}

.akm-chat-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--akm-chat-bubble-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.akm-chat-bubble {
  max-width: 85% !important;
  font-family: var(--akm-chat-font) !important;
  font-size: 16px !important;
  line-height: 1.5 !important;
  word-wrap: break-word !important;
  white-space: pre-wrap !important;
  color: #000000 !important;
}

.akm-chat-msg--bot .akm-chat-bubble {
  background: transparent !important;
  color: #000000 !important;
  padding: 0 !important;
  border: none !important;
}

.akm-chat-msg--user .akm-chat-bubble {
  background: var(--akm-chat-bubble-gray) !important;
  color: #000000 !important;
  padding: 14px 20px !important;
  border-radius: var(--akm-chat-radius-chat) !important;
}

.akm-chat-msg-name {
  font-family: var(--akm-chat-font);
  font-size: 14px;
  font-weight: 700;
  color: #000000 !important;
  margin-bottom: 2px;
}



/* Markdown-like bold */
.akm-chat-bubble strong {
  font-weight: 700;
}

.akm-chat-bubble a {
  color: var(--akm-chat-gradient-start);
  text-decoration: underline;
}

/* ---- Typing / Loading Indicator ---- */
.akm-chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 0;
  background: transparent;
  width: fit-content;
}

.akm-chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--akm-chat-gray-400);
  display: block;
  animation: akm-chat-typing-bounce 1.2s ease-in-out infinite;
}

.akm-chat-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.akm-chat-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes akm-chat-typing-bounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }

  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ---- Input Area ---- */
.akm-chat-input-area {
    flex: 0 0 auto !important;
    position: relative !important;
    z-index: 5 !important;
    background: #fff !important;
    height: auto !important;
    min-height: 96px;
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom)) !important;
    border-top: 1px solid var(--akm-chat-gray-200);
    isolation: isolate;
    box-sizing: border-box !important;
    width: 100% !important;
}

.akm-chat-input-wrapper {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 44px;
    grid-template-rows: minmax(56px, auto) 32px;
    align-items: center !important;

    width: 100%;
    height: auto !important;
    min-height: 96px;
    max-height: 160px;

    position: relative !important;
    overflow: hidden;
    background: #fff !important;
    border: 1px solid var(--akm-chat-gray-200) !important;
    border-radius: 12px !important;
    transition: border-color 0.2s !important;
}

.akm-chat-input-wrapper:focus-within {
  border-color: var(--akm-chat-gray-400);
}

.akm-chat-lead-label {
  font-family: var(--akm-chat-font);
  font-size: 18px;
  font-weight: 700;
  color: var(--akm-chat-text);
  margin-bottom: -5px;
}

.akm-chat-chat-input {
    grid-column: 1 / -1;
    grid-row: 1;

    display: block;
    width: 100% !important;
    min-height: 56px !important;
    max-height: 112px !important;
    height: 56px;

    padding: 14px 16px 8px !important;
    margin: 0 !important;

    overflow-y: hidden;
    resize: none !important;
    box-sizing: border-box !important;
    
    background: transparent !important;
    border: none !important;
    color: #000000 !important;
    font-family: var(--akm-chat-font) !important;
    font-size: 16px !important;
    line-height: 1.5 !important;
    outline: none !important;
    box-shadow: none !important;
    touch-action: pan-y;
}

.akm-chat-chat-input::placeholder {
  color: var(--akm-chat-gray-600);
}

.akm-chat-char-counter {
    position: static !important;
    grid-column: 1;
    grid-row: 2;
    align-self: center;
    justify-self: start;

    margin: 0 0 0 16px;
    pointer-events: none;
    font-family: var(--akm-chat-font);
    font-size: 11px;
    color: var(--akm-chat-gray-400);
}

.akm-chat-send {
    position: static !important;
    grid-column: 2;
    grid-row: 2;
    align-self: center;
    justify-self: center;

    width: 40px !important;
    height: 40px !important;
    margin: 0 !important;
    border-radius: 8px !important;
    border: none !important;
    background: transparent !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease !important;
    padding: 0 !important;
    box-shadow: none !important;
}

.akm-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.akm-chat-send svg {
  width: 20px !important;
  height: 20px !important;
  fill: var(--akm-chat-primary) !important;
  display: block !important;
}

/* ---- Responsive (mobil) ---- */
@media (max-width: 768px) {
  .akm-chat-window,
  .akm-chat-window.is-open {
    position: fixed !important;
    left: 0 !important;
    right: auto !important;
    top: var(--akm-vv-top, 0px) !important;
    bottom: auto !important;

    width: 100% !important;
    max-width: none !important;

    height: var(--akm-vv-height, 100dvh) !important;
    max-height: var(--akm-vv-height, 100dvh) !important;
    min-height: 0 !important;

    transform: none !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }
}

/* ---- Login Button ---- */
.akm-login-button {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  gap: 8px;
  margin: 0 auto;
  width: 243px;
  min-height: 48px;
  background: #AA6BFF;
  border-radius: 24px;
  font-family: 'Poppins', sans-serif;
  font-style: normal;
  font-weight: 600;
  font-size: 16px;
  line-height: 24px;
  text-align: center;
  color: #FDF8FE;
  text-decoration: none;
  box-sizing: border-box;
}

/* ---- Minimized Bubble ---- */
.akm-chat-bubble-minimized {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  right: calc(20px + env(safe-area-inset-right));
  z-index: var(--akm-chat-z);
  background: var(--akm-chat-white);
  border-radius: 99px;
  box-shadow: var(--akm-chat-shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 8px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  min-height: 48px;
  border: 1px solid var(--akm-chat-gray-200);
}

.akm-chat-bubble-minimized:hover {
  transform: translateY(-2px);
  box-shadow: var(--akm-chat-shadow-sm);
}

.akm-chat-bubble-min-avatar {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
}

.akm-chat-bubble-min-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.akm-chat-bubble-min-dot {
  position: absolute;
  top: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background-color: #22c55e;
  border-radius: 50%;
  border: 2px solid var(--akm-chat-white);
}

.akm-chat-bubble-min-name {
  font-family: var(--akm-chat-font);
  font-weight: 700;
  font-size: 15px;
  color: var(--akm-chat-text);
  white-space: nowrap;
}

@media (max-width: 400px) {
  .akm-chat-bubble-min-name {
    display: none;
  }

  .akm-chat-bubble-minimized {
    padding: 8px;
    border-radius: 50%;
  }
}


/* ---- Initial Screen ---- */
.akm-initial-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #FFFFFF;
  z-index: 2;
}

.akm-initial-screen-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.akm-initial-spinner {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.akm-initial-spinner span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #98A2B3;
  opacity: 0.35;
  animation: akmInitialDot 1.2s ease-in-out infinite;
}

.akm-initial-spinner span:nth-child(2) {
  animation-delay: 0.15s;
}

.akm-initial-spinner span:nth-child(3) {
  animation-delay: 0.3s;
}

.akm-initial-screen-text {
  font-size: 15px;
  line-height: 1.5;
  color: #667085;
}

@keyframes akmInitialDot {

  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* ---- Busy Screen ---- */
.akm-busy-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: #FFFFFF;
  z-index: 3;
}

.akm-busy-screen-inner {
  max-width: 300px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.akm-busy-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 10px;
}

.akm-busy-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #F04438;
  box-shadow: 0 0 0 0 rgba(240, 68, 56, 0.25);
  animation: akmBusyDotPulse 1.8s ease-in-out infinite;
  flex: 0 0 8px;
}

.akm-busy-title {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
  color: #101828;
  margin: 0;
  padding-bottom: 1px;
  /* Optické vycentrování k tečce */
}

.akm-busy-text {
  font-size: 14px;
  line-height: 1.5;
  color: #667085;
  margin-bottom: 8px;
}

.akm-busy-actions {
  display: flex;
  justify-content: center;
  margin-top: 30px;
}

.akm-busy-close {
  min-width: 120px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px !important;
  border-radius: 10px;
  border: 1px solid #E0587E;
  background: #FFFFFF;
  color: #D6336C;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1 !important;
  box-sizing: border-box !important;
}

.akm-busy-close:hover {
  background: #FFF1F5;
  border-color: #D6336C;
}

@keyframes akmBusyDotPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(240, 68, 56, 0.25);
    opacity: 0.85;
  }

  50% {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(240, 68, 56, 0);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(240, 68, 56, 0);
    opacity: 0.85;
  }
}

/* ---- Page Lock ---- */
html.akm-chat-is-open {
    overflow: hidden !important;
    overscroll-behavior: none;
}

body.akm-page-locked {
    overflow: hidden !important;
    overscroll-behavior: none;
    touch-action: none;
}

/* ---- Confirmation Modal ---- */
.akm-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
}
.akm-confirm-overlay.is-active {
  opacity: 1;
  visibility: visible;
}
.akm-confirm-dialog {
  background: var(--akm-chat-white);
  border-radius: var(--akm-chat-radius);
  box-shadow: var(--akm-chat-shadow);
  width: min(520px, calc(100vw - 32px)) !important;
  max-width: 520px !important;
  padding: 34px 32px !important;
  box-sizing: border-box !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: translateY(20px);
  transition: transform 0.25s ease;
}
.akm-confirm-overlay.is-active .akm-confirm-dialog {
  transform: translateY(0);
}
.akm-confirm-title {
  font-family: var(--akm-chat-font);
  font-size: 20px;
  font-weight: 700;
  color: var(--akm-chat-text);
  margin: 0;
}
.akm-confirm-text {
  font-family: var(--akm-chat-font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--akm-chat-gray-600);
  margin: 0 0 16px 0;
}
.akm-confirm-actions {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) !important;
  gap: 16px !important;
  width: 100% !important;
  min-width: 0 !important;
  margin-top: 32px !important;
  align-items: stretch !important;
  box-sizing: border-box !important;
}

.akm-confirm-actions > button,
.akm-confirm-actions > a,
.akm-confirm-actions .akm-confirm-cancel,
.akm-confirm-actions .akm-confirm-submit {
  font-family: var(--akm-chat-font);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 10px !important;
  
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  min-height: 48px !important;
  padding: 12px 16px !important;
  margin: 0 !important;
  box-sizing: border-box !important;

  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  white-space: nowrap !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

.akm-confirm-cancel {
  background: #F3F6FB !important;
  border: 1px solid #C9D3E0 !important;
  color: #44516A !important;
}

.akm-confirm-cancel:hover {
  background: #e2e8f0 !important;
}

.akm-confirm-submit,
.akm-chat-danger-btn,
.akm-chat-end-confirm {
  background: #FF383C !important;
  border: 1px solid #FF383C !important;
  color: #fff !important;
}

.akm-confirm-submit:hover,
.akm-chat-danger-btn:hover,
.akm-chat-end-confirm:hover {
  filter: brightness(0.96);
}

@media (max-width: 640px) {
  .akm-confirm-dialog {
    width: calc(100vw - 32px) !important;
    max-width: calc(100vw - 32px) !important;
    padding: 24px 20px !important;
    box-sizing: border-box !important;
  }

  .akm-confirm-actions {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    width: 100% !important;
    margin-top: 24px !important;
    box-sizing: border-box !important;
  }

  .akm-confirm-actions .akm-confirm-cancel,
  .akm-confirm-actions .akm-confirm-submit {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 48px !important;
    padding: 12px 16px !important;
    box-sizing: border-box !important;

    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    white-space: normal !important;
    text-align: center !important;
  }
}