/* ========================================================================
   CartSavior Pro :: Popup Builder Frontend Styles (v3 - Direct Replica)
   
   This file is a direct replica of the builder's own stylesheet, with
   ONLY the admin-specific UI selectors removed to ensure a pixel-perfect
   match on the live site.
   
   MODIFIED: All selectors prepended with #csp-popup-builder-root
   to increase specificity and prevent theme conflicts.
======================================================================== */

/* --- GLOBAL STYLES & FONT IMPORTS --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');


:root {
    --csp-dark-bg: #1e2029;
    --csp-light-bg: #292c3a;
    --csp-primary: #6c56f9;
    --csp-text-light: #ffffff;
    --csp-text-medium: #aeb2c2;
    --csp-text-dark: #333333;
    --csp-border-color: #4a4f6b;
}

/* --- POPUP PREVIEW STYLES --- */
#csp-popup-builder-root .csp-popup-v1-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    font-family: 'Inter', sans-serif;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
}
#csp-popup-builder-root .csp-popup-v1-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease;
}

#csp-popup-builder-root .csp-popup-v1-popup-container {
    position: relative;
    background: linear-gradient(135deg, #4c46e6, #2d9cdb);
    padding: 2.5rem;
    border-radius: 16px;
    width: 480px;
    max-width: 90%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

#csp-popup-builder-root .csp-popup-v1-popup-content-area {
    min-height: 50px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
}

/* Text Elements */
#csp-popup-builder-root .csp-popup-v1-editable-headline {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    margin: 0;
}

#csp-popup-builder-root .csp-popup-v1-editable-text {
    font-size: 1rem;
    color: #e0e0e0;
    margin: 0;
}

/* Button Element */
#csp-popup-builder-root .csp-popup-v1-editable-button {
    background-color: #fff;
    color: var(--csp-text-dark);
    padding: 0.8rem 1.6rem;
    border-radius: 8px;
    text-decoration: none;
    display: inline-block;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease-in-out;
    margin: 0 auto;
}

#csp-popup-builder-root .csp-popup-v1-editable-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Image Element */
#csp-popup-builder-root .csp-popup-v1-editable-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
}

/* Close Button */
#csp-popup-builder-root .csp-popup-v1-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.2);
    color: #ffffff;
    font-size: 16px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    outline: none;
    border: none;
}

#csp-popup-builder-root .csp-popup-v1-close-btn:hover {
    transform: scale(1.1);
    background-color: rgba(0, 0, 0, 0.4);
}

/* Form Elements */
#csp-popup-builder-root .csp-popup-v1-form-wrapper {
    width: 100%;
}

#csp-popup-builder-root .csp-popup-v1-form-field {
    margin-bottom: 12px;
    text-align: left;
}

#csp-popup-builder-root .csp-popup-v1-form-field label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #f1f1f1;
    margin-bottom: 6px;
}

#csp-popup-builder-root .csp-popup-v1-form-field input {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    font-size: 16px;
    background-color: #2c3140;
    border: 1px solid var(--csp-border-color);
    border-radius: 8px;
    color: var(--csp-text-light);
    transition: all 0.2s ease-in-out;
}

#csp-popup-builder-root .csp-popup-v1-form-field input:focus {
    outline: none;
    border-color: var(--csp-primary);
    box-shadow: 0 0 0 3px rgba(108, 86, 249, 0.2);
}

#csp-popup-builder-root .csp-popup-v1-form-submit-button {
    width: 100%;
    height: 48px;
    margin-top: 8px;
    transition: all 0.2s ease-in-out;
    background-color: var(--csp-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
}

#csp-popup-builder-root .csp-popup-v1-form-submit-button:hover {
    background-color: #5a48d8;
}

#csp-popup-builder-root .csp-popup-v1-form-message {
    font-size: 12px;
    text-align: center;
    margin-top: 12px;
    color: var(--csp-text-medium);
}

