/**
 * Pop-up Styles
 * 
 * Styles for all popup layout types with smooth animations
 * 
 * @package Commerce_Elite
 */

/* =================================================================
   BASE POPUP STYLES
   ================================================================= */

.ce-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
}

.ce-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1;
}

.ce-popup-container {
    position: relative;
    z-index: 2;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.ce-popup-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(0, 0, 0, 0.8); /* Darker for visibility */
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999; /* High z-index to stay on top */
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); /* Shadow for visibility */
}

.ce-popup-close:hover {
    background: #d63638;
    transform: rotate(90deg);
    box-shadow: 0 4px 12px rgba(214, 54, 56, 0.4);
}

.ce-popup-close svg {
    width: 20px;
    height: 20px;
    stroke-width: 3; /* Thicker lines for visibility */
}

.ce-popup-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

/* Prevent body scroll when popup is active */
body.ce-popup-active {
    overflow: hidden;
}


/* =================================================================
   LAYOUT: CENTER MODAL
   ================================================================= */

.ce-popup-layout-center_modal .ce-popup-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 600px;
    min-height: 200px; /* Minimum height for content */
    max-height: 90vh;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: ce-popup-fade-in 0.3s ease;
    display: flex;
    flex-direction: column;
}

.ce-popup-layout-center_modal .ce-popup-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px 30px 30px 30px; /* Extra top padding for close button */
}

@keyframes ce-popup-fade-in {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}


/* =================================================================
   LAYOUT: FULLSCREEN OVERLAY
   ================================================================= */

.ce-popup-layout-fullscreen .ce-popup-overlay {
    background: rgba(0, 0, 0, 0.95);
}

.ce-popup-layout-fullscreen .ce-popup-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95%;
    max-width: 1200px;
    min-height: 80vh; /* Ensure minimum height */
    max-height: 95vh; /* Allow taller content */
    background: #fff;
    border-radius: 0;
    animation: ce-popup-scale-in 0.4s ease;
    display: flex;
    flex-direction: column;
}

.ce-popup-layout-fullscreen .ce-popup-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
}

.ce-popup-layout-fullscreen .ce-popup-close {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 999;
    background: rgba(0, 0, 0, 0.8); /* Darker background */
    border: 2px solid #fff; /* White border for visibility */
}

.ce-popup-layout-fullscreen .ce-popup-close:hover {
    background: #d63638;
    border-color: #d63638;
}


@keyframes ce-popup-scale-in {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}


/* =================================================================
   LAYOUT: SLIDE-IN FROM LEFT
   ================================================================= */

.ce-popup-layout-slide_left .ce-popup-container {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 90%;
    max-width: 500px;
    background: #fff;
    animation: ce-popup-slide-in-left 0.4s ease;
}

@keyframes ce-popup-slide-in-left {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}


/* =================================================================
   LAYOUT: SLIDE-IN FROM RIGHT
   ================================================================= */

.ce-popup-layout-slide_right .ce-popup-container {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 90%;
    max-width: 500px;
    background: #fff;
    animation: ce-popup-slide-in-right 0.4s ease;
}

@keyframes ce-popup-slide-in-right {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}


/* =================================================================
   LAYOUT: SLIDE-IN FROM BOTTOM
   ================================================================= */

.ce-popup-layout-slide_bottom .ce-popup-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 80vh;
    background: #fff;
    border-radius: 20px 20px 0 0;
    animation: ce-popup-slide-in-bottom 0.4s ease;
}

@keyframes ce-popup-slide-in-bottom {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}


/* =================================================================
   LAYOUT: CORNER BOTTOM RIGHT
   ================================================================= */

.ce-popup-layout-corner_bottom_right .ce-popup-overlay {
    background: transparent;
    pointer-events: none;
}

.ce-popup-layout-corner_bottom_right .ce-popup-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 90%;
    max-width: 400px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.3);
    animation: ce-popup-slide-in-corner-br 0.4s ease;
}

