/* ============================================================
   WACRM Popup Checkout Form - Frontend Styles
   Premium Glassmorphic Modal + WooCommerce Buy Now Button
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* ============================================================
   1. BUY NOW BUTTON (on product page)
   ============================================================ */
.wacrm-pcf-buy-now-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 140px;
    padding: 13px 24px;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 50%, #ec4899 100%);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    letter-spacing: 0.3px;
    vertical-align: middle;
    margin-left: 10px;
    z-index: 1;
    /* iOS: eliminate 300ms tap delay & grey flash */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.wacrm-pcf-buy-now-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, transparent 60%);
    border-radius: 14px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.wacrm-pcf-buy-now-btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.45);
    filter: brightness(1.05);
}

.wacrm-pcf-buy-now-btn:hover::before {
    opacity: 1;
}

.wacrm-pcf-buy-now-btn:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 3px 10px rgba(239, 68, 68, 0.3);
}

.wacrm-pcf-btn-icon {
    font-size: 1.1em;
    animation: wacrm-pcf-pulse-icon 2s ease-in-out infinite;
}

@keyframes wacrm-pcf-pulse-icon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ============================================================
   BUTTON ANIMATION EFFECTS
   ============================================================ */

/* 1. Shimmer (Shiny Sweep) */
.wacrm-pcf-buy-now-btn.wacrm-pcf-effect-shimmer::after,
.wacrm-pcf-submit-btn.wacrm-pcf-effect-shimmer::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 40%;
    height: 200%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transform: skewX(-15deg);
    animation: wacrm-pcf-shimmer 3s infinite;
}

@keyframes wacrm-pcf-shimmer {
    0% { left: -60%; }
    100% { left: 160%; }
}

/* 2. Pulse (Breathing) */
.wacrm-pcf-buy-now-btn.wacrm-pcf-effect-pulse,
.wacrm-pcf-submit-btn.wacrm-pcf-effect-pulse {
    animation: wacrm-pcf-pulse-btn 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes wacrm-pcf-pulse-btn {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* 3. Bounce (Up and Down) */
.wacrm-pcf-buy-now-btn.wacrm-pcf-effect-bounce,
.wacrm-pcf-submit-btn.wacrm-pcf-effect-bounce {
    animation: wacrm-pcf-bounce-btn 2s infinite;
}

@keyframes wacrm-pcf-bounce-btn {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
    60% { transform: translateY(-4px); }
}

/* ---- Buy Now Button: Loading State ---- */
.wacrm-pcf-buy-now-btn.wacrm-pcf-btn-loading {
    pointer-events: none;
    /* Freeze shimmer, keep gradient but slightly dim */
    animation: none;
    filter: brightness(0.9);
}

/* Ripple ring on loading */
.wacrm-pcf-buy-now-btn.wacrm-pcf-btn-loading::before {
    opacity: 1;
    animation: wacrm-pcf-btn-ripple 0.7s ease-out forwards;
}

@keyframes wacrm-pcf-btn-ripple {
    0%   { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.5); }
    100% { box-shadow: 0 0 0 20px rgba(255, 255, 255, 0); }
}

/* Bounce dots spinner */
.wacrm-pcf-btn-spinner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 1.2em;
}

.wacrm-pcf-btn-spinner span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #ffffff;
    border-radius: 50%;
    animation: wacrm-pcf-dot-bounce 0.6s ease-in-out infinite alternate;
}

.wacrm-pcf-btn-spinner span:nth-child(2) {
    animation-delay: 0.15s;
}

.wacrm-pcf-btn-spinner span:nth-child(3) {
    animation-delay: 0.30s;
}

@keyframes wacrm-pcf-dot-bounce {
    0%   { transform: translateY(0); opacity: 0.6; }
    100% { transform: translateY(-7px); opacity: 1; }
}

/* ============================================================
   2. MODAL OVERLAY
   ============================================================ */
.wacrm-pcf-overlay {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.65) !important;
    backdrop-filter: blur(6px) saturate(150%);
    -webkit-backdrop-filter: blur(6px) saturate(150%);
    z-index: 2147483647 !important; /* Max z-index */
    display: none !important; /* Hidden by default — !important to beat theme overrides */
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none !important; /* Never block clicks when hidden */
    visibility: hidden;
    transition: opacity 0.35s ease;
    box-sizing: border-box;
}