#csp-popup-builder-root .csp-popup-v1-success-icon {
    font-size: 48px;
    color: #22C55E;
    margin-bottom: 16px;
    display: block;
    text-align: center;
}

/* Countdown Timer */
#csp-popup-builder-root .csp-popup-v1-countdown-wrapper {
    width: 100%;
    text-align: center;
}

#csp-popup-builder-root .csp-popup-v1-countdown-microcopy {
    font-size: 14px;
    color: var(--csp-text-medium);
    margin: 0 0 8px 0;
}

#csp-popup-builder-root .csp-popup-v1-countdown-timer {
    display: flex;
    justify-content: center;
    gap: 16px;
}

#csp-popup-builder-root .csp-popup-v1-countdown-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: rgba(0,0,0,0.2);
    padding: 8px 12px;
    border-radius: 6px;
    min-width: 60px;
}

#csp-popup-builder-root .csp-popup-v1-countdown-number {
    font-size: 28px;
    font-weight: 700;
    color: #FFFFFF;
    line-height: 1.1;
}

#csp-popup-builder-root .csp-popup-v1-countdown-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--csp-text-medium);
    text-transform: uppercase;
}

#csp-popup-builder-root .csp-popup-v1-countdown-expired-message {
    font-size: 18px;
    font-weight: 500;
    color: #EF4444;
    padding: 16px;
}

/* Coupon Styles */
#csp-popup-builder-root .csp-popup-v1-coupon-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#csp-popup-builder-root .csp-popup-v1-coupon-inner {
    width: 100%;
    max-width: 320px;
    border-radius: 8px;
    overflow: visible;
}

#csp-popup-builder-root .csp-popup-v1-coupon-microcopy {
    font-size: 12px;
    color: var(--csp-text-medium);
    margin-top: 8px;
}

#csp-popup-builder-root .csp-coupon-layout-default, 
#csp-popup-builder-root .csp-coupon-layout-ticket, 
#csp-popup-builder-root .csp-coupon-layout-modern, 
#csp-popup-builder-root .csp-coupon-layout-codeonly { 
    display: none; 
}

#csp-popup-builder-root .csp-popup-v1-coupon-wrapper.default-style .csp-coupon-layout-default { display: flex; }
#csp-popup-builder-root .csp-popup-v1-coupon-wrapper.ticket-style .csp-coupon-layout-ticket { display: flex; }
#csp-popup-builder-root .csp-popup-v1-coupon-wrapper.modern-style .csp-coupon-layout-modern { display: flex; }
#csp-popup-builder-root .csp-popup-v1-coupon-wrapper.codeonly-style .csp-coupon-layout-codeonly { display: block; }

#csp-popup-builder-root .csp-coupon-layout-default {
    background-color: #f3f4f6;
    border: 2px dashed #d1d5db;
}

#csp-popup-builder-root .csp-popup-v1-coupon-code-text {
    flex-grow: 1;
    padding: 12px 16px;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

#csp-popup-builder-root .csp-popup-v1-coupon-copy-btn {
    flex-shrink: 0;
    padding: 12px 16px;
    border: none;
    border-left: 2px dashed #d1d5db;
    background-color: #e5e7eb;
    color: #1f2937;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

#csp-popup-builder-root .csp-popup-v1-coupon-copy-btn:hover {
    background-color: #d1d5db;
}

#csp-popup-builder-root .csp-popup-v1-coupon-copy-btn.copied {
    background-color: #22c55e;
    color: white;
}

#csp-popup-builder-root .csp-coupon-layout-ticket {
    position: relative;
    max-width: 420px;
}

#csp-popup-builder-root .csp-coupon-layout-ticket::before, 
#csp-popup-builder-root .csp-coupon-layout-ticket::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background-color: var(--csp-dark-bg);
    border-radius: 50%;
}

#csp-popup-builder-root .csp-coupon-layout-ticket::before { left: -10px; }
#csp-popup-builder-root .csp-coupon-layout-ticket::after { right: -10px; }

#csp-popup-builder-root .csp-coupon-ticket-main {
    flex-grow: 1;
    background-color: #ffcc00;
    padding: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
}

