/**
 * Floating WhatsApp Button Styles
 * This component creates a fixed WhatsApp button that appears on all pages
 * UPDATED: Enhanced specificity and consistency across all pages
 */

/* High specificity to ensure these styles are not overridden */
body .floating-whatsapp,
html .floating-whatsapp,
.floating-whatsapp {
    position: fixed !important;
    bottom: 30px !important;
    right: 30px !important;
    z-index: 10002 !important; /* Above bottom nav (10001) and filter bar (9999) */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 65px !important;
    height: 65px !important;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%) !important;
    color: white !important;
    border-radius: 50% !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    text-decoration: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: inherit !important;
    font-size: inherit !important;
    line-height: 1 !important;
    overflow: visible !important;
}

/* Hover effects with high specificity */
body .floating-whatsapp:hover,
html .floating-whatsapp:hover,
.floating-whatsapp:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2) !important;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%) !important;
    color: white !important;
}

/* Icon styling with high specificity */
body .floating-whatsapp i,
html .floating-whatsapp i,
.floating-whatsapp i {
    font-size: 30px !important;
    color: white !important;
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
}

/* Pulse animation for the button with high specificity */
body .floating-whatsapp::after,
html .floating-whatsapp::after,
.floating-whatsapp::after {
    content: '' !important;
    position: absolute !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%) !important;
    z-index: -1 !important;
    animation: pulse 2s infinite !important;
    top: 0 !important;
    left: 0 !important;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    70% {
        transform: scale(1.2);
        opacity: 0;
    }
    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

/* Responsive adjustments with high specificity */
@media (max-width: 768px) {
    body .floating-whatsapp,
    html .floating-whatsapp,
    .floating-whatsapp {
        bottom: 120px !important; /* Above bottom nav (56px) + filter bar (48px) + extra space (16px) */
        right: 20px !important; /* Floating position */
        left: auto !important; /* Remove full width */
        width: 60px !important; /* Circular button */
        height: 60px !important; /* Circular button */
        border-radius: 50% !important; /* Circular button */
        border: none !important; /* Remove border */
        z-index: 10000001 !important; /* Above search page header (10000000) */
    }
    
    body .floating-whatsapp i,
    html .floating-whatsapp i,
    .floating-whatsapp i {
        font-size: 28px !important;
    }
}

/* WhatsApp Chat Box Styles */
.whatsapp-chat-box {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 300px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 10001;
    animation: slideUp 0.3s ease-out;
}

.floating-whatsapp.open .whatsapp-chat-box {
    display: block;
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e5e5e5;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 12px;
}

.chat-info h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.chat-info p {
    margin: 0;
    font-size: 12px;
    color: #666;
}

.chat-close {
    background: none;
    border: none;
    color: #666;
    font-size: 16px;
    cursor: pointer;
    margin-left: auto;
}

.chat-body {
    padding: 16px;
}

.chat-message p {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #333;
}

.chat-footer {
    padding: 16px;
    border-top: 1px solid #e5e5e5;
}

.chat-start-btn {
    width: 100%;
    background: #25D366;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.whatsapp-btn {
    position: relative;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.whatsapp-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    z-index: -1;
    animation: pulse 2s infinite;
}

/* Mobile responsive for chat box */
@media (max-width: 768px) {
    .whatsapp-chat-box {
        width: 280px;
        bottom: 190px; /* Above the WhatsApp button (120px) + extra space (70px) */
        right: -10px;
        z-index: 10003 !important; /* Above the WhatsApp button */
    }
}

/* Ensure no conflicts with other WhatsApp buttons */
.floating-whatsapp.whatsapp-btn,
.floating-whatsapp.btn-whatsapp {
    width: 65px !important;
    height: 65px !important;
    border-radius: 50% !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    gap: 0 !important;
    margin-top: 0 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
}

/* Override any potential conflicting styles from styles.css */
.floating-whatsapp {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%) !important;
    color: white !important;
    border: none !important;
    padding: 0 !important;
    width: 65px !important;
    height: 65px !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
    margin: 0 !important;
    text-decoration: none !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
}
/* Page-specific mobile offsets to avoid overlap with fixed bars */
@media (max-width: 768px) {
  /* Product Listing: above bottom nav (56px) + filter bar (48px) */
  body:has(.productsMain) .floating-whatsapp,
  body.products-page .floating-whatsapp {
    bottom: calc(56px + 48px + env(safe-area-inset-bottom) + 16px) !important;
  }

  /* Product Detail: above primary action bar (56px) */
  body:has(.productView) .floating-whatsapp,
  body.product-page .floating-whatsapp {
    bottom: calc(56px + env(safe-area-inset-bottom) + 16px) !important;
  }

  /* Align chat box with button on listing page */
  body:has(.productsMain) .whatsapp-chat-box,
  body.products-page .whatsapp-chat-box {
    bottom: calc(56px + 48px + 60px + env(safe-area-inset-bottom)) !important;
  }

  /* Align chat box with button on product detail page */
  body:has(.productView) .whatsapp-chat-box,
  body.product-page .whatsapp-chat-box {
    bottom: calc(56px + 60px + env(safe-area-inset-bottom)) !important;
  }
}
