/* ==============================================================================
   Samkaksha Foundation - Enhanced UI/UX Widgets (WhatsApp, AI Assistant & Mobile Responsiveness)
   ============================================================================== */

/* --- Base Mobile Polish --- */
html, body {
  overflow-x: hidden !important;
  max-width: 100vw;
  width: 100%;
  -webkit-text-size-adjust: 100%;
}

/* Remove legacy right-side React WhatsApp icon if any */
a[aria-label="Chat on WhatsApp"]:not(.sam-wa-btn),
a[href*="wa.me"][class*="rounded-full"][class*="fixed"]:not(.sam-wa-btn) {
  display: none !important;
}

/* ==============================================================================
   1. FLOATING WHATSAPP CLICK-TO-CHAT (Positioned on Bottom-Left for Perfect Balance)
   ============================================================================== */
.sam-wa-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  right: auto !important;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Poppins', sans-serif;
  text-decoration: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (max-width: 768px) {
  .sam-wa-container {
    bottom: 16px;
    left: 16px;
    right: auto !important;
  }
}

/* HIDE WHATSAPP COMPLETELY WHENEVER CHATBOT IS ACTIVE OR OPEN */
body.sam-chat-open .sam-wa-container,
body.sam-chat-open #sam-wa-widget,
.sam-wa-container.is-hidden {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: scale(0.6) !important;
}

.sam-wa-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.4), 0 2px 6px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  position: relative;
  outline: none;
  border: none;
}

@media (max-width: 768px) {
  .sam-wa-btn {
    width: 50px;
    height: 50px;
  }
}

.sam-wa-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 28px rgba(37, 211, 102, 0.55), 0 4px 8px rgba(0, 0, 0, 0.2);
}

.sam-wa-btn:active {
  transform: scale(0.95);
}

/* Pulsating radar ring */
.sam-wa-btn::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid #25D366;
  opacity: 0.8;
  animation: sam-wa-pulse 2.2s infinite;
  pointer-events: none;
}

@keyframes sam-wa-pulse {
  0% {
    transform: scale(0.95);
    opacity: 0.9;
  }
  70% {
    transform: scale(1.35);
    opacity: 0;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

.sam-wa-icon {
  width: 30px;
  height: 30px;
  fill: currentColor;
}

@media (max-width: 768px) {
  .sam-wa-icon {
    width: 26px;
    height: 26px;
  }
}

.sam-wa-badge {
  display: none !important;
}

/* ==============================================================================
   2. AI SUPPORT ASSISTANT / CHATBOT (FULL RESPONSIVE & COLLISION FREE)
   ============================================================================== */

/* Base Root Container */
#sam-chatbot-root,
.sam-chatbot-root {
  z-index: 9995 !important;
}

/* Desktop Chatbot Modal */
@media (min-width: 641px) {
  #sam-chatbot-modal,
  .sam-chatbot-modal,
  .sam-chatbot-root > div.animate-in {
    width: 360px !important;
    max-width: 90vw !important;
    height: 520px !important;
    max-height: calc(100vh - 110px) !important;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.2), 0 8px 18px rgba(0, 0, 0, 0.08) !important;
    border-radius: 18px !important;
  }
}

/* ==============================================================================
   3. MOBILE SCREEN STYLING (Screens <= 640px)
   ============================================================================== */
@media (max-width: 640px) {
  /* Expand chatbot root to full screen when open */
  body.sam-chat-open #sam-chatbot-root,
  body.sam-chat-open .sam-chatbot-root {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    top: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    z-index: 100000 !important;
    pointer-events: none !important;
  }

  /* Full Screen / Bottom Sheet Mobile Experience */
  #sam-chatbot-modal,
  .sam-chatbot-modal,
  .sam-chatbot-root > div.animate-in {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    z-index: 100001 !important;
    background: #ffffff !important;
    pointer-events: auto !important;
  }

  /* Chatbot Header */
  #sam-chatbot-modal > div:first-child,
  .sam-chatbot-modal > div:first-child,
  .sam-chatbot-root > div.animate-in > div:first-child {
    padding: 16px 18px !important;
    padding-top: max(16px, env(safe-area-inset-top)) !important;
    flex-shrink: 0 !important;
  }

  /* Message List Area */
  #sam-chatbot-modal > div:nth-child(2),
  .sam-chatbot-modal > div:nth-child(2),
  .sam-chatbot-root > div.animate-in > div:nth-child(2) {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 16px !important;
  }

  /* Input Footer Bar */
  #sam-chatbot-modal > div:last-child,
  .sam-chatbot-modal > div:last-child,
  .sam-chatbot-root > div.animate-in > div:last-child {
    padding: 12px 14px !important;
    padding-bottom: max(14px, env(safe-area-inset-bottom)) !important;
    flex-shrink: 0 !important;
    background: #ffffff !important;
    border-top: 1px solid #e2e8f0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }

  /* Mobile Input Text Box (16px font prevents iOS Safari auto-zoom) */
  #sam-chatbot-modal > div:last-child input,
  .sam-chatbot-modal > div:last-child input,
  .sam-chatbot-root > div.animate-in > div:last-child input {
    font-size: 16px !important;
    padding: 10px 14px !important;
    border-radius: 12px !important;
  }

  /* Mobile Send Button: 100% visible, unobstructed, touch-friendly 44x44 target */
  #sam-chatbot-modal > div:last-child button,
  .sam-chatbot-modal > div:last-child button,
  .sam-chatbot-root > div.animate-in > div:last-child button {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }

  /* Hide the redundant bottom-right circular toggle button when modal is open on mobile */
  body.sam-chat-open #sam-chatbot-root > button,
  body.sam-chat-open .sam-chatbot-root > button,
  body.sam-chat-open .sam-chatbot-root button.rounded-full {
    display: none !important;
  }
}

/* ==============================================================================
   4. HERO LANDING RESPONSIVE IMAGE & TEXT ALIGNMENT (Mobile View Optimization)
   ============================================================================== */
@media (max-width: 768px) {
  /* Shift hero focal point naturally so polaroid photo frame is fully visible without clipping */
  img[alt="Children learning"],
  img[src*="hero_landing"] {
    object-position: 58% center !important;
  }

  /* Keep mobile hero title and script neatly aligned over road/sky without overlapping photo */
  .relative.h-\[80vh\] .max-w-4xl,
  .relative[class*="h-"] .max-w-4xl {
    max-width: min(290px, 72vw) !important;
    margin-top: 2rem !important;
  }

  .relative.h-\[80vh\] h1,
  .relative[class*="h-"] h1 {
    font-size: 2.25rem !important;
    line-height: 1.15 !important;
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.9) !important;
  }

  .relative.h-\[80vh\] span.font-handwriting,
  .relative[class*="h-"] span.font-handwriting {
    font-size: 2.5rem !important;
    line-height: 1.2 !important;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8) !important;
    margin-bottom: 0.5rem !important;
  }
}

/* ==============================================================================
   5. ADMIN GLOBAL SETTINGS - LOCK & EDIT MODE STYLING
   ============================================================================== */
.settings-locked input,
.settings-locked select,
.settings-locked textarea {
  pointer-events: none !important;
  opacity: 0.8 !important;
  background-color: #f8fafc !important;
  border-color: #e2e8f0 !important;
  cursor: not-allowed !important;
}

.settings-editing input,
.settings-editing select,
.settings-editing textarea {
  pointer-events: auto !important;
  opacity: 1 !important;
  background-color: #ffffff !important;
  border-color: #ec4899 !important;
  box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.1) !important;
}