#csp-popup-builder-root .csp-coupon-ticket-side-text {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-weight: bold;
    color: #333;
    padding-right: 16px;
    margin-right: 16px;
    border-right: 2px dashed #333;
    font-size: 14px;
}

#csp-popup-builder-root .csp-coupon-ticket-content {
    text-align: center;
    flex-grow: 1;
}

#csp-popup-builder-root .csp-coupon-layout-modern {
    background-color: #F3F4F6;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

#csp-popup-builder-root .csp-modern-code-text {
    flex-grow: 1;
    padding: 14px 20px;
    font-size: 20px;
    font-weight: 700;
    color: #111827;
}

#csp-popup-builder-root .csp-modern-copy-btn {
    border-radius: 0 8px 8px 0;
    padding: 14px 20px;
    border: none;
    background: var(--csp-primary);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

#csp-popup-builder-root .csp-modern-copy-btn:hover {
    background-color: #5a48d8;
}

#csp-popup-builder-root .csp-modern-copy-btn.copied {
    background-color: #22c55e;
}

#csp-popup-builder-root .csp-coupon-layout-codeonly {
    text-align: center;
}

#csp-popup-builder-root .csp-codeonly-text {
    font-size: 32px;
    font-weight: 700;
    color: #FFFFFF;
    padding: 10px 20px;
    cursor: pointer;
}

/* Divider Styles */
#csp-popup-builder-root .csp-popup-v1-divider-wrapper {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
}

#csp-popup-builder-root .csp-popup-v1-divider-line {
    flex-grow: 1;
    height: 1px;
    background-color: #374151;
}

#csp-popup-builder-root .csp-popup-v1-divider-text {
    padding: 0 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--csp-text-medium);
}

/* Responsive Styles */
@media (max-width: 768px) {
    #csp-popup-builder-root .csp-popup-v1-popup-container {
        padding: 1.5rem;
    }
    
    #csp-popup-builder-root .csp-popup-v1-editable-headline {
        font-size: 1.5rem;
    }
    
    #csp-popup-builder-root .csp-popup-v1-editable-text {
        font-size: 0.9rem;
    }
    
    #csp-popup-builder-root .csp-popup-v1-countdown-number {
        font-size: 24px;
    }
    
    #csp-popup-builder-root .csp-popup-v1-countdown-block {
        min-width: 50px;
        padding: 6px 10px;
    }
}

/* --- Animation Application --- */
/* This rule was missing. It tells the browser HOW to run the animation. */
#csp-popup-builder-root .csp-popup-v1-popup-container.animate__animated {
    /* You can adjust the duration here if you like */
    --animate-duration: 0.7s;
}
/* --- Form Validation Styles --- */
#csp-popup-builder-root .csp-popup-v1-form-field input.has-error {
    border-color: #ef4444 !important; /* Use important to override inline styles */
}
#csp-popup-builder-root .csp-form-error-msg {
    color: #ef4444;
    font-size: 13px;
    text-align: left;
    margin-top: 6px;
}

/* ========================================================================
   Popup Overflow & Resilience Fixes
======================================================================== */

/* 1. Container Overflow Control */
#csp-popup-builder-root .csp-popup-v1-popup-container {
    /* Use flexbox to better control the inner content area */
    display: flex;
    flex-direction: column;
    /* Prevent the popup from ever being taller than 90% of the screen height */
    max-height: 90vh; 
}

#csp-popup-builder-root .csp-popup-v1-popup-content-area {
    /* If content is too tall, allow vertical scrolling WITHIN the content area */
    overflow-y: auto;
    /* Always hide horizontal overflow, as side-scrolling is bad UX on a popup */
    overflow-x: hidden;
    /* Ensures padding is respected by the scrollbar */
    padding-right: 5px; 
}

/* 2. Component Resilience */
#csp-popup-builder-root .csp-popup-v1-popup-container * {
    /* This is a crucial rule that makes responsive design with padding/borders work correctly. */
    box-sizing: border-box;
}

