/**
 * BEEP! Contact Popup
 * 
 * Proactive WhatsApp/Phone contact widget with glassmorphism design
 * Position: Bottom-Left (Desktop) / Above Sticky-CTA (Mobile)
 */

/* ===================================================================
   POPUP CONTAINER
   =================================================================== */

.contact-popup {
    position: fixed;
    bottom: 24px;
    left: 24px;
    max-width: 360px;
    z-index: 1015;
    /* Under sticky-cta-bar (1020), above content */

    /* Glassmorphism */
    background: var(--glass-regular-surface);
    border: 1px solid var(--glass-regular-border);
    backdrop-filter: blur(var(--blur-regular));
    -webkit-backdrop-filter: blur(var(--blur-regular));

    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;

    /* Animation */
    transform: translateX(-120%);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.4s ease;
    pointer-events: none;
}

.contact-popup.show {
    transform: translateX(0);
    opacity: 1;
    pointer-events: all;
}

/* Mobile: Above Sticky-CTA-Bar */
@media (max-width: 767px) {
    .contact-popup {
        left: 16px;
        right: 16px;
        bottom: 80px;
        /* 80px = Sticky-CTA-Bar height + spacing */
        max-width: none;
    }
}

/* ===================================================================
   MINIMIZED STATE (Badge Mode)
   =================================================================== */

/* Minimized badge - bottom left on desktop, compact version */
.contact-popup.minimized {
    max-width: 220px;
    bottom: 24px;
    left: 24px;
    right: auto;
    transform: translateX(0);
    opacity: 1;
    pointer-events: all;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Animation is set below in dedicated animation section */
}

.contact-popup.minimized:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

/* Hide elements not needed in minimized state */
.contact-popup.minimized .contact-popup-close,
.contact-popup.minimized .contact-popup-text,
.contact-popup.minimized .contact-popup-actions {
    display: none;
}

/* Compact padding */
.contact-popup.minimized .contact-popup-content {
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--spacing-xs);
}

/* Smaller icon */
.contact-popup.minimized .contact-popup-icon {
    width: 32px;
    height: 32px;
    min-width: 32px; /* prevent flex shrink distortion */
    margin: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    animation: none;
}

.contact-popup.minimized .contact-popup-icon svg,
.contact-popup.minimized .contact-popup-icon i {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px;
    min-height: 18px;
    max-width: 18px;
    max-height: 18px;
    display: block;
    flex-shrink: 0;
}

/* Compact title */
.contact-popup.minimized .contact-popup-title {
    font-size: var(--font-size-body-small);
    font-weight: 600;
    margin: 0;
    text-align: left;
    line-height: 1.2;
    /* Critical: allow flex item to shrink and clip overflow */
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===================================================================
   ANIMATIONS - Icon Bobbing Only
   =================================================================== */

/* Headset icon subtle bobbing */
@keyframes headset-bob {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }
}

/* Apply bobbing to icon (clean, no glow) */
.contact-popup.minimized .contact-popup-icon {
    animation: headset-bob 3s ease-in-out 0.5s infinite;
}

/* Mobile: Top right corner to avoid sticky CTA bar */
@media (max-width: 767px) {
    .contact-popup.minimized {
        top: 80px;
        /* Below header */
        bottom: auto;
        right: 16px;
        left: auto;
        max-width: 210px;
        /* Smooth hide/show transition */
        transition: opacity 0.25s ease, transform 0.25s ease;
    }

    .contact-popup.minimized .contact-popup-title {
        font-size: 12px;
    }

    /* Hide badge while scrolling down */
    .contact-popup.minimized.scroll-hidden {
        opacity: 0 !important;
        transform: translateY(-16px) !important;
        pointer-events: none !important;
    }
}

/* ===================================================================
   CLOSE BUTTON
   =================================================================== */

