/* --- Base Styles (Your Existing Logic) --- */
.dooble-ad-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 50px;
    margin: 15px 0;
    position: relative;
    overflow: visible; /* Changed from hidden to allow 'outside' close button */
    width: 100%;
}

/* --- CLS Prevention: Fixed Sizes based on ACF Selection --- */
/* We use data-attributes that the JS will set on the container */
.dooble-ad-placeholder[data-size="leader"] { min-height: 90px; }
.dooble-ad-placeholder[data-size="rect"]   { min-height: 250px; }
.dooble-ad-placeholder[data-size="large"]  { min-height: 280px; }
.dooble-ad-placeholder[data-size="sky"]    { min-height: 600px; }
.dooble-ad-placeholder[data-size="mobile"] { min-height: 50px; }

/* --- Sticky Behavior --- */
.dooble-ad-placeholder.is-sticky {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 9999;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    margin: 0;
    transform: translateY(100%);
    transition: transform 0.4s ease-in-out;
}
.dooble-ad-placeholder.is-sticky.loaded {
    transform: translateY(0);
}

/* --- Modal Behavior --- */
.dooble-ad-placeholder.is-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.4s ease-out;
    pointer-events: none; /* Prevent blocking clicks when invisible */
}
.dooble-ad-placeholder.is-modal.loaded {
    opacity: 1;
    pointer-events: auto;
}
.dooble-ad-placeholder.is-modal .dooble-ad-wrapper {
    background: #fff;
    padding: 15px; /* Adjust padding as needed */
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
    position: relative;
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
}

/* --- Close Button: Support for dynamic positions --- */
.dooble-close {
    position: absolute;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 20px;
}

/* Close button position modifiers (based on ACF) */
.dooble-close.pos-top-right { top: 10px; right: 10px; }
.dooble-close.pos-top-left  { top: 10px; left: 10px; }
.dooble-close.pos-outside   { top: -15px; right: -15px; }

/* --- Loader Animation (Your Logic) --- */
.dooble-loader {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.dooble-ad-placeholder.loaded .dooble-loader {
    display: none;
}

/* --- Smooth Reveal --- */
.dooble-ad-wrapper {
    opacity: 0;
    transition: opacity 0.5s ease;
}
.dooble-ad-placeholder.loaded .dooble-ad-wrapper {
    opacity: 1;
}

/* --- Utility: Fallback --- */
.dooble-ad-fallback {
    background: #f1f1f1;
    border: 1px dashed #ccc;
    padding: 15px;
    text-align: center;
    font-size: 11px;
}