/**
 * WhatsApp FAB Styles
 * Floating Action Button for WhatsApp Community Support
 * 
 * Layout: Opsi C - Text left, Icon right, CTA centered below icon area
 * 
 * @package ElevAIte Dashboard
 * @version 1.0.0
 * @date 2025-10-24
 */

/* ==============================================
   BASE STYLES
   ============================================== */

.whatsapp-fab {
    position: fixed !important;
    z-index: 1000 !important;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    /* Ensure FAB is always visible when shown */
    pointer-events: auto;
}

.whatsapp-fab.show {
    opacity: 1;
    transform: translateY(0);
}

/* Position variants */
.whatsapp-fab-bottom-right {
    bottom: 40px;
    right: 40px;
}

.whatsapp-fab-bottom-left {
    bottom: 40px;
    left: 40px;
}

/* ==============================================
   FAB BUTTON
   ============================================== */

.whatsapp-fab-button {
    display: block;
    position: relative;
    background: #25D366; /* WhatsApp Green */
    color: white;
    text-decoration: none;
    padding: 12px 20px 10px 20px; /* Reduced padding for compact look */
    border-radius: 50px;
    box-shadow: 
        0 4px 12px rgba(37, 211, 102, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 260px;
    max-width: 340px;
}

.whatsapp-fab-button:hover {
    background: #128C7E; /* Darker WhatsApp Green */
    box-shadow: 
        0 6px 16px rgba(37, 211, 102, 0.4),
        0 3px 6px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
    text-decoration: none;
    color: white;
}

.whatsapp-fab-button:active {
    transform: translateY(0);
    box-shadow: 
        0 2px 8px rgba(37, 211, 102, 0.3),
        0 1px 2px rgba(0, 0, 0, 0.1);
}

/* ==============================================
   CONTENT LAYOUT (2 Columns)
   Left: Message + CTA | Right: Icon
   ============================================== */

.whatsapp-fab-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* ==============================================
   TEXT COLUMN (Message + CTA stacked)
   ============================================== */

.whatsapp-fab-text-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ==============================================
   MESSAGE TEXT (Rotating)
   ============================================== */

.whatsapp-fab-message {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.2;
    color: white;
    text-align: right;
    transition: opacity 0.3s ease;
}

.whatsapp-fab-message.fade-out {
    opacity: 0;
}

.whatsapp-fab-message.fade-in {
    opacity: 1;
}

/* ==============================================
   CTA TEXT (Below message, align right in left column)
   ============================================== */

.whatsapp-fab-cta {
    font-size: 11px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9);
    text-align: right;
    line-height: 1.2;
}

/* ==============================================
   WHATSAPP ICON (Right column)
   ============================================== */

.whatsapp-fab-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.whatsapp-fab-icon svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.whatsapp-fab-cta .arrow {
    display: inline-block;
    margin-left: 4px;
    transition: transform 0.2s ease;
}

.whatsapp-fab-button:hover .whatsapp-fab-cta .arrow {
    transform: translateX(3px);
}

/* ==============================================
   DISMISS BUTTON
   ============================================== */

.whatsapp-fab-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 50%;
    background: #ffffff;
    color: #25D366;
    border: 2px solid #25D366;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    font-weight: bold;
    transition: all 0.2s ease;
    padding: 0;
    z-index: 10;
    /* Force box-sizing to prevent size issues */
    box-sizing: border-box;
}

.whatsapp-fab-close:hover {
    background: #25D366;
    color: white;
    transform: scale(1.1);
}

.whatsapp-fab-close:active {
    transform: scale(0.95);
}

/* ==============================================
   ANIMATIONS
   ============================================== */

/* Pulse animation for attention */
@keyframes pulse {
    0%, 100% {
        box-shadow: 
            0 4px 12px rgba(37, 211, 102, 0.3),
            0 2px 4px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 
            0 6px 20px rgba(37, 211, 102, 0.5),
            0 4px 8px rgba(0, 0, 0, 0.15);
    }
}

.whatsapp-fab-button.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* Fade in/out for message rotation */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ==============================================
   RESPONSIVE - TABLET & MOBILE
   ============================================== */