.contact-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;

    background: transparent;
    border: none;
    border-radius: 50%;

    font-size: 24px;
    line-height: 1;
    color: var(--color-text-secondary);

    cursor: pointer;
    transition: all 0.2s ease;

    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.contact-popup-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--color-text-primary);
    transform: rotate(90deg);
}

.contact-popup-close:active {
    transform: rotate(90deg) scale(0.95);
}

/* ===================================================================
   POPUP CONTENT
   =================================================================== */

.contact-popup-content {
    padding: var(--spacing-lg);
    padding-top: var(--spacing-md);
    /* Less top padding due to close button */
}

.contact-popup-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--spacing-sm);

    background: linear-gradient(135deg,
            var(--color-primary) 0%,
            var(--color-primary-light) 100%);
    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    /* Subtle pulse animation */
    animation: popup-icon-pulse 2s ease-in-out infinite;
}

.contact-popup-icon .icon,
.contact-popup-icon i,
.contact-popup-icon svg {
    width: 24px;
    height: 24px;
    color: #FFFFFF !important;
    stroke: #FFFFFF !important;
}

@keyframes popup-icon-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.2);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(0, 0, 0, 0);
    }
}

.contact-popup-title {
    font-size: var(--font-size-heading-5);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    text-align: center;
    margin-bottom: var(--spacing-xs);
}

.contact-popup-text {
    font-size: var(--font-size-body-medium);
    line-height: var(--line-height-body-medium);
    color: var(--color-text-secondary);
    text-align: center;
    margin-bottom: var(--spacing-md);
}

/* ===================================================================
   ACTION BUTTONS
   =================================================================== */

.contact-popup-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.contact-popup-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);

    min-height: 44px;
    /* Touch-friendly */
    padding: 0 var(--spacing-md);

    font-family: var(--font-family);
    font-size: var(--font-size-body-medium);
    font-weight: var(--font-weight-semibold);
    text-decoration: none;

    border-radius: var(--radius-button);
    cursor: pointer;
    transition: all 0.2s ease;
}

.contact-popup-btn .icon {
    width: 18px;
    height: 18px;
}

/* WhatsApp Button - Primary with Pulse */
.contact-popup-btn-whatsapp {
    background-color: #25D366;
    /* WhatsApp Green */
    color: white;
    border: none;
    position: relative;
    overflow: hidden;
}

.contact-popup-btn-whatsapp::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.contact-popup-btn-whatsapp:hover::before {
    width: 300px;
    height: 300px;
}

.contact-popup-btn-whatsapp:hover {
    background-color: #20BA5A;
    /* Darker WhatsApp Green */
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.contact-popup-btn-whatsapp:active {
    transform: translateY(0);
}

/* Pulse animation for WhatsApp button */
@keyframes whatsapp-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(37, 211, 102, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
    }
}

.contact-popup-btn-whatsapp {
    animation: whatsapp-pulse 2s infinite;
}

/* Phone Button - Secondary */
.contact-popup-btn-phone {
    background-color: var(--glass-thin-surface);
    color: var(--color-text-primary);
    border: 1px solid var(--glass-thin-border);
    backdrop-filter: blur(var(--blur-thin));
}

.contact-popup-btn-phone:hover {
    background-color: var(--glass-regular-surface);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-medium);
}

.contact-popup-btn-phone:active {
    transform: translateY(0);
}

/* Mobile: Stack buttons vertically for better touch targets */
@media (max-width: 767px) {
    .contact-popup-actions {
        flex-direction: column;
    }

    .contact-popup-btn {
        width: 100%;
        min-height: 48px;
        /* Larger touch target on mobile */
    }
}

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

.contact-popup-close:focus-visible,
.contact-popup-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ===================================================================
   REDUCED MOTION
   =================================================================== */

@media (prefers-reduced-motion: reduce) {

    .contact-popup,
    .contact-popup-close,
    .contact-popup-btn {
        transition: none;
        animation: none;
    }

    .contact-popup.show {
        transform: none;
    }
}