/* ============================================
   Affiliate Popup Pro - Frontend Popup Styles
   © muathemewpgiare.com - All rights reserved.
   Tailwind CSS inspired utility-first design
   ============================================ */

/* ---- Reset & Base ---- */
.app-overlay,
.app-overlay * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ---- Scroll Lock ---- */
body.app-popup-open {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    left: 0;
    right: 0;
}

/* ---- Overlay ---- */
.app-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.app-overlay.app-visible {
    display: flex;
    opacity: 1;
}

/* ---- Container ---- */
.app-container {
    position: relative;
    width: 100%;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.app-overlay.app-visible .app-container {
    transform: translateY(0) scale(1);
}

/* ---- Animations ---- */
.app-animation-fadeIn .app-container {
    animation: appFadeIn 0.5s ease-out forwards;
}

.app-animation-slideUp .app-container {
    animation: appSlideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.app-animation-scaleIn .app-container {
    animation: appScaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.app-animation-bounceIn .app-container {
    animation: appBounceIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes appFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes appSlideUp {
    from { opacity: 0; transform: translateY(60px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes appScaleIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes appBounceIn {
    0% { opacity: 0; transform: scale(0.3); }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

/* ---- Close Button ---- */
.app-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.app-close-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    transform: rotate(90deg);
}

.app-close-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ---- Content ---- */
.app-content {
    padding: 32px 28px 20px;
}

/* ---- Image ---- */
.app-image-wrapper {
    margin: -32px -28px 24px;
    overflow: hidden;
    position: relative;
}

.app-image-wrapper::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to top, rgba(255,255,255,1), rgba(255,255,255,0));
    pointer-events: none;
}

.app-popup-image {
    width: 100%;
    height: auto;
    max-height: 220px;
    object-fit: cover;
    display: block;
}

/* ---- Title ---- */
.app-popup-title {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 1.375rem;
    font-weight: 800;
    line-height: 1.3;
    color: #0f172a;
    text-align: center;
    margin-bottom: 10px;
    letter-spacing: -0.025em;
}

/* ---- Description ---- */
.app-popup-desc {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: #64748b;
    text-align: center;
    margin-bottom: 8px;
}

/* ---- CTA Text ---- */
.app-popup-cta {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #ef4444;
    text-align: center;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---- Buttons Container ---- */
.app-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

/* ---- Affiliate Button Base ---- */
.app-aff-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.9375rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.01em;
}

.app-aff-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
    pointer-events: none;
}

.app-aff-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    filter: brightness(1.08);
    text-decoration: none;
    color: #fff;
}

.app-aff-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ---- Button Icon ---- */
.app-btn-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* ---- Button Colors - Gradient Style ---- */
.app-btn-gradient.app-btn-tiktok {
    background: linear-gradient(135deg, #000000 0%, #25f4ee 50%, #fe2c55 100%);
}

.app-btn-gradient.app-btn-shopee {
    background: linear-gradient(135deg, #ee4d2d 0%, #ff6633 100%);
}

.app-btn-gradient.app-btn-lazada {
    background: linear-gradient(135deg, #0f146d 0%, #1a1f87 100%);
}

.app-btn-gradient.app-btn-tiki {
    background: linear-gradient(135deg, #1a94ff 0%, #0d7fe8 100%);
}

.app-btn-gradient.app-btn-amazon {
    background: linear-gradient(135deg, #ff9900 0%, #ffad33 100%);
    color: #0f172a;
}

.app-btn-gradient.app-btn-other {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

/* ---- Button Colors - Solid Style ---- */
.app-btn-solid.app-btn-tiktok {
    background: #010101;
}

.app-btn-solid.app-btn-shopee {
    background: #ee4d2d;
}

.app-btn-solid.app-btn-lazada {
    background: #0f146d;
}

.app-btn-solid.app-btn-tiki {
    background: #1a94ff;
}

.app-btn-solid.app-btn-amazon {
    background: #ff9900;
    color: #0f172a;
}

.app-btn-solid.app-btn-other {
    background: #6366f1;
}

/* ---- Button Colors - Outline Style ---- */
.app-btn-outline.app-aff-btn {
    background: transparent;
    border: 2px solid;
}

.app-btn-outline.app-btn-tiktok {
    border-color: #010101;
    color: #010101;
}

.app-btn-outline.app-btn-shopee {
    border-color: #ee4d2d;
    color: #ee4d2d;
}

.app-btn-outline.app-btn-lazada {
    border-color: #0f146d;
    color: #0f146d;
}

.app-btn-outline.app-btn-tiki {
    border-color: #1a94ff;
    color: #1a94ff;
}

.app-btn-outline.app-btn-amazon {
    border-color: #ff9900;
    color: #ff9900;
}

.app-btn-outline.app-btn-other {
    border-color: #6366f1;
    color: #6366f1;
}

.app-btn-outline.app-aff-btn:hover {
    color: #fff;
}

.app-btn-outline.app-btn-tiktok:hover { background: #010101; }
.app-btn-outline.app-btn-shopee:hover { background: #ee4d2d; }
.app-btn-outline.app-btn-lazada:hover { background: #0f146d; }
.app-btn-outline.app-btn-tiki:hover { background: #1a94ff; }
.app-btn-outline.app-btn-amazon:hover { background: #ff9900; color: #0f172a; }
.app-btn-outline.app-btn-other:hover { background: #6366f1; }

/* ---- Footer ---- */
.app-popup-footer {
    padding: 0 28px 20px;
    text-align: center;
}

.app-dismiss-btn {
    background: none;
    border: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.8125rem;
    color: #94a3b8;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.app-dismiss-btn:hover {
    background: #f1f5f9;
    color: #475569;
}

/* ---- Pulse animation for buttons ---- */
@keyframes appPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.app-aff-btn:first-child {
    animation: appPulse 2s infinite;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .app-overlay {
        padding: 16px;
        align-items: center;
    }

    .app-container {
        border-radius: 16px !important;
        max-width: 100% !important;
    }

    .app-content {
        padding: 24px 20px 16px;
    }

    .app-image-wrapper {
        margin: -24px -20px 20px;
    }

    .app-popup-image {
        max-height: 160px;
    }

    .app-popup-title {
        font-size: 1.2rem;
    }

    .app-popup-desc {
        font-size: 0.875rem;
    }

    .app-aff-btn {
        padding: 12px 20px;
        font-size: 0.875rem;
        border-radius: 10px;
    }

    .app-popup-footer {
        padding: 0 20px 16px;
    }
}

/* ---- Dark mode support ---- */
@media (prefers-color-scheme: dark) {
    .app-container {
        background: #1e293b !important;
    }

    .app-popup-title {
        color: #f1f5f9;
    }

    .app-popup-desc {
        color: #94a3b8;
    }

    .app-close-btn {
        background: rgba(255, 255, 255, 0.1);
        color: #94a3b8;
    }

    .app-close-btn:hover {
        background: rgba(239, 68, 68, 0.2);
        color: #ef4444;
    }

    .app-dismiss-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #cbd5e1;
    }

    .app-image-wrapper::after {
        background: linear-gradient(to top, #1e293b, transparent);
    }
}

/* ---- Print: hide popup ---- */
@media print {
    .app-overlay {
        display: none !important;
    }
}

/* ============================================
   FORCE CLICK MODE
   Popup không thể đóng, click bất kỳ đâu → redirect
   ============================================ */

/* Overlay: toàn bộ là clickable */
.app-overlay.app-force-mode {
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

/* Container: cũng clickable, thêm hiệu ứng gợi ý */
.app-force-mode .app-container {
    cursor: pointer;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease;
}

.app-force-mode .app-container:hover {
    box-shadow:
        0 25px 60px -12px rgba(0, 0, 0, 0.3),
        0 0 0 3px rgba(99, 102, 241, 0.3);
}

/* Subtle pulse glow to hint "click me" */
.app-force-mode .app-container::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    pointer-events: none;
    animation: appForceGlow 2s ease-in-out infinite;
}

@keyframes appForceGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(99, 102, 241, 0);
    }
}

/* Force footer hint text */
.app-force-footer {
    padding: 0 28px 20px;
    text-align: center;
}

.app-force-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #6366f1;
    animation: appForceHintPulse 1.5s ease-in-out infinite;
    cursor: pointer;
}

.app-force-hint svg {
    flex-shrink: 0;
    animation: appForceArrow 1s ease-in-out infinite;
}

@keyframes appForceHintPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

@keyframes appForceArrow {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(4px); }
}

/* Force mode: buttons also pulse more aggressively */
.app-force-mode .app-aff-btn {
    animation: appForceBtnPulse 2s ease-in-out infinite;
}

.app-force-mode .app-aff-btn:nth-child(2) {
    animation-delay: 0.3s;
}

.app-force-mode .app-aff-btn:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes appForceBtnPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* Force mode mobile */
@media (max-width: 640px) {
    .app-force-footer {
        padding: 0 20px 16px;
    }

    .app-force-hint {
        font-size: 0.75rem;
    }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    .app-overlay,
    .app-container,
    .app-aff-btn,
    .app-close-btn {
        animation: none !important;
        transition: none !important;
    }
}

/* ============================================
   IMAGE-ONLY MODE
   Chỉ hiển thị ảnh + nút đóng (X)
   ============================================ */

.app-image-only .app-content {
    padding: 0;
}

.app-image-only .app-image-wrapper {
    margin: 0;
}

.app-image-only .app-image-wrapper::after {
    display: none;
}

.app-image-only .app-popup-image {
    max-height: none;
    border-radius: inherit;
}

.app-image-only-link {
    display: block;
    text-decoration: none;
    cursor: pointer;
}

.app-image-only-link:hover .app-popup-image {
    opacity: 0.92;
    transition: opacity 0.2s ease;
}

.app-image-only .app-close-btn {
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    top: 10px;
    right: 10px;
}

.app-image-only .app-close-btn:hover {
    background: rgba(239, 68, 68, 0.85);
    color: #fff;
}

@media (max-width: 640px) {
    .app-image-only .app-close-btn {
        width: 32px;
        height: 32px;
        top: 8px;
        right: 8px;
    }
}