#csp-popup-builder-root .csp-popup-v1-editable-headline,
#csp-popup-builder-root .csp-popup-v1-editable-text {
    /* Forces long, unbreakable words (like URLs) to wrap instead of overflowing */
    word-break: break-word;
    overflow-wrap: break-word;
    /* Prevent margins from causing overflow issues */
    max-width: 100%;
}

#csp-popup-builder-root .csp-popup-v1-editable-image,
#csp-popup-builder-root .csp-popup-v1-video-wrapper {
    /* Ensures images and videos can never be wider than the popup container */
    max-width: 100%;
    height: auto; /* Maintains aspect ratio */
}

#csp-popup-builder-root .csp-popup-v1-editable-button {
    /* Prevents a button with a fixed width from overflowing on small screens */
    max-width: 100%;
}

/* ==========================================================================
   Responsive & Override Styles for All Popups
   ========================================================================== */

/* 1. Universal Fix for Cut-Off Headlines on ALL screen sizes */
/* Addresses the core problem you identified on desktop */
#csp-popup-builder-root .csp-popup-v1-editable-headline {
    /* Set a sensible relative line-height. !important is needed to override inline styles from the builder. */
    line-height: 1.3 !important; 
}

/* ==========================================================================
   NEW: Robust Scrolling for Tall Popups
   ========================================================================== */

/* 1. Set the main overlay to use flexbox for centering */
#csp-popup-builder-root .csp-popup-v1-overlay {
    display: flex;
    align-items: center; /* Vertically centers the container */
    justify-content: center; /* Horizontally centers the container */
}

/* 2. Configure the popup container with flexbox and a max-height */
#csp-popup-builder-root .csp-popup-v1-popup-container {
    display: flex;
    flex-direction: column;
    /* Can be no taller than 90% of the viewport height, leaving 5% margin top/bottom */
    max-height: 90vh; 
}

/* 3. Make the CONTENT AREA the part that scrolls internally */
#csp-popup-builder-root .csp-popup-v1-popup-content-area {
    /* This makes the content area expand to fill available vertical space */
    flex-shrink: 1;
    flex-grow: 1;

    /* If content overflows, a vertical scrollbar will appear INSIDE this area */
    overflow-y: auto; 

    /* Add some padding to prevent content from touching the scrollbar */
    padding-right: 15px;
    margin-right: -15px; /* Offset the padding to keep content centered */
}

/* 4. Add styling for a cleaner, less intrusive scrollbar (optional but recommended) */
/* Works in modern browsers like Chrome, Edge, and Safari */
#csp-popup-builder-root .csp-popup-v1-popup-content-area::-webkit-scrollbar {
  width: 8px;
}

#csp-popup-builder-root .csp-popup-v1-popup-content-area::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

#csp-popup-builder-root .csp-popup-v1-popup-content-area::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}

#csp-popup-builder-root .csp-popup-v1-popup-content-area::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.6);
}


/* 2. Tablet View (Portrait) - Graceful adjustments */
@media screen and (max-width: 992px) {
    #csp-popup-builder-root .csp-popup-v1-editable-headline {
        font-size: 32px !important;
    }
}


/* 3. Mobile View (Portrait) - Full responsive override */
@media screen and (max-width: 576px) {
    /* Further reduce text sizes for readability on small phones */
    #csp-popup-builder-root .csp-popup-v1-editable-headline {
        font-size: 26px !important;
    }
    #csp-popup-builder-root .csp-popup-v1-overlay {
        /* On mobile, align to top instead of center, but still let the internal content scroll */
        align-items: center;
        padding: 10px;
    }
}

#csp-popup-builder-root .size-6 {
  width: 1.5em; /* Relative to font size */
  height: 1.5em; /* Relative to font size */
  display: block; /* Already in your inline style */
}

/* Optional responsive sizing */
@media (max-width: 768px) {
  #csp-popup-builder-root .size-6 {
    width: 1.25em;
    height: 1.25em;
  }
}

