/* --- Wrapper principal --- */
.pve-wrapper {
    position: relative;
    width: 100%;
    max-width: 640px;
    aspect-ratio: 16 / 9;
    margin: 0 auto 16px auto;
    text-align: center;
    border: 1px solid #e2e8f0;
    padding: 12px !important;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    transition: all 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
}

/* Când reclama este prezentă, wrapper-ul nu mai este limitat la raportul 16:9.
   Astfel, pe telefoane, cei 250px ai reclamei nu sunt tăiați. */
.pve-wrapper.pve-has-ad {
    aspect-ratio: auto;
    min-height: 274px;
}

/* --- Stil GLOBAL pentru Video / Iframe --- */
.pve-wrapper iframe,
.pve-wrapper video {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    border: none;
    display: block;
    object-fit: cover;
    border-radius: 0;
}

/* --- Reclama 300x250 --- */
.pve-ad-container {
    position: relative;
    width: 300px;
    height: 250px;
    max-width: 100%;
    flex: 0 0 auto;
    background: #ffffff;
    border-radius: 4px;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
}

.pve-ad-content {
    width: 300px;
    height: 250px;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Majoritatea reclamelor sunt iframe-uri 300x250. Pe telefoane le limităm
   la dimensiunea real disponibilă, ca să nu iasă din ecran. */
.pve-ad-content iframe,
.pve-ad-content ins,
.pve-ad-content img,
.pve-ad-content video,
.pve-ad-content > div {
    max-width: 100% !important;
    box-sizing: border-box;
}

.pve-ad-content iframe {
    width: 300px !important;
    height: 250px !important;
    max-width: 100% !important;
}

/* --- Buton închidere: X + text --- */
.pve-ad-close {
    position: absolute;
    top: 5px;
    right: 5px;
    width: auto;
    min-width: 24px;
    height: 24px;
    padding: 3px 8px;
    margin: 0;
    border: 0;
    border-radius: 13px;
    background: rgba(0, 0, 0, 0.82);
    color: #fff;
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    line-height: 18px;
    white-space: nowrap;
    text-align: center;
    cursor: pointer;
    z-index: 2147483647;
    opacity: 0.95;
    box-sizing: border-box;
}

.pve-ad-close span:first-child {
    font-size: 16px;
    line-height: 10px;
    vertical-align: -1px;
}

.pve-ad-close:hover {
    opacity: 1;
}

/* --- Buton Play --- */
.playButton {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    padding: 10px 24px;
    border: none;
    cursor: pointer;
    border-radius: 50px;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 2;
}

.playButton:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}

.playButton:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

/* --- Loader --- */
.pve-loader {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(37, 99, 235, 0.15);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s ease-in-out infinite;
    z-index: 2;
}

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

/* --- Variațiuni de fundal --- */
.pve-color-1 { background: linear-gradient(135deg, #0f172a, #1e293b); }
.pve-color-2 { background: linear-gradient(135deg, #1e1b4b, #312e81); }
.pve-color-3 { background: linear-gradient(135deg, #2a0845, #6441a5); }
.pve-color-4 { background: linear-gradient(135deg, #064e3b, #0f766e); }
.pve-color-5 { background: linear-gradient(135deg, #18181b, #27272a); }

/* Telefoane: reclama se micșorează proporțional dacă lățimea disponibilă
   este mai mică decât 300px. Butonul de închidere rămâne deasupra ei. */
@media (max-width: 340px) {
    .pve-wrapper.pve-has-ad {
        min-height: calc((100vw - 26px) * 0.833333 + 24px);
    }

    .pve-ad-container {
        width: calc(100vw - 26px);
        height: calc((100vw - 26px) * 0.833333);
        max-width: 300px;
        max-height: 250px;
    }

    .pve-ad-content {
        width: 100%;
        height: 100%;
    }

    .pve-ad-content iframe {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
    }

    .pve-ad-close {
        top: 4px;
        right: 4px;
        font-size: 9px;
        padding: 2px 6px;
        height: 22px;
        line-height: 17px;
    }
}