/* When JS sets display:flex inline AND adds this class */
.wacrm-pcf-overlay.wacrm-pcf-active {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important; /* Restore click interception when open */
    visibility: visible !important;
}

/* ============================================================
   3. MODAL BOX
   ============================================================ */
.wacrm-pcf-modal {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 24px;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.20),
        0 8px 24px rgba(0, 0, 0, 0.10),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    padding: 36px 36px 28px;
    box-sizing: border-box;
    transform: scale(0.85) translateY(30px);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.35s ease;
    scrollbar-width: thin;
    scrollbar-color: #e0e7ff transparent;
}

.wacrm-pcf-overlay.wacrm-pcf-active .wacrm-pcf-modal {
    opacity: 1;
    animation: wacrm-pcf-modal-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes wacrm-pcf-modal-pop {
    0% { transform: scale(0.85) translateY(30px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.wacrm-pcf-modal::-webkit-scrollbar {
    width: 5px;
}
.wacrm-pcf-modal::-webkit-scrollbar-thumb {
    background: #c7d2fe;
    border-radius: 5px;
}

/* ============================================================
   4. CLOSE BUTTON
   ============================================================ */
.wacrm-pcf-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 34px;
    height: 34px;
    background: rgba(0, 0, 0, 0.06);
    border: none;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    z-index: 10;
}

.wacrm-pcf-close-btn:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    transform: rotate(90deg);
}

/* ============================================================
   5. MODAL HEADER
   ============================================================ */
.wacrm-pcf-modal-header {
    text-align: center;
    margin-bottom: 28px;
}

.wacrm-pcf-header-image-wrap {
    margin-bottom: 16px;
    border-radius: 16px;
    overflow: hidden;
    max-height: 200px;
}

.wacrm-pcf-header-image {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
}

.wacrm-pcf-modal-title {
    margin: 0 0 8px;
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f59e0b, #ef4444, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.wacrm-pcf-modal-subtitle {
    margin: 0;
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 400;
}

/* ============================================================
   6. FORM FIELDS
   ============================================================ */
.wacrm-pcf-form {
    position: relative;
}

.wacrm-pcf-form-group {
    margin-bottom: 18px;
}

.wacrm-pcf-form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 7px;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    text-align: left;
}

.wacrm-pcf-required {
    color: #ef4444;
    margin-left: 2px;
}

.wacrm-pcf-input-wrapper {
    position: relative;
}

.wacrm-pcf-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    pointer-events: none;
    z-index: 1;
    user-select: none;
}

