/* ==========================================================================
   KUMAR SPORTS — NEOBRUTALIST WHATSAPP CHATBOT WIDGET
   Design Tokens:
   - Primary Accent: var(--yellow, #FFF569)
   - Accent Green: var(--green, #15803D)
   - Deep Base: var(--black, #000000)
   - Clean Surface: var(--white, #FFFFFF)
   - Neo-brutalist Stroke: 2.5px solid var(--black)
   - Neo-brutalist Shadow: 4px 4px 0px var(--black)
   ========================================================================== */

/* ---------- Floating Launcher Trigger ---------- */
.ks-bot-launcher {
  position: fixed;
  bottom: 24px;
  right: clamp(24px, 4.5vw, 64px); /* same inset as the hero content edge */
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--yellow, #FFF569);
  color: var(--black, #000000);
  border: 2.5px solid var(--black, #000000);
  border-radius: 999px;
  padding: 8px 16px 8px 12px;
  box-shadow: 4px 4px 0px var(--black, #000000);
  cursor: pointer;
  font-family: var(--font-head, 'Clash Grotesk', sans-serif);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px) scale(0.92);
  transition: opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1), transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.16s ease, background-color 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.ks-bot-launcher.is-ready {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.ks-bot-launcher.is-ready:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px var(--black, #000000);
}

.ks-bot-launcher.is-ready:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0px var(--black, #000000);
}

/* Hard guard while motion loader is active */
.motion .loader:not([style*="display: none"]) ~ * .ks-bot-launcher {
  opacity: 0 !important;
  pointer-events: none !important;
}

.ks-launcher-icon-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  background: var(--black, #000000);
  color: var(--yellow, #FFF569);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ks-launcher-icon-wrap svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ks-launcher-ping {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 11px;
  height: 11px;
  background: #22C55E;
  border: 2px solid var(--black, #000000);
  border-radius: 50%;
  animation: ks-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.ks-launcher-label {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: left;
}

.ks-launcher-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--black, #000000);
}

.ks-launcher-subtitle {
  font-size: 10.5px;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-weight: 600;
  color: #333333;
}

.ks-unread-pill {
  background: #EF4444;
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1.5px solid var(--black, #000000);
  margin-left: 2px;
}

/* ---------- Backdrop Overlay for Mobile / Focus ---------- */
.ks-bot-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 9992;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.ks-bot-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Chat Dialog Container ---------- */
.ks-bot-dialog {
  position: fixed;
  bottom: 92px;
  right: clamp(24px, 4.5vw, 64px);
  z-index: 9995;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 610px;
  max-height: calc(100vh - 120px);
  background: var(--white, #FFFFFF);
  border: 2.5px solid var(--black, #000000);
  border-radius: 16px;
  box-shadow: 8px 8px 0px var(--black, #000000);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-body, 'Inter', sans-serif);
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.97);
  transition: opacity 0.22s cubic-bezier(0.22, 1, 0.36, 1), transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.ks-bot-dialog.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Lenis Protection */
.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

/* Mobile Pull Down Handle */
.ks-bot-handle-bar {
  display: none;
  width: 100%;
  background: var(--black, #000000);
  padding: 8px 0 4px 0;
  text-align: center;
  cursor: pointer;
  user-select: none;
}

.ks-bot-handle-pill {
  display: inline-block;
  width: 38px;
  height: 4px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  transition: background 0.15s ease;
}

.ks-bot-handle-bar:hover .ks-bot-handle-pill {
  background: var(--yellow, #FFF569);
}

/* ---------- Header Bar ---------- */
.ks-bot-header {
  background: var(--black, #000000);
  color: var(--white, #FFFFFF);
  padding: 14px 16px;
  border-bottom: 2.5px solid var(--black, #000000);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
}

.ks-header-identity {
  display: flex;
  align-items: center;
  gap: 11px;
}

.ks-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  background: var(--yellow, #FFF569);
  color: var(--black, #000000);
  border: 2px solid var(--black, #000000);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  box-shadow: 2px 2px 0px rgba(255, 255, 255, 0.3);
}

.ks-avatar svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ks-avatar-status {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: #22C55E;
  border: 2px solid var(--black, #000000);
  border-radius: 50%;
}

.ks-header-meta {
  display: flex;
  flex-direction: column;
}

.ks-header-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ks-header-name {
  font-family: var(--font-head, 'Clash Grotesk', sans-serif);
  font-weight: 700;
  font-size: 15px;
  color: var(--white, #FFFFFF);
  letter-spacing: -0.01em;
}

.ks-header-badge {
  background: var(--yellow, #FFF569);
  color: var(--black, #000000);
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
}

.ks-header-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}

.ks-header-dot {
  width: 6px;
  height: 6px;
  background: #22C55E;
  border-radius: 50%;
  display: inline-block;
}

.ks-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ks-head-btn {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white, #FFFFFF);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ks-head-btn:hover {
  background: var(--yellow, #FFF569);
  color: var(--black, #000000);
  border-color: var(--black, #000000);
}

.ks-head-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2.2;
}

/* ---------- Chat Messages Canvas ---------- */
.ks-bot-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 16px;
  background: #F8F9F5;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Custom Scrollbar */
.ks-bot-body::-webkit-scrollbar {
  width: 6px;
}
.ks-bot-body::-webkit-scrollbar-track {
  background: #EFEFEF;
}
.ks-bot-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.45);
  border-radius: 999px;
}
.ks-bot-body::-webkit-scrollbar-thumb:hover {
  background: var(--black, #000000);
}

/* Message Rows */
.ks-msg-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 86%;
  animation: ks-msg-in 0.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.ks-msg-row.user-row {
  align-self: flex-end;
  align-items: flex-end;
}

.ks-msg-row.bot-row {
  align-self: flex-start;
  align-items: flex-start;
}

/* Bubbles */
.ks-bubble {
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.52;
  word-break: break-word;
}

.user-row .ks-bubble {
  background: var(--black, #000000);
  color: var(--white, #FFFFFF);
  border: 2px solid var(--black, #000000);
  border-radius: 14px 14px 2px 14px;
  box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.25);
}

.bot-row .ks-bubble {
  background: var(--white, #FFFFFF);
  color: var(--black, #000000);
  border: 2px solid var(--black, #000000);
  border-radius: 14px 14px 14px 2px;
  box-shadow: 3px 3px 0px var(--black, #000000);
}

.ks-bubble p {
  margin: 0 0 8px 0;
}
.ks-bubble p:last-child {
  margin-bottom: 0;
}

.ks-bubble strong {
  font-weight: 700;
  color: var(--black, #000000);
}

.user-row .ks-bubble strong {
  color: var(--yellow, #FFF569);
}

.ks-bubble ul {
  margin: 6px 0 8px 16px;
  padding: 0;
}

.ks-bubble li {
  margin-bottom: 4px;
}

.ks-msg-time {
  font-size: 10px;
  color: rgba(0, 0, 0, 0.45);
  font-family: var(--font-body, 'Inter', sans-serif);
  padding: 0 4px;
}

/* Call-to-Action WhatsApp Deep Link inside Bot Message */
.ks-bot-wa-action {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--yellow, #FFF569);
  color: var(--black, #000000);
  border: 2px solid var(--black, #000000);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 2px 2px 0px var(--black, #000000);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  width: 100%;
  justify-content: center;
}

.ks-bot-wa-action:hover {
  background: #25D366;
  color: #FFFFFF;
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0px var(--black, #000000);
}

.ks-bot-wa-action svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 2.2;
}

/* Typing Indicator */
.ks-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--white, #FFFFFF);
  border: 2px solid var(--black, #000000);
  border-radius: 12px 12px 12px 2px;
  box-shadow: 2px 2px 0px var(--black, #000000);
  width: fit-content;
}

.ks-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--black, #000000);
  border-radius: 50%;
  animation: ks-bounce 1.3s infinite ease-in-out;
}

.ks-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.ks-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* ---------- Quick Action Chips Tray ---------- */
.ks-chips-wrapper {
  background: var(--white, #FFFFFF);
  border-top: 1.5px solid rgba(0, 0, 0, 0.12);
  padding: 10px 12px 8px;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  flex-shrink: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  cursor: grab;
  user-select: none;
  scrollbar-width: thin;
  scrollbar-color: var(--black, #000000) #F0F0F0;
}

.ks-chips-wrapper.is-dragging {
  cursor: grabbing;
  scroll-behavior: auto !important;
}

.ks-chips-wrapper::-webkit-scrollbar {
  height: 4px;
}
.ks-chips-wrapper::-webkit-scrollbar-track {
  background: #F0F0F0;
  border-radius: 999px;
}
.ks-chips-wrapper::-webkit-scrollbar-thumb {
  background: var(--black, #000000);
  border-radius: 999px;
}

.ks-chip-btn {
  background: #F4F6F0;
  color: var(--black, #000000);
  border: 1.5px solid var(--black, #000000);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 1.5px 1.5px 0px var(--black, #000000);
  transition: all 0.14s ease;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  user-select: none;
}

.ks-chip-btn:hover {
  background: var(--yellow, #FFF569);
  transform: translate(-1px, -1px);
  box-shadow: 2.5px 2.5px 0px var(--black, #000000);
}

.ks-chip-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px var(--black, #000000);
}

/* ---------- Chat Footer & Input Form ---------- */
.ks-bot-footer {
  padding: 10px 12px;
  background: var(--white, #FFFFFF);
  border-top: 2.5px solid var(--black, #000000);
  flex-shrink: 0;
}

.ks-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ks-chat-input {
  flex: 1;
  background: #F4F6F0;
  border: 2px solid var(--black, #000000);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--black, #000000);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.ks-chat-input:focus {
  background: #FFFFFF;
  border-color: var(--black, #000000);
  box-shadow: 0 0 0 2px var(--yellow, #FFF569);
}

.ks-chat-input::placeholder {
  color: rgba(0, 0, 0, 0.45);
}

.ks-send-btn {
  width: 40px;
  height: 40px;
  background: var(--yellow, #FFF569);
  color: var(--black, #000000);
  border: 2px solid var(--black, #000000);
  border-radius: 10px;
  box-shadow: 2px 2px 0px var(--black, #000000);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.14s ease;
}

.ks-send-btn:hover {
  background: var(--black, #000000);
  color: var(--yellow, #FFF569);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0px var(--black, #000000);
}

.ks-send-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px var(--black, #000000);
}

.ks-send-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 2.3;
}

/* ---------- Keyframe Animations ---------- */
@keyframes ks-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.25);
    opacity: 0.8;
  }
}

@keyframes ks-bounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes ks-msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Responsive Mobile Styles ---------- */
@media (max-width: 640px) {
  body.ks-bot-open {
    overflow: hidden;
    touch-action: none;
  }

  body.ks-bot-open .ks-bot-launcher {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
  }

  .ks-bot-launcher {
    bottom: 18px;
    right: 16px;
    padding: 7px 14px 7px 10px;
    font-size: 13px;
  }

  .ks-bot-handle-bar {
    display: block;
  }

  .ks-bot-dialog {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 85vh;
    height: 85dvh;
    max-height: 88dvh;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.4);
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.2s ease;
  }

  .ks-bot-dialog.is-open {
    transform: translateY(0);
    opacity: 1;
  }

  .ks-bot-header {
    border-radius: 0;
    padding: 10px 14px;
  }

  .ks-head-btn {
    width: 36px;
    height: 36px;
  }

  .ks-bot-body {
    padding: 12px 14px;
    gap: 12px;
  }

  .ks-msg-row {
    max-width: 90%;
  }

  .ks-bubble {
    font-size: 13.5px;
    padding: 10px 12px;
  }

  .ks-chips-wrapper {
    padding: 9px 12px 8px;
    gap: 7px;
  }

  .ks-chip-btn {
    padding: 7px 12px;
    font-size: 12px;
    touch-action: manipulation;
  }

  .ks-bot-footer {
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .ks-chat-input {
    font-size: 16px; /* Stop iOS Safari auto-zoom on field focus */
    padding: 10px 12px;
  }

  .ks-send-btn {
    width: 40px;
    height: 40px;
  }
}
