/* ==========================================
   Ad Preview Device Frame Simulator
   Shared styles for content preview + approval review
   ========================================== */

/* ------- Preview Toolbar ------- */
.preview-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px 10px 0 0;
    flex-wrap: wrap;
}

.preview-toolbar label {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.preview-toolbar select {
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-color);
    font-size: 0.85rem;
    cursor: pointer;
}

.preview-toolbar select option {
    background: #1a1a1a;
    color: #e0e0e0;
}

.preview-toolbar select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.preview-resolution-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    font-family: monospace;
}

.preview-toolbar-spacer {
    flex: 1;
}

.preview-toolbar .btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.15s, border-color 0.15s;
}

.preview-toolbar .btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
}

/* ------- Device Frame Wrapper ------- */
.device-frame-wrapper {
    position: relative;
    background: #111;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: none;
    border-radius: 0 0 10px 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 24px;
}

/* ------- Device Frame (the "screen bezel") ------- */
.device-frame {
    position: relative;
    border-radius: 8px;
    background: #1a1a1a;
    box-shadow:
        0 0 0 3px #333,
        0 0 0 5px #222,
        0 8px 30px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    transition: width 0.3s ease, height 0.3s ease;
}

.device-frame-label {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ------- Fullscreen Ad Format -------
   Orientation is not part of the ad format — it comes from the content's
   screen.orientation and only changes the frame's width/height. */
.device-frame.display-fullscreen .device-screen {
    width: 100%;
    height: 100%;
    position: relative;
}

.device-frame.display-fullscreen .device-screen iframe {
    width: 100%;
    height: 100%;
    border: none;
    position: relative;
    z-index: 1;
}

/* Background video layer (shared across ad formats) */
.preview-bg-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    pointer-events: none;
    background: #000;
}

/* Full-frame device background is active: make every zone + the ad iframe
   transparent so transparent parts of the ad — its #gymdooh-passthrough-region
   and the free area next to a sidebar or banner ad — reveal the background video. */
.device-frame.has-frame-bg .device-screen,
.device-frame.has-frame-bg .sidebar-main,
.device-frame.has-frame-bg .banner-main,
.device-frame.has-frame-bg .sidebar-ad,
.device-frame.has-frame-bg .banner-ad {
    background: transparent;
    position: relative;
    z-index: 1;
}

.device-frame.has-frame-bg .sidebar-main::after,
.device-frame.has-frame-bg .banner-main::after {
    display: none;
}

.device-frame.has-frame-bg iframe {
    background: transparent;
}

/* ------- Side Ad Ad Format -------
   Which side the ad strip sits on is decided by DOM order in
   DevicePreview._renderSidebar (a preview placement choice), not by a CSS class. */
.device-frame.display-sidebar {
    display: flex;
    flex-direction: row;
}

.device-frame .sidebar-main {
    flex: 1;
    background: #222;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.device-frame .sidebar-main::after {
    content: 'Main Content Area';
    color: rgba(255, 255, 255, 0.15);
    font-size: 0.85rem;
    position: absolute;
    pointer-events: none;
}

.device-frame .sidebar-ad {
    position: relative;
    overflow: hidden;
}

.device-frame .sidebar-ad iframe {
    width: 100%;
    height: 100%;
    border: none;
    position: relative;
    z-index: 1;
    /* Transparent so a creative's passthrough region reveals the backdrop below. */
    background: transparent;
}

/* Sits BEHIND the creative. Whatever the creative leaves transparent — typically its
   #gymdooh-passthrough-region — shows this instead of an empty black area, which is what
   made an intentional passthrough look like a rendering fault. */
.device-frame .passthrough-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    background:
        repeating-linear-gradient(135deg,
            rgba(255, 255, 255, 0.045) 0,
            rgba(255, 255, 255, 0.045) 6px,
            transparent 6px,
            transparent 12px),
        #1e1e1e;
}

.device-frame .passthrough-backdrop::after {
    content: attr(data-label);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8%;
    text-align: center;
    font-size: 0.7rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.28);
    pointer-events: none;
}

/* ------- Banner Ad Format ------- */
.device-frame.display-banner {
    display: flex;
    flex-direction: column;
}

.device-frame .banner-main {
    flex: 1;
    background: #222;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.device-frame .banner-main::after {
    content: 'Main Content Area';
    color: rgba(255, 255, 255, 0.15);
    font-size: 0.85rem;
    position: absolute;
    pointer-events: none;
}

.device-frame .banner-ad {
    position: relative;
    overflow: hidden;
}

.device-frame .banner-ad iframe {
    width: 100%;
    height: 100%;
    border: none;
    position: relative;
    z-index: 1;
    background: transparent;
}

/* ------- Fullscreen Mode ------- */
.preview-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.preview-fullscreen-overlay .preview-toolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    border-radius: 0;
    z-index: 1;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

.preview-fullscreen-overlay .device-frame-wrapper {
    flex: 1;
    border: none;
    border-radius: 0;
    width: 100%;
}

.preview-fullscreen-overlay .btn-close-fullscreen {
    position: absolute;
    top: 8px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.preview-fullscreen-overlay .btn-close-fullscreen:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* ------- Preview Actions (below frame) ------- */
.preview-actions-bar {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* ------- Responsive ------- */
@media (max-width: 768px) {
    .preview-toolbar {
        gap: 8px;
        padding: 8px 12px;
    }

    .device-frame-wrapper {
        padding: 12px;
        min-height: 200px;
    }

    .preview-resolution-label {
        display: none;
    }
}

/* ------- Annotation Pins ------- */
.annotation-overlay {
    position: absolute;
}

.annotation-pin {
    cursor: pointer;
    z-index: 20;
    transition: transform 0.15s;
}

.annotation-pin:hover {
    transform: translate(-50%, -100%) scale(1.2) !important;
}

.annotation-pin-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50% 50% 50% 0;
    background: #ef4444;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    transform: rotate(-45deg);
}

.annotation-pin-number::after {
    content: '';
}

/* Annotation mode active indicator */
.annotation-overlay[style*="pointer-events: auto"] {
    outline: 2px dashed rgba(99, 102, 241, 0.4);
    outline-offset: -2px;
}

/* Annotation summary in form */
.annotation-summary {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
    font-size: 0.85rem;
}

.annotation-summary-item {
    display: flex;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.annotation-summary-item:last-child {
    border-bottom: none;
}

.annotation-summary-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
}

.annotation-summary-text {
    color: var(--text-color);
}