@keyframes ce-popup-slide-in-corner-br {
    from {
        opacity: 0;
        transform: translate(20px, 20px);
    }
    to {
        opacity: 1;
        transform: translate(0, 0);
    }
}


/* =================================================================
   LAYOUT: CORNER BOTTOM LEFT
   ================================================================= */

.ce-popup-layout-corner_bottom_left .ce-popup-overlay {
    background: transparent;
    pointer-events: none;
}

.ce-popup-layout-corner_bottom_left .ce-popup-container {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 90%;
    max-width: 400px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.3);
    animation: ce-popup-slide-in-corner-bl 0.4s ease;
}

@keyframes ce-popup-slide-in-corner-bl {
    from {
        opacity: 0;
        transform: translate(-20px, 20px);
    }
    to {
        opacity: 1;
        transform: translate(0, 0);
    }
}


/* =================================================================
   LAYOUT: BAR TOP
   ================================================================= */

.ce-popup-layout-bar_top .ce-popup-overlay {
    background: transparent;
    pointer-events: none;
}

.ce-popup-layout-bar_top .ce-popup-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    animation: ce-popup-slide-down 0.3s ease;
}

@keyframes ce-popup-slide-down {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}


/* =================================================================
   LAYOUT: BAR BOTTOM
   ================================================================= */

.ce-popup-layout-bar_bottom .ce-popup-overlay {
    background: transparent;
    pointer-events: none;
}

.ce-popup-layout-bar_bottom .ce-popup-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #fff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    animation: ce-popup-slide-up 0.3s ease;
}

@keyframes ce-popup-slide-up {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}


/* =================================================================
   RESPONSIVE STYLES
   ================================================================= */

@media (max-width: 768px) {
    /* Center modal */
    .ce-popup-layout-center_modal .ce-popup-container {
        width: 95%;
        max-width: none;
    }
    
    /* Fullscreen on mobile */
    .ce-popup-layout-fullscreen .ce-popup-container {
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        transform: none;
        border-radius: 0;
    }
    
    /* Side slides become full width */
    .ce-popup-layout-slide_left .ce-popup-container,
    .ce-popup-layout-slide_right .ce-popup-container {
        width: 100%;
        max-width: none;
    }
    
    /* Corners become full width */
    .ce-popup-layout-corner_bottom_right .ce-popup-container,
    .ce-popup-layout-corner_bottom_left .ce-popup-container {
        bottom: 0;
        left: 0;
        right: auto;
        width: 100%;
        max-width: none;
        border-radius: 20px 20px 0 0;
    }
}


/* =================================================================
   CONTENT STYLING (DEFAULT)
   ================================================================= */

.ce-popup-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
}

.ce-popup-content h1,
.ce-popup-content h2,
.ce-popup-content h3 {
    margin-top: 0;
}

.ce-popup-content a {
    color: #2271b1;
}

.ce-popup-content a:hover {
    text-decoration: underline;
}

.ce-popup-content img {
    max-width: 100%;
    height: auto;
}

.ce-popup-content form {
    margin: 20px 0;
}

.ce-popup-content input[type="text"],
.ce-popup-content input[type="email"],
.ce-popup-content input[type="tel"],
.ce-popup-content textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    margin-bottom: 15px;
}

.ce-popup-content button,
.ce-popup-content input[type="submit"] {
    background: #2271b1;
    color: #fff;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.ce-popup-content button:hover,
.ce-popup-content input[type="submit"]:hover {
    background: #135e96;
}


/* =================================================================
   SCROLLBAR STYLING (FOR LONG CONTENT)
   ================================================================= */

.ce-popup-container::-webkit-scrollbar {
    width: 8px;
}

.ce-popup-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ce-popup-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.ce-popup-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}


/* =================================================================
   PERFORMANCE OPTIMIZATION
   ================================================================= */

.ce-popup {
    will-change: opacity;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

.ce-popup-container {
    will-change: transform;
    transform: translateZ(0);
}


/* =================================================================
   ACCESSIBILITY
   ================================================================= */

.ce-popup-close:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Screen reader only text */
.ce-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}