/* ==========================================================================
   MODERN & RESPONSIVE: Member "Add to Cart" Notice Styles
   - Preserves all original class names.
   - Uses CSS variables for easy theming.
   - Mobile-first design for full responsiveness.
   - Enhanced animations with opacity.
   - Improved accessibility with focus styles and larger touch targets.
   ========================================================================== */

.csp-member-notice {
    /* --- Theming and Configuration Variables --- */
    --csp-bg: #111827;
    --csp-text-body: #f9fafb;
    --csp-text-strong: #ffffff;
    --csp-text-link: #93c5fd;
    --csp-text-link-hover: #ffffff;
    --csp-icon-color: #34d399;
    --csp-close-icon-color: #9ca3af;
    --csp-close-icon-hover: #ffffff;
    --csp-border-radius: 8px;
    --csp-shadow: 0 10px 15px -3px rgba(0,0,0,0.2), 0 4px 6px -2px rgba(0,0,0,0.1);
    --csp-ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --csp-offset-mobile: 1rem; /* 16px */
    --csp-offset-desktop: 1.25rem; /* 20px */
    
    /* --- Base Layout & Styling (Mobile First) --- */
    position: fixed;
    z-index: 100001;
    display: flex;
    align-items: center;
    gap: 12px;
    
    /* Positioning for mobile */
    bottom: var(--csp-offset-mobile);
    left: var(--csp-offset-mobile);
    right: var(--csp-offset-mobile);
    width: auto;
    max-width: 420px;
    margin: 0 auto; /* Center the notice horizontally */

    /* Appearance */
    background-color: var(--csp-bg);
    color: var(--csp-text-body);
    padding: 16px;
    border-radius: var(--csp-border-radius);
    box-shadow: var(--csp-shadow);
    
    /* Animation: Initially hidden */
    opacity: 0;
    transform: translateY(calc(100% + var(--csp-offset-mobile)));
    transition: transform 0.4s var(--csp-ease-out), opacity 0.3s ease-in-out;
}

/* --- Visible State --- */
.csp-member-notice.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Icon Styling --- */
.csp-notice-icon {
    flex-shrink: 0;
    color: var(--csp-icon-color);
    width: 24px;
    height: 24px;
}

/* --- Content Styling --- */
.csp-notice-content {
    flex-grow: 1;
    min-width: 0; /* Prevents text overflow issues in flexbox */
}

.csp-notice-content p {
    margin: 0 0 4px;
    padding: 0;
    font-size: 15px;
    line-height: 1.5;
}

.csp-notice-content strong {
    color: var(--csp-text-strong);
    font-weight: 600;
}

/* --- Link Styling --- */
.csp-notice-link {
    color: var(--csp-text-link);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

.csp-notice-link:hover,
.csp-notice-link:focus {
    color: var(--csp-text-link-hover);
    text-decoration: underline;
    outline: none; /* Or use a custom focus ring */
}

/* --- Close Button --- */
.csp-notice-close {
    /* Improved click/touch target size */
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--csp-close-icon-color);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s ease-in-out, background-color 0.2s ease-in-out;
}

.csp-notice-close:hover,
.csp-notice-close:focus {
    color: var(--csp-close-icon-hover);
    background-color: rgba(255, 255, 255, 0.1);
    outline: none; /* Or use a custom focus ring */
}

/* ==========================================================================
   Desktop Styles (for screens 640px and wider)
   ========================================================================== */
@media (min-width: 640px) {
    .csp-member-notice {
        /* Revert to bottom-right positioning */
        bottom: var(--csp-offset-desktop);
        right: var(--csp-offset-desktop);
        left: auto;
        
        /* Restore original width behavior */
        width: 90%;
        max-width: 380px;
        margin: 0;

        /* Adjust animation for a slide-in from the right */
        transform: translateX(calc(100% + var(--csp-offset-desktop)));
    }

    .csp-member-notice.is-visible {
        transform: translateX(0);
    }
}