/* AhmedoWeb Product Video - Frontend */

@property --angle1 {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

@property --angle2 {
    syntax: '<angle>';
    initial-value: 180deg;
    inherits: false;
}

/* ---- Video Button ---- */
.apv-video-button-wrapper {
    margin: 15px 0;
    text-align: center;
    width: 100%;
}

.apv-video-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 28px;
    color: #000000 !important;
    border: none;
    border-radius: 5px !important;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #111118;
    position: relative;
    z-index: 1;
    letter-spacing: 0.5px;
    text-decoration: none;
}

.apv-video-btn::before,
.apv-video-btn::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 8px;
    z-index: -1;
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    padding: 3px;
}

.apv-video-btn::before {
    background: conic-gradient(
        from var(--angle1),
        transparent 0deg,
        #FC466B 40deg,
        #FF6B8A 100deg,
        transparent 160deg,
        transparent 360deg
    );
    animation: apvSpin1 3s linear infinite;
    filter: blur(1px);
}

.apv-video-btn::after {
    background: conic-gradient(
        from var(--angle2),
        transparent 0deg,
        #3F5EFB 50deg,
        #2D3FA0 110deg,
        transparent 170deg,
        transparent 360deg
    );
    animation: apvSpin2 3s linear infinite;
    filter: blur(0.5px);
    opacity: 0.6;
}

.apv-video-btn:hover::before {
    filter: blur(2px);
}

.apv-video-btn:hover::after {
    filter: blur(1px);
    opacity: 0.8;
}

.apv-video-btn:hover {
    transform: translateY(-2px);
    color: #000000 !important;
}

.apv-video-btn:active {
    transform: translateY(0);
}

.apv-video-btn .apv-btn-text {
    color: #000000 !important;
}

.apv-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.apv-btn-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
}

.apv-btn-icon svg circle {
    stroke: #000000;
    fill: none;
}

.apv-btn-icon svg path {
    fill: #000000;
}

/* RTL Support */
html[dir="rtl"] .apv-video-btn {
    flex-direction: row;
}

/* ---- Gallery Thumbnail ---- */
.apv-gallery-thumb {
    position: relative;
    cursor: pointer;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 1;
}

.apv-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.apv-gallery-thumb:hover img {
    transform: scale(1.05);
}

.apv-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    transition: background 0.3s ease;
}

.apv-gallery-thumb:hover .apv-play-overlay {
    background: rgba(0, 0, 0, 0.4);
}

.apv-play-overlay svg {
    width: 50px;
    height: 50px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
    transition: transform 0.3s ease;
}

.apv-gallery-thumb:hover .apv-play-overlay svg {
    transform: scale(1.1);
}

/* ---- Modal ---- */
.apv-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    padding: 20px;
}

.apv-modal.apv-active {
    opacity: 1;
    visibility: visible;
}

.apv-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    cursor: pointer;
}

.apv-modal-container {
    position: relative;
    z-index: 1;
    background: #1a1a2e;
    border-radius: 10px;
    overflow: hidden;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.apv-modal.apv-active .apv-modal-container {
    transform: scale(1) translateY(0);
}

.apv-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(90deg, #FC466B 0%, #3F5EFB 100%);
}

.apv-modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.3px;
}

.apv-modal-close {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    height: 36px !important;
    background: rgba(0, 0, 0, 0.3) !important;
    border: 2px solid rgba(255, 255, 255, 0.7) !important;
    border-radius: 5px !important;
    color: #ffffff !important;
    cursor: pointer !important;
    transition: all 0.25s ease;
    padding: 0 !important;
    flex-shrink: 0;
}

.apv-modal-close:hover {
    background: rgba(0, 0, 0, 0.5) !important;
    border-color: #ffffff !important;
}

.apv-modal-close svg {
    width: 18px !important;
    height: 18px !important;
    fill: none !important;
    display: block !important;
}

.apv-modal-close svg path {
    stroke: #ffffff !important;
    stroke-width: 2.5 !important;
}

.apv-modal-body {
    padding: 0;
    background: #0f0f1a;
}

/* ---- Video Wrapper ---- */
.apv-video-wrapper {
    position: relative;
    width: 100%;
    background: #000;
    overflow: hidden;
}

.apv-video-wrapper video,
.apv-video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.apv-video-wrapper video {
    object-fit: contain;
    background: #000;
}

/* Aspect Ratios */
.apv-ratio-9-16 {
    padding-bottom: 177.78%;
}

.apv-ratio-16-9 {
    padding-bottom: 56.25%;
}

.apv-ratio-1-1 {
    padding-bottom: 100%;
}

.apv-ratio-4-5 {
    padding-bottom: 125%;
}

/* Custom Video Controls */
.apv-video-wrapper video::-webkit-media-controls-panel {
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
}

.apv-video-wrapper video::-webkit-media-controls-play-button {
    background-color: rgba(252, 70, 107, 0.9);
    border-radius: 50%;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
    .apv-modal {
        padding: 0;
        align-items: flex-end;
    }

    .apv-modal-container {
        max-width: 100%;
        border-radius: 10px 10px 0 0;
        transform: translateY(100%);
    }

    .apv-modal.apv-active .apv-modal-container {
        transform: translateY(0);
    }

    .apv-video-btn {
        padding: 10px 22px;
        font-size: 14px;
    }

    .apv-modal-header {
        padding: 14px 16px;
    }

    .apv-modal-title {
        font-size: 15px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .apv-modal-container {
        max-width: 360px;
    }
}

/* ---- Animations ---- */
@keyframes apvSpin1 {
    to { --angle1: 360deg; }
}

@keyframes apvSpin2 {
    to { --angle2: 540deg; }
}

/* ---- WoodMart / Elementor Compatibility ---- */
.product-images .apv-video-button-wrapper {
    margin-top: 12px;
    margin-bottom: 8px;
}

.woodmart-product-gallery .apv-gallery-thumb {
    margin-bottom: 10px;
}

.elementor-widget-woocommerce-product-images .apv-video-button-wrapper {
    margin: 15px auto;
}

/* Prevent scroll when modal is open */
body.apv-modal-open {
    overflow: hidden !important;
    padding-right: var(--apv-scroll-width, 0);
}

/* Loading state */
.apv-modal-loading .apv-video-wrapper::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #FC466B;
    border-radius: 50%;
    animation: apvSpin 0.8s linear infinite;
}

@keyframes apvSpin {
    to { transform: rotate(360deg); }
}
