/* ====================================
   WhatsApp Popup Overlay - Reusable Component
   Version: 1.0
   ==================================== */

/* WhatsApp Button Fixed */
.whatsapp-popup-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9998;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
    transition: all 0.3s ease;
    animation: pulse-whatsapp 2s infinite;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.whatsapp-popup-btn:active {
    transform: scale(0.95);
}

.whatsapp-popup-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.6);
}

.whatsapp-popup-btn i {
    font-size: 32px;
    color: #fff;
}

/* Pulse Animation */
@keyframes pulse-whatsapp {
    0% {
        box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
    }
    50% {
        box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4), 0 0 0 10px rgba(37, 211, 102, 0.1);
    }
    100% {
        box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
    }
}

/* Badge for notifications */
.whatsapp-popup-btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid white;
}

/* Popup Overlay */
.whatsapp-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.whatsapp-popup-overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Popup Container */
.whatsapp-popup-container {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.whatsapp-popup-overlay.active .whatsapp-popup-container {
    animation: popIn 0.3s ease forwards;
}

@keyframes popIn {
    to {
        transform: scale(1);
    }
}

/* Popup Header */
.whatsapp-popup-header {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.whatsapp-popup-header-content {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.whatsapp-popup-header-icon {
    width: 48px;
    height: 48px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #25D366;
    flex-shrink: 0;
}

.whatsapp-popup-header-text {
    flex: 1;
}

.whatsapp-popup-header-text h3 {
    margin: 0;
    font-size: 19px;
    font-weight: 600;
    line-height: 1.3;
}

.whatsapp-popup-header-text p {
    margin: 2px 0 0;
    font-size: 14px;
    opacity: 0.95;
    line-height: 1.4;
}

.whatsapp-popup-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.whatsapp-popup-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.whatsapp-popup-close:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.95);
}

/* Popup Body */
.whatsapp-popup-body {
    padding: 24px;
    max-height: calc(80vh - 100px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #b4b4b4 #f0f0f0;
}

.whatsapp-popup-body::-webkit-scrollbar {
    width: 6px;
}

.whatsapp-popup-body::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.whatsapp-popup-body::-webkit-scrollbar-thumb {
    background: #25D366;
    border-radius: 3px;
}

.whatsapp-popup-body::-webkit-scrollbar-thumb:hover {
    background: #128C7E;
}

.whatsapp-popup-message {
    background: #f0f0f0;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    position: relative;
}

.whatsapp-popup-message::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 16px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid #f0f0f0;
}

.whatsapp-popup-message p {
    margin: 0;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
}

/* Contact Options */
.whatsapp-popup-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.whatsapp-popup-option {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.whatsapp-popup-option:hover {
    background: #e9f7ef;
    border-color: #25D366;
    transform: translateX(4px);
}

.whatsapp-popup-option:active {
    background: #d4edda;
    transform: translateX(2px) scale(0.98);
}

.whatsapp-popup-option-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    margin-right: 12px;
    flex-shrink: 0;
}

.whatsapp-popup-option-content h4 {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.whatsapp-popup-option-content p {
    margin: 0;
    font-size: 13px;
    color: #666;
}

/* Popup Footer */
.whatsapp-popup-footer {
    padding: 16px 24px;
    background: #f8f9fa;
    text-align: center;
    border-top: 1px solid #e0e0e0;
}

.whatsapp-popup-footer p {
    margin: 0;
    font-size: 12px;
    color: #666;
}

/* Responsive */
@media (max-width: 768px) {
    .whatsapp-popup-btn {
        width: 56px;
        height: 56px;
        bottom: 16px;
        right: 16px;
    }
    
    .whatsapp-popup-btn i {
        font-size: 28px;
    }
    
    .whatsapp-popup-container {
        width: 95%;
        max-width: 100%;
    }
    
    .whatsapp-popup-header {
        padding: 18px 20px;
    }

    .whatsapp-popup-header-icon {
        width: 44px;
        height: 44px;
        font-size: 26px;
    }

    .whatsapp-popup-header-text h3 {
        font-size: 17px;
    }

    .whatsapp-popup-header-text p {
        font-size: 13px;
    }
    
    .whatsapp-popup-body {
        padding: 20px;
    }

    .whatsapp-popup-message {
        padding: 14px;
        font-size: 14px;
    }

    .whatsapp-popup-option {
        padding: 12px 14px;
    }

    .whatsapp-popup-option-icon {
        width: 38px;
        height: 38px;
        font-size: 17px;
        margin-right: 10px;
    }

    .whatsapp-popup-option-content h4 {
        font-size: 14px;
    }

    .whatsapp-popup-option-content p {
        font-size: 12px;
    }
}

/* Small Mobile Devices (Portrait phones, less than 480px) */
@media (max-width: 480px) {
    .whatsapp-popup-btn {
        width: 52px;
        height: 52px;
        bottom: 12px;
        right: 12px;
    }
    
    .whatsapp-popup-btn i {
        font-size: 26px;
    }

    .whatsapp-popup-btn .badge {
        width: 20px;
        height: 20px;
        font-size: 10px;
        top: -4px;
        right: -4px;
    }

    .whatsapp-popup-container {
        width: 96%;
        margin: 0 2%;
    }

    .whatsapp-popup-header {
        padding: 16px 18px;
    }

    .whatsapp-popup-header-content {
        gap: 12px;
    }

    .whatsapp-popup-header-icon {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }

    .whatsapp-popup-header-text h3 {
        font-size: 16px;
        line-height: 1.25;
    }

    .whatsapp-popup-header-text p {
        font-size: 12px;
        margin-top: 1px;
    }

    .whatsapp-popup-close {
        width: 30px;
        height: 30px;
        font-size: 18px;
    }

    .whatsapp-popup-body {
        padding: 18px 16px;
    }

    .whatsapp-popup-message {
        padding: 12px;
        margin-bottom: 16px;
        font-size: 13px;
        border-radius: 6px;
    }

    .whatsapp-popup-message::before {
        left: -6px;
        top: 12px;
        border-top: 6px solid transparent;
        border-bottom: 6px solid transparent;
        border-right: 6px solid #f0f0f0;
    }

    .whatsapp-popup-options {
        gap: 10px;
    }

    .whatsapp-popup-option {
        padding: 11px 12px;
        border-radius: 6px;
    }

    .whatsapp-popup-option-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
        margin-right: 10px;
    }

    .whatsapp-popup-option-content h4 {
        font-size: 13px;
        margin-bottom: 2px;
    }

    .whatsapp-popup-option-content p {
        font-size: 11px;
        line-height: 1.3;
    }

    .whatsapp-popup-footer {
        padding: 12px 16px;
    }

    .whatsapp-popup-footer p {
        font-size: 11px;
        line-height: 1.4;
    }
}

/* Extra Small Devices (very small phones, less than 360px) */
@media (max-width: 360px) {
    .whatsapp-popup-btn {
        width: 48px;
        height: 48px;
        bottom: 10px;
        right: 10px;
    }
    
    .whatsapp-popup-btn i {
        font-size: 24px;
    }

    .whatsapp-popup-btn .badge {
        width: 18px;
        height: 18px;
        font-size: 9px;
    }

    .whatsapp-popup-container {
        width: 98%;
        margin: 0 1%;
        border-radius: 12px;
    }

    .whatsapp-popup-header {
        padding: 14px 16px;
        border-radius: 12px 12px 0 0;
    }

    .whatsapp-popup-header-content {
        gap: 10px;
    }

    .whatsapp-popup-header-icon {
        width: 36px;
        height: 36px;
        font-size: 22px;
    }

    .whatsapp-popup-header-text h3 {
        font-size: 15px;
        line-height: 1.2;
    }

    .whatsapp-popup-header-text p {
        font-size: 11px;
        margin-top: 1px;
    }

    .whatsapp-popup-close {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .whatsapp-popup-body {
        padding: 16px 14px;
    }

    .whatsapp-popup-message {
        padding: 10px;
        margin-bottom: 14px;
        font-size: 12px;
    }

    .whatsapp-popup-options {
        gap: 8px;
    }

    .whatsapp-popup-option {
        padding: 10px;
        border-radius: 6px;
    }

    .whatsapp-popup-option-icon {
        width: 32px;
        height: 32px;
        font-size: 15px;
        margin-right: 8px;
    }

    .whatsapp-popup-option-content h4 {
        font-size: 12px;
        margin-bottom: 2px;
    }

    .whatsapp-popup-option-content p {
        font-size: 10px;
        line-height: 1.3;
    }

    .whatsapp-popup-footer {
        padding: 10px 14px;
    }

    .whatsapp-popup-footer p {
        font-size: 10px;
    }
}

/* Landscape orientation adjustments for mobile */
@media (max-height: 600px) and (orientation: landscape) {
    .whatsapp-popup-overlay {
        align-items: flex-start;
        padding-top: 20px;
        overflow-y: auto;
    }

    .whatsapp-popup-container {
        max-height: 90vh;
        overflow-y: auto;
        margin: 10px auto;
    }

    .whatsapp-popup-header {
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .whatsapp-popup-body {
        padding: 16px;
    }

    .whatsapp-popup-message {
        margin-bottom: 12px;
    }

    .whatsapp-popup-options {
        gap: 8px;
    }

    .whatsapp-popup-option {
        padding: 10px 12px;
    }
}

/* Very short screens (like iPhone SE in landscape) */
@media (max-height: 400px) and (orientation: landscape) {
    .whatsapp-popup-btn {
        width: 44px;
        height: 44px;
        bottom: 8px;
        right: 8px;
    }

    .whatsapp-popup-btn i {
        font-size: 22px;
    }

    .whatsapp-popup-container {
        max-height: 95vh;
    }

    .whatsapp-popup-header {
        padding: 12px 16px;
    }

    .whatsapp-popup-header-icon {
        width: 32px;
        height: 32px;
        font-size: 20px;
    }

    .whatsapp-popup-header-text h3 {
        font-size: 14px;
    }

    .whatsapp-popup-header-text p {
        font-size: 11px;
    }

    .whatsapp-popup-body {
        padding: 12px;
    }

    .whatsapp-popup-message {
        padding: 8px;
        font-size: 11px;
    }

    .whatsapp-popup-option {
        padding: 8px 10px;
    }

    .whatsapp-popup-option-icon {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .whatsapp-popup-footer {
        padding: 8px 12px;
    }
}

/* Accessibility */
.whatsapp-popup-btn:focus,
.whatsapp-popup-close:focus,
.whatsapp-popup-option:focus {
    outline: 3px solid rgba(37, 211, 102, 0.5);
    outline-offset: 2px;
}

/* Hide button on print */
@media print {
    .whatsapp-popup-btn,
    .whatsapp-popup-overlay {
        display: none !important;
    }
}