/* ================================================================
   Perfecto — Promo Features CSS
   Loading Animation  +  Floating Offer Button (Dropdown Popup)
   LTR + RTL Support
   ================================================================ */

/* ──────────────────────────────────────────────────────────────
   1. LOADING ANIMATION OVERLAY
   ────────────────────────────────────────────────────────────── */
#perfecto-loader {
    position: fixed; inset: 0; z-index: 999999;
    display: flex; align-items: center; justify-content: center;
    transition: opacity var(--pfl-fade,400ms) ease, visibility var(--pfl-fade,400ms) ease;
}
#perfecto-loader.pfl-hidden { opacity:0; visibility:hidden; pointer-events:none; }
.pfl-inner { display:flex; flex-direction:column; align-items:center; gap:24px; }
.pfl-logo img, .pfl-logo .pfl-site-name { display:block; max-width:100%; }
.pfl-logo .pfl-site-name { font-size:28px; font-weight:700; color:#111; }

/* Continuous Logo Animations */
.pfl-logo-anim-fade   { animation: pflFadeLoop   2s ease-in-out infinite; }
.pfl-logo-anim-zoom   { animation: pflZoomLoop   2s ease-in-out infinite; }
.pfl-logo-anim-bounce { animation: pflBounceLoop 2s ease-in-out infinite; }
.pfl-logo-anim-flip   { animation: pflFlipLoop   3s linear infinite; }

@keyframes pflFadeLoop { 
    0%, 100% { opacity: 0.4; } 
    50% { opacity: 1; } 
}

@keyframes pflZoomLoop { 
    0%, 100% { transform: scale(0.9); } 
    50% { transform: scale(1.1); } 
}

@keyframes pflBounceLoop {
    0%, 100% { transform: translateY(0); } 
    50% { transform: translateY(-15px); }
}

@keyframes pflFlipLoop { 
    0% { transform: rotateY(0deg); } 
    100% { transform: rotateY(360deg); } 
}

.pfl-anim-spinner {
    width:48px; height:48px; border-radius:50%;
    border:4px solid rgba(0,0,0,.08); border-top-color:var(--pfl-color,#e53935);
    animation:pflSpin .8s linear infinite;
}
@keyframes pflSpin { to{transform:rotate(360deg)} }

.pfl-anim-pulse {
    width:56px; height:56px; border-radius:50%;
    background:var(--pfl-color,#e53935); animation:pflPulse 1.2s ease-in-out infinite;
}
@keyframes pflPulse { 0%,100%{transform:scale(.85);opacity:.6} 50%{transform:scale(1.1);opacity:1} }

.pfl-anim-dots { display:flex; gap:10px; }
.pfl-anim-dots span {
    width:14px; height:14px; border-radius:50%;
    background:var(--pfl-color,#e53935); animation:pflDot 1.2s ease-in-out infinite;
}
.pfl-anim-dots span:nth-child(2){animation-delay:.2s}
.pfl-anim-dots span:nth-child(3){animation-delay:.4s}
@keyframes pflDot { 0%,80%,100%{transform:scale(0)} 40%{transform:scale(1)} }

.pfl-anim-bar { width:200px; }
.pfl-bar-track { height:5px; background:rgba(0,0,0,.08); border-radius:99px; overflow:hidden; }
.pfl-bar-fill  { height:100%; background:var(--pfl-color,#e53935); border-radius:99px; animation:pflBar 1.4s ease-in-out infinite; }
@keyframes pflBar { 0%{width:0%;margin-left:0} 50%{width:70%;margin-left:15%} 100%{width:0%;margin-left:100%} }

.pfl-anim-ripple { position:relative; width:60px; height:60px; }
.pfl-ripple-ring { position:absolute; inset:0; border:3px solid var(--pfl-color,#e53935); border-radius:50%; animation:pflRipple 1.4s ease-out infinite; }
.pfl-ripple-delay { animation-delay:.7s; }
@keyframes pflRipple { from{transform:scale(0);opacity:1} to{transform:scale(2);opacity:0} }


/* ──────────────────────────────────────────────────────────────
   2. WRAPPER  — position is set via inline style from PHP
   ────────────────────────────────────────────────────────────── */
#perfecto-offer-wrap {
    position: fixed;
    z-index: 99990;
}

/* Device helpers */
@media (min-width:769px) { .pfo-hide-desktop { display:none !important; } }
@media (max-width:768px) { .pfo-hide-mobile  { display:none !important; } }


/* ──────────────────────────────────────────────────────────────
   3. FLOATING BUTTON
   ────────────────────────────────────────────────────────────── */
#perfecto-offer-btn {
    position: relative; z-index: 2;
    display: inline-flex; align-items: center; gap: 7px;
    padding: var(--pfo-pad-desktop,13px) 20px !important;
    background: var(--pfo-btn-bg,#e53935);
    color: var(--pfo-btn-txt,#fff);
    border: none; border-radius: 50px;
    font-size: var(--pfo-font-desktop,14px) !important; font-weight: 700; font-family: inherit;
    cursor: pointer; white-space: nowrap; letter-spacing: .2px;
    box-shadow: 0 6px 20px rgba(0,0,0,.22);
    transition: transform .2s ease, box-shadow .2s ease;
}
@media (max-width:768px) {
    #perfecto-offer-btn {
        font-size: var(--pfo-font-mobile,13px) !important;
        padding-top: var(--pfo-pad-mobile,10px) !important;
        padding-bottom: var(--pfo-pad-mobile,10px) !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
}
#perfecto-offer-btn:hover { transform:translateY(-2px); box-shadow:0 8px 24px rgba(0,0,0,.28); }
#perfecto-offer-btn[aria-expanded="true"] { box-shadow:0 4px 14px rgba(0,0,0,.18); }

/* Chevron */
#perfecto-offer-btn .pfo-chevron {
    display: inline-block; width:0; height:0; flex-shrink:0; opacity:.85;
    border-left:5px solid transparent; border-right:5px solid transparent;
    border-bottom:6px solid currentColor;
    transition: transform .25s ease;
}
#perfecto-offer-btn[aria-expanded="true"] .pfo-chevron { transform:rotate(180deg); }

/* Pulse ring */
#perfecto-offer-btn.pfo-pulse::before {
    content:''; position:absolute; inset:-5px; border-radius:50px;
    background:var(--pfo-btn-bg,#e53935); opacity:.3; z-index:-1;
    animation:pfoBtnPulse 2s ease infinite;
}
@keyframes pfoBtnPulse { 0%,100%{transform:scale(1);opacity:.3} 50%{transform:scale(1.3);opacity:0} }


/* ──────────────────────────────────────────────────────────────
   4. DROPDOWN POPUP  — floats above the button
   ────────────────────────────────────────────────────────────── */
#perfecto-offer-popup {
    position: absolute;
    bottom: calc(100% + 14px);   /* above the button */
    z-index: 99991;
    width: 300px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
    overflow: hidden;
    /* Animate */
    transition: opacity .22s ease, transform .22s cubic-bezier(.4,0,.2,1), visibility .22s ease;
}

/* Caret arrow */
#perfecto-offer-popup::after {
    content:''; position:absolute; bottom:-7px;
    width:14px; height:14px; background:#fff;
    transform:rotate(45deg);
    box-shadow:3px 3px 5px rgba(0,0,0,.06);
    border-radius:2px; z-index:-1;
}

/* Hidden state — CSS-driven, no display:none so animation works */
#perfecto-offer-popup[hidden] {
    display: block !important;
    opacity: 0;
    transform: scale(.93) translateY(8px);
    pointer-events: none;
    visibility: hidden;
}
#perfecto-offer-popup:not([hidden]) {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
    visibility: visible;
}

/* ── Align based on position class ── */
.pfo-pos-bottom_right #perfecto-offer-popup,
.pfo-pos-middle_right #perfecto-offer-popup  { right:0; }
.pfo-pos-bottom_right #perfecto-offer-popup::after,
.pfo-pos-middle_right #perfecto-offer-popup::after { right:20px; left:auto; }

.pfo-pos-bottom_left #perfecto-offer-popup,
.pfo-pos-middle_left #perfecto-offer-popup   { left:0; }
.pfo-pos-bottom_left #perfecto-offer-popup::after,
.pfo-pos-middle_left #perfecto-offer-popup::after  { left:20px; right:auto; }

/* ── RTL flip ── */
[dir="rtl"] .pfo-pos-bottom_right #perfecto-offer-popup,
[dir="rtl"] .pfo-pos-middle_right #perfecto-offer-popup { right:0; left:auto; }
[dir="rtl"] .pfo-pos-bottom_left  #perfecto-offer-popup,
[dir="rtl"] .pfo-pos-middle_left  #perfecto-offer-popup { left:0; right:auto; }
[dir="rtl"] .pfo-pos-bottom_right #perfecto-offer-popup::after { right:20px; left:auto; }
[dir="rtl"] .pfo-pos-bottom_left  #perfecto-offer-popup::after { left:20px;  right:auto; }

/* Mobile: stretch to fit */
@media (max-width:420px) {
    #perfecto-offer-popup { width:calc(100vw - 32px); min-width:0; }
    .pfo-pos-bottom_right #perfecto-offer-popup { right:0; left:auto; }
    .pfo-pos-bottom_left  #perfecto-offer-popup { left:0;  right:auto; }
}


/* ──────────────────────────────────────────────────────────────
   5. POPUP HEADER
   ────────────────────────────────────────────────────────────── */
.pfo-popup-header {
    display: flex; align-items: center;
    padding: 12px 14px;
    background: var(--pfo-btn-bg,#e53935);
    color: var(--pfo-btn-txt,#fff);
    gap: 8px;
}
.pfo-popup-header h3 {
    flex: 1; margin: 0; text-align: center;
    font-size: 14px; font-weight: 700; line-height: 1.3;
}
.pfo-header-spacer { width:28px; flex-shrink:0; }

/* RTL */
[dir="rtl"] .pfo-popup-header { flex-direction:row-reverse; }

.pfo-close {
    width:28px; height:28px; border-radius:50%; border:none; flex-shrink:0;
    background:rgba(255,255,255,.2); color:inherit; font-size:12px;
    cursor:pointer; display:flex; align-items:center; justify-content:center;
    transition:background .15s; font-family:inherit;
}
.pfo-close:hover { background:rgba(255,255,255,.35); }


/* ──────────────────────────────────────────────────────────────
   6. BANNER IMAGE
   ────────────────────────────────────────────────────────────── */
.pfo-banner img { width:100%; display:block; object-fit:cover; max-height:130px; }


/* ──────────────────────────────────────────────────────────────
   7. BODY + OFFERS LIST
   ────────────────────────────────────────────────────────────── */
.pfo-body {
    padding: 12px 14px 14px;
    max-height: 55vh; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.pfo-offers-list {
    list-style:none; margin:0 0 12px; padding:0;
    display:flex; flex-direction:column; gap:8px;
}
.pfo-offer-item {
    display:flex; align-items:center; flex-wrap:wrap; gap:6px;
    padding:10px 12px;
    background:#f7f8fa; border:1px solid #eeeff2; border-radius:12px;
    transition:background .15s;
}
.pfo-offer-item:hover { background:#eef0f4; }

.pfo-offer-icon { font-size:20px; flex-shrink:0; line-height:1; }
.pfo-offer-text { flex:1; font-size:13px; font-weight:600; color:#1a1a1a; min-width:0; line-height:1.4; }

.pfo-badge {
    padding:2px 7px; border-radius:6px;
    background:var(--pfo-btn-bg,#e53935); color:#fff;
    font-size:9px; font-weight:800; letter-spacing:.6px; text-transform:uppercase; flex-shrink:0;
}

/* Coupon */
.pfo-coupon-wrap { display:flex; align-items:center; gap:5px; width:100%; margin-top:3px; }
[dir="rtl"] .pfo-coupon-wrap { flex-direction:row-reverse; }

.pfo-coupon {
    display:inline-flex; align-items:center; gap:4px;
    padding:3px 9px; border:1.5px dashed #bbb; border-radius:6px;
    background:#fff; color:#555; font-size:11px; font-weight:700;
    letter-spacing:.5px; cursor:pointer; font-family:monospace;
    transition:border-color .15s, color .15s;
}
.pfo-coupon:hover { border-color:var(--pfo-btn-bg,#e53935); color:var(--pfo-btn-bg,#e53935); }

.pfo-copied-msg {
    font-size:11px; color:#2e7d32; font-weight:700;
    opacity:0; transition:opacity .2s; pointer-events:none;
}
.pfo-copied-msg.visible { opacity:1; }


/* ──────────────────────────────────────────────────────────────
   8. CTA BUTTON
   ────────────────────────────────────────────────────────────── */
.pfo-cta-btn {
    display:block; width:100%; padding:11px;
    background:var(--pfo-cta-bg,#e53935); color:#fff !important;
    text-align:center; border-radius:10px; font-size:14px; font-weight:700;
    text-decoration:none; transition:filter .2s, transform .15s; margin-top:2px;
}
.pfo-cta-btn:hover { filter:brightness(1.08); transform:translateY(-1px); }