/* Apply mobile styles for all screens 768px and below */
@media screen and (max-width: 768px), screen and (max-device-width: 768px) {
    .whatsapp-fab-bottom-right {
        bottom: 24px;
        right: 24px;
    }
    
    .whatsapp-fab-bottom-left {
        bottom: 24px;
        left: 24px;
    }
    
    .whatsapp-fab-button {
        padding: 10px 18px 8px 18px;
        min-width: 240px;
        max-width: 320px;
    }
    
    .whatsapp-fab-message {
        font-size: 14px;
    }
    
    .whatsapp-fab-icon {
        width: 32px;
        height: 32px;
    }
    
    .whatsapp-fab-cta {
        font-size: 10px;
    }
    
    /* Force responsive close button size on tablet and below */
    .whatsapp-fab .whatsapp-fab-close,
    .whatsapp-fab-close,
    button.whatsapp-fab-close {
        min-width: 0 !important;
        min-height: 0 !important;
        max-width: none !important;
        max-height: none !important;
        width: 20px !important;
        height: 20px !important;
        font-size: 12px !important;
        top: -6px !important;
        right: -6px !important;
        border-width: 1.5px !important;
    }
}

/* ==============================================
   RESPONSIVE - MOBILE
   ============================================== */

/* Apply mobile styles for all screens 480px and below */
@media screen and (max-width: 480px), (max-device-width: 480px) {
    .whatsapp-fab-bottom-right {
        bottom: 20px;
        right: 20px;
    }
    
    .whatsapp-fab-bottom-left {
        bottom: 20px;
        left: 20px;
    }
    
    .whatsapp-fab-button {
        padding: 10px 16px 8px 16px;
        min-width: 220px;
        max-width: calc(100vw - 40px);
    }
    
    .whatsapp-fab-content {
        gap: 10px;
    }
    
    .whatsapp-fab-message {
        font-size: 13px;
    }
    
    .whatsapp-fab-icon {
        width: 30px;
        height: 30px;
    }
    
    .whatsapp-fab-cta {
        font-size: 9px;
    }
    
    /* Force responsive close button size on mobile */
    .whatsapp-fab .whatsapp-fab-close,
    .whatsapp-fab-close,
    button.whatsapp-fab-close {
        min-width: 0 !important;
        min-height: 0 !important;
        max-width: none !important;
        max-height: none !important;
        width: 18px !important;
        height: 18px !important;
        font-size: 11px !important;
        top: -4px !important;
        right: -4px !important;
        border-width: 1.5px !important;
    }
}

/* ==============================================
   VERY SMALL SCREENS
   ============================================== */

/* Apply very small screen styles for all screens 360px and below */
@media screen and (max-width: 360px), (max-device-width: 360px) {
    .whatsapp-fab {
        /* Don't hide on very small screens - just make it smaller */
        bottom: 16px !important;
        right: 16px !important;
        left: auto !important;
    }
    
    .whatsapp-fab-button {
        min-width: 180px;
        max-width: calc(100vw - 32px);
        padding: 8px 14px 6px 14px;
    }
    
    .whatsapp-fab-message {
        font-size: 12px;
    }
    
    .whatsapp-fab-icon {
        width: 28px;
        height: 28px;
    }
    
    .whatsapp-fab-cta {
        font-size: 8px;
    }
    
    /* Force responsive close button size on very small screens */
    .whatsapp-fab .whatsapp-fab-close,
    .whatsapp-fab-close,
    button.whatsapp-fab-close {
        min-width: 0 !important;
        min-height: 0 !important;
        max-width: none !important;
        max-height: none !important;
        width: 16px !important;
        height: 16px !important;
        font-size: 10px !important;
        top: -3px !important;
        right: -3px !important;
        border-width: 1.5px !important;
    }
}

/* ==============================================
   ACCESSIBILITY
   ============================================== */

/* Focus states for keyboard navigation */
.whatsapp-fab-button:focus {
    outline: 3px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.whatsapp-fab-close:focus {
    outline: 2px solid #25D366;
    outline-offset: 1px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .whatsapp-fab-button {
        border: 2px solid white;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .whatsapp-fab,
    .whatsapp-fab-button,
    .whatsapp-fab-message,
    .whatsapp-fab-close {
        transition: none;
        animation: none;
    }
    
    .whatsapp-fab-button.pulse {
        animation: none;
    }
}

/* ==============================================
   PRINT STYLES
   ============================================== */

@media print {
    .whatsapp-fab {
        display: none !important;
    }
}