.wacrm-pcf-input {
    display: block;
    width: 100%;
    padding: 13px 16px 13px 46px !important;
    font-family: inherit;
    font-size: 0.95rem;
    color: #1f2937;
    background: rgba(249, 250, 251, 0.8);
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.wacrm-pcf-input::placeholder {
    color: #9ca3af;
}

.wacrm-pcf-input:focus {
    border-color: #f59e0b;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.12);
}

/* ============================================================
   7. PHONE FIELD WITH LOCKED PREFIX
   ============================================================ */
.wacrm-pcf-phone-wrapper {
    display: flex;
    align-items: stretch;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(249, 250, 251, 0.8);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.wacrm-pcf-phone-wrapper:focus-within {
    border-color: #f59e0b;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.12);
}

.wacrm-pcf-phone-prefix {
    display: flex;
    align-items: center;
    padding: 0 14px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    font-size: 0.9rem;
    font-weight: 800;
    white-space: nowrap;
    border-right: 1.5px solid #fcd34d;
    letter-spacing: 0.5px;
    user-select: none;
    cursor: default;
    min-width: 50px;
    justify-content: center;
}

.wacrm-pcf-phone-input {
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    flex: 1;
    padding: 13px 16px !important;
}

.wacrm-pcf-phone-input:focus {
    outline: none;
    border: none !important;
    box-shadow: none !important;
}

.wacrm-pcf-field-hint {
    display: block;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 6px;
    line-height: 1.4;
}

/* ============================================================
   8. STATE DROPDOWN
   ============================================================ */
.wacrm-pcf-select-wrapper {
    position: relative;
}

.wacrm-pcf-select {
    display: block;
    width: 100%;
    padding: 13px 42px 13px 16px; /* Right space for arrow, normal left */
    font-family: inherit;
    font-size: 0.95rem;
    color: #1f2937;
    background: rgba(249, 250, 251, 0.8);
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    outline: none;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.wacrm-pcf-select:focus {
    border-color: #f59e0b;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.12);
}

.wacrm-pcf-select-arrow {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: #9ca3af;
    pointer-events: none;
    user-select: none;
}

/* ============================================================
   9. SUBMIT BUTTON
   ============================================================ */
.wacrm-pcf-form-actions {
    margin-top: 24px;
}

.wacrm-pcf-submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 15px 24px;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 800;
    color: #ffffff;
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 50%, #ec4899 100%);
    background-size: 200% 200%;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(239, 68, 68, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    letter-spacing: 0.5px;
    animation: wacrm-pcf-gradient-move 4s ease infinite;
}

/* Animation effects applied dynamically via classes */

@keyframes wacrm-pcf-gradient-move {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.wacrm-pcf-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 32px rgba(239, 68, 68, 0.45);
    filter: brightness(1.06);
}

.wacrm-pcf-submit-btn:active {
    transform: translateY(1px);
}

.wacrm-pcf-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.wacrm-pcf-submit-icon {
    font-size: 1.2em;
    animation: wacrm-pcf-pulse-icon 2s infinite;
}

.wacrm-pcf-submit-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: wacrm-pcf-spin 0.75s linear infinite;
}

@keyframes wacrm-pcf-spin {
    to { transform: rotate(360deg); }
}

.wacrm-pcf-secure-note {
    margin: 14px 0 0;
    text-align: center;
    font-size: 0.75rem;
    color: #9ca3af;
}

/* ============================================================
   10. PROCESSING OVERLAY (inside modal)
   ============================================================ */
.wacrm-pcf-processing-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    animation: wacrm-pcf-fade-in 0.25s ease forwards;
}

@keyframes wacrm-pcf-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.wacrm-pcf-processing-content {
    text-align: center;
    padding: 24px;
    width: 100%;
    max-width: 320px;
    position: relative;
}

/* Ring Loader */
.wacrm-pcf-ring-container {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
}

.wacrm-pcf-progress-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.wacrm-pcf-ring-track {
    fill: none;
    stroke: #f3f4f6;
    stroke-width: 8;
}

.wacrm-pcf-ring-fill {
    fill: none;
    stroke: url(#wacrm-pcf-ring-gradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 263.9; /* 2 * PI * 42 */
    stroke-dashoffset: 263.9;
    transition: stroke-dashoffset 0.15s ease;
}

.wacrm-pcf-ring-percent {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 800;
    color: #374151;
    font-family: 'Outfit', sans-serif;
}

/* Progress Bar */
.wacrm-pcf-prog-track {
    height: 5px;
    background: #f3f4f6;
    border-radius: 5px;
    overflow: hidden;
    margin: 0 auto 16px;
    max-width: 240px;
}

.wacrm-pcf-prog-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #f59e0b, #ef4444, #ec4899);
    border-radius: 5px;
    transition: width 0.15s ease;
}

/* Processing Text */
.wacrm-pcf-proc-title {
    margin: 0 0 8px;
    font-size: 1.3rem;
    font-weight: 800;
    color: #1f2937;
}

.wacrm-pcf-proc-msg {
    margin: 0 0 16px;
    font-size: 0.875rem;
    color: #6b7280;
    min-height: 20px;
    transition: opacity 0.2s ease;
}

/* ============================================================
   11. SUCCESS CHECKMARK ANIMATION
   ============================================================ */
.wacrm-pcf-success-icon {
    width: 90px;
    height: 90px;
    margin: 0 auto 20px;
    animation: wacrm-pcf-success-pop 0.5s cubic-bezier(0.26, 0.86, 0.44, 0.985) forwards;
}

@keyframes wacrm-pcf-success-pop {
    0% { transform: scale(0) rotate(-15deg); opacity: 0; }
    60% { transform: scale(1.15) rotate(5deg); }
    80% { transform: scale(0.95) rotate(-3deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.wacrm-pcf-checkmark-svg {
    width: 100%;
    height: 100%;
}

.wacrm-pcf-checkmark-circle-bg {
    stroke: #22c55e;
    stroke-width: 2;
    stroke-dasharray: 157; /* 2 * PI * 25 */
    stroke-dashoffset: 157;
    animation: wacrm-pcf-circle-draw 0.5s ease forwards 0.1s;
}

@keyframes wacrm-pcf-circle-draw {
    to { stroke-dashoffset: 0; }
}

.wacrm-pcf-checkmark-path {
    stroke: #22c55e;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    animation: wacrm-pcf-check-draw 0.4s ease forwards 0.5s;
}

@keyframes wacrm-pcf-check-draw {
    to { stroke-dashoffset: 0; }
}

/* ============================================================
   12. ERROR CROSS
   ============================================================ */
.wacrm-pcf-error-icon {
    position: relative;
    width: 70px;
    height: 70px;
    margin: 0 auto 20px;
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid #ef4444;
    border-radius: 50%;
    animation: wacrm-pcf-success-pop 0.4s cubic-bezier(0.26, 0.86, 0.44, 0.985) forwards;
}

.wacrm-pcf-cross-line1,
.wacrm-pcf-cross-line2 {
    position: absolute;
    width: 32px;
    height: 3.5px;
    background: #ef4444;
    border-radius: 3px;
    top: 50%;
    left: 50%;
    transform-origin: center;
}

.wacrm-pcf-cross-line1 {
    transform: translate(-50%, -50%) rotate(45deg);
    animation: wacrm-pcf-cross-draw 0.3s ease forwards 0.2s;
    opacity: 0;
}

.wacrm-pcf-cross-line2 {
    transform: translate(-50%, -50%) rotate(-45deg);
    animation: wacrm-pcf-cross-draw 0.3s ease forwards 0.35s;
    opacity: 0;
}

@keyframes wacrm-pcf-cross-draw {
    from { opacity: 0; transform: translate(-50%, -50%) rotate(var(--r, 45deg)) scaleX(0); }
    to { opacity: 1; transform: translate(-50%, -50%) rotate(var(--r, 45deg)) scaleX(1); }
}

.wacrm-pcf-cross-line2 {
    --r: -45deg;
}

/* ============================================================
   13. CONFETTI CANVAS
   ============================================================ */
.wacrm-pcf-confetti-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 30;
    border-radius: 24px;
}

/* ============================================================
   14. PROC CLOSE / RETRY BUTTON
   ============================================================ */
.wacrm-pcf-proc-close-btn {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 28px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.wacrm-pcf-proc-close-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* ============================================================
   15. RESPONSIVE
   ============================================================ */
@media (max-width: 520px) {
    .wacrm-pcf-overlay {
        padding: 10px;
        align-items: center; /* Center horizontally and vertically */
    }

    .wacrm-pcf-modal {
        padding: 18px 16px 14px;
        border-radius: 20px;
        max-height: 85vh; /* Keep it away from edges and keyboards */
        transform: scale(0.9) translateY(0); /* Smaller default size */
        margin: auto;
        width: 100%;
    }

    .wacrm-pcf-overlay.wacrm-pcf-active .wacrm-pcf-modal {
        transform: scale(0.95) translateY(0);
        opacity: 1;
    }

    .wacrm-pcf-modal-title {
        font-size: 1.25rem;
    }

    .wacrm-pcf-modal-subtitle {
        font-size: 0.85rem;
        margin-bottom: 16px;
    }

    .wacrm-pcf-input,
    .wacrm-pcf-phone-input,
    .wacrm-pcf-select {
        font-size: 0.9rem;
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }

    .wacrm-pcf-phone-prefix {
        font-size: 0.9rem;
    }

    .wacrm-pcf-buy-now-btn {
        margin-left: 0;
        margin-top: 6px;
        width: 100%;
        padding: 12px 24px;
        font-size: 0.95rem;
    }
    
    .wacrm-pcf-secure-note {
        font-size: 0.75rem;
        margin-top: 12px;
    }
}

/* ============================================================
   16. SVG Gradient Definition (injected by JS)
   ============================================================ */
svg.wacrm-pcf-progress-svg defs {
    display: block;
}
