/**
 * WP Reels Commerce - Giao diện nút CTA
 * Dùng chung cho video player (frontend) và bản xem trước trong admin.
 *
 * Màu: --cta-bg / --cta-text (riêng từng video, đặt inline)
 *   → fallback --wprc-cta-bg / --wprc-cta-text (Cài đặt giao diện chung)
 *   → fallback màu mặc định.
 *
 * @package   WP_Reels_Commerce
 * @author    Le Thuan
 * @copyright 2026 Le Thuan
 * @license   GPL-2.0-or-later
 * @link      https://lethuan.com/wp-reels-commerce
 * @version   1.2.8
 */

.wprc-cta-btn {
    --_cta-bg: var(--cta-bg, var(--wprc-cta-bg, #ff3b5c));
    --_cta-fg: var(--cta-text, var(--wprc-cta-text, #ffffff));

    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    box-sizing: border-box;
    overflow: hidden;
    isolation: isolate;
    border: 2px solid transparent;
    color: var(--_cta-fg) !important;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none !important;
    text-shadow: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease,
        background-color 0.2s ease, color 0.2s ease;
}

.wprc-cta-btn:hover {
    filter: brightness(1.07);
    transform: translateY(-1px) scale(1.02);
}

.wprc-cta-btn:active {
    transform: scale(0.98);
}

.wprc-cta-btn:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* !important để theme (Flatsome: svg:not(:root), svg { max-width... }) không làm mất icon */
.wprc-cta-btn .wprc-cta-icon {
    display: block !important;
    flex: 0 0 auto;
    width: 1.2em !important;
    height: 1.2em !important;
    max-width: none !important;
    margin: 0 !important;
    overflow: visible !important;
    fill: currentColor !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.wprc-cta-btn .wprc-cta-icon path {
    fill: inherit !important;
}

.wprc-cta-btn .wprc-cta-label {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ========== Kiểu nút ========== */
.wprc-cta--solid {
    background: var(--_cta-bg);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

/* Gradient tự sinh từ 1 màu: lớp sáng/tối phủ lên màu nền */
.wprc-cta--gradient {
    background-color: var(--_cta-bg);
    background-image: linear-gradient(135deg,
        rgba(255, 255, 255, 0.35) 0%,
        rgba(255, 255, 255, 0) 45%,
        rgba(0, 0, 0, 0.25) 100%);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

/* Viền: màu nền dùng cho viền + chữ; hover thì đổ đầy */
.wprc-cta--outline {
    background: rgba(0, 0, 0, 0.28);
    border-color: var(--_cta-bg);
    color: var(--_cta-bg) !important;
}

.wprc-cta--outline:hover {
    background: var(--_cta-bg);
    color: var(--_cta-fg) !important;
}

/* Kính mờ: nền trong suốt, icon mang màu nhấn */
.wprc-cta--glass {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.35);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    backdrop-filter: blur(10px) saturate(140%);
}

.wprc-cta--glass .wprc-cta-icon {
    fill: var(--_cta-bg) !important;
}

/* ========== Bo góc ========== */
.wprc-cta--pill {
    border-radius: 999px;
}

.wprc-cta--rounded {
    border-radius: 10px;
}

.wprc-cta--square {
    border-radius: 3px;
}

/* ========== Hiệu ứng ========== */
.wprc-cta--fx-pulse {
    animation: wprc-cta-pulse 2s ease-out infinite;
}

@keyframes wprc-cta-pulse {
    0% {
        box-shadow: 0 0 0 0 var(--_cta-bg);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(0, 0, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
    }
}

.wprc-cta--fx-shine::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -60%;
    z-index: 1;
    width: 40%;
    background: linear-gradient(105deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.55) 50%,
        rgba(255, 255, 255, 0) 100%);
    transform: skewX(-20deg);
    animation: wprc-cta-shine 3.2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes wprc-cta-shine {
    0%,
    55% {
        left: -60%;
    }
    100% {
        left: 130%;
    }
}

.wprc-cta--fx-bounce {
    animation: wprc-cta-bounce 2.6s ease-in-out infinite;
}

@keyframes wprc-cta-bounce {
    0%,
    70%,
    100% {
        transform: translateY(0);
    }
    78% {
        transform: translateY(-6px);
    }
    86% {
        transform: translateY(0);
    }
    92% {
        transform: translateY(-2px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .wprc-cta-btn,
    .wprc-cta-btn::after {
        animation: none !important;
        transition: none;
    }

    .wprc-cta--fx-shine::after {
        display: none;
    }
}
