/**
 * AdLogic Custom Interstitial Styles
 * 
 * Namespaced to prevent conflicts with Google's web interstitials
 * 
 * @package AdLogic
 * @version 1.0.0
 */

/* Custom Interstitial Overlay */
.adlogic-interstitial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    z-index: 2147483640; /* High but under Google's max */
    display: flex;
    align-items: center;
    justify-content: center;
}

.adlogic-interstitial-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Show container when overlay is active */
.adlogic-interstitial-overlay.active .adlogic-interstitial-container {
    display: flex !important;
}

/* Wrapper for branding + container */
.adlogic-interstitial-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90vw;
    max-height: 90vh;
}

/* Branding above container */
.adlogic-interstitial-branding-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%; /* Ensure full width for proper centering */
    margin-bottom: 8px;
    /* Ensure branding doesn't interfere with trigger button */
    pointer-events: none;
    z-index: 2147483645; /* Higher than overlay to ensure visibility */
    position: relative;
    opacity: 1 !important; /* Force visibility */
    visibility: visible !important; /* Force visibility */
}

.adlogic-interstitial-branding-wrapper .noadcode-branding {
    display: inline-flex !important;
    align-items: center;
    gap: 0.3em;
    padding: 0.5em 1em !important;
    border-radius: 6px;
    background: #1a1a1a;
    color: #ffffff;
    text-decoration: none;
    font-size: clamp(9px, 2vw, 12px);
    font-weight: 500;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    /* Re-enable pointer events for the link itself */
    pointer-events: auto;
    opacity: 1 !important; /* Ensure link is visible */
    visibility: visible !important; /* Ensure link is visible */
}

.adlogic-interstitial-branding-wrapper .noadcode-branding:hover {
    background: #000000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}

.adlogic-interstitial-branding-wrapper .noadcode-branding .lightning-icon {
    color: #FFD700;
    font-size: 1.2em;
    line-height: 1;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.6);
}

/* Custom Interstitial Container - Unique properties */
.adlogic-interstitial-container {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    width: auto;
    min-width: 320px;
    max-width: 85vw;
    max-height: calc(85vh - 60px); /* Account for branding above */
    border-radius: 0px 16px 16px 16px;

    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35),
                0 0 0 1px rgba(0, 0, 0, 0.04);
    position: relative;
    overflow: hidden;
    /* Hide by default - only show when overlay is active */
    display: none !important;
    flex-direction: column;
    transform: none;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    border: 1px solid rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
}

/* Unique interstitial container border glow effect */
.adlogic-interstitial-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #4285f4, #34a853, #fbbc05, #ea4335);
    background-size: 400% 100%;
    animation: interstitialGradient 8s ease infinite;
}

@keyframes interstitialGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Animation Variations - Updated for wrapper structure */
.adlogic-interstitial-overlay.animation-slide-up .adlogic-interstitial-wrapper {
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fallback for undefined animation - use slide-up as default */
.adlogic-interstitial-overlay.animation-undefined .adlogic-interstitial-wrapper {
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.adlogic-interstitial-overlay.animation-slide-up.active .adlogic-interstitial-wrapper {
    transform: translateY(0);
}

.adlogic-interstitial-overlay.animation-undefined.active .adlogic-interstitial-wrapper {
    transform: translateY(0);
}

.adlogic-interstitial-overlay.animation-slide-down .adlogic-interstitial-wrapper {
    transform: translateY(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.adlogic-interstitial-overlay.animation-slide-down.active .adlogic-interstitial-wrapper {
    transform: translateY(0);
}

.adlogic-interstitial-overlay.animation-fade .adlogic-interstitial-wrapper {
    opacity: 0;
    transition: opacity 0.4s ease;
}

.adlogic-interstitial-overlay.animation-fade.active .adlogic-interstitial-wrapper {
    opacity: 1;
}

.adlogic-interstitial-overlay.animation-zoom .adlogic-interstitial-wrapper {
    transform: scale(0.8);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
}

.adlogic-interstitial-overlay.animation-zoom.active .adlogic-interstitial-wrapper {
    transform: scale(1);
    opacity: 1;
}

/* Removed old header styles - branding is now above container */

/* Custom Close Button - Positioned at top-right of container */
.adlogic-interstitial-close {
    position: absolute;
    top: 0px;
    right: 12px;
    width: 34px; /* Reduced by 25% from 45px */
    height: 34px;
    border-radius: 4px; /* Square with slight rounding to match other buttons */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border: 2px solid rgba(255, 255, 255, 0.9);
    color: #ffffff;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                background 0.3s ease,
                box-shadow 0.3s ease;
    z-index: 20;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform-origin: center center; /* Ensure rotation happens from center */
    overflow: visible; /* Allow hover area to extend beyond button */
}

.adlogic-interstitial-close:hover {
    background: linear-gradient(135deg, #764ba2 0%, #8b5cf6 100%) !important;
    transform: rotate(90deg); /* Removed scale to prevent size change */
    box-shadow: 0 6px 20px rgba(118, 75, 162, 0.5);
}

.adlogic-interstitial-close:active {
    transform: scale(0.95);
}

.adlogic-interstitial-close::before,
.adlogic-interstitial-close::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 3px;
    background: #ffffff;
    border-radius: 2px;
}

.adlogic-interstitial-close::before {
    transform: rotate(45deg);
}

.adlogic-interstitial-close::after {
    transform: rotate(-45deg);
}

/* Small Close Button Variant */
.adlogic-interstitial-close.small {
    width: 32px;
    height: 32px;
    border-radius: 4px; /* Keep square shape for small variant */
}

.adlogic-interstitial-close.small::before,
.adlogic-interstitial-close.small::after {
    width: 16px;
    height: 2px;
}

/* Custom Interstitial Content - Unique padding for interstitial */
.adlogic-interstitial-content {
    padding: 35px 30px 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex: 1;
    background: transparent;
    position: relative;
}

/* Subtle pattern for interstitial background */
.adlogic-interstitial-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: radial-gradient(circle at 20% 80%, rgba(66, 133, 244, 0.03) 0%, transparent 50%),
                      radial-gradient(circle at 80% 20%, rgba(234, 67, 53, 0.03) 0%, transparent 50%),
                      radial-gradient(circle at 40% 40%, rgba(52, 168, 83, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.adlogic-interstitial-ad-slot {
    position: relative;
    z-index: 1;
}

/* Ad Slot Container - Dynamic sizing */
.adlogic-interstitial-ad-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    width: auto;
    height: auto;
    border-radius: 8px;
    margin: 0 auto;
}

/* Size Variations */
.adlogic-interstitial-container.size-300x250 .adlogic-interstitial-ad-slot {
    width: 300px;
    height: 250px;
}

.adlogic-interstitial-container.size-336x280 .adlogic-interstitial-ad-slot {
    width: 336px;
    height: 280px;
}

.adlogic-interstitial-container.size-320x480 .adlogic-interstitial-ad-slot {
    width: 320px;
    height: 480px;
}

.adlogic-interstitial-container.size-728x90 .adlogic-interstitial-ad-slot {
    width: 728px;
    height: 90px;
}

.adlogic-interstitial-container.size-responsive .adlogic-interstitial-ad-slot {
    width: 100%;
    max-width: 728px;
    min-height: 250px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .adlogic-interstitial-wrapper {
        max-width: 95vw;
    }
    
    .adlogic-interstitial-container {
        max-width: 100%;
        max-height: calc(85vh - 50px);
        border-radius: 12px;
    }
    
    .adlogic-interstitial-branding-wrapper .noadcode-branding {
        font-size: 10px;
        padding: 0.4em 0.8em;
    }
    
    .adlogic-interstitial-content {
        padding: 20px;
        max-height: calc(85vh - 100px);
    }
    
    .adlogic-interstitial-close {
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
    
    /* Adjust ad slot sizes for mobile */
    .adlogic-interstitial-container.size-728x90 .adlogic-interstitial-ad-slot {
        width: 100%;
        max-width: 320px;
    }
}

/* Accessibility */
.adlogic-interstitial-close:focus {
    outline: 3px solid #2196F3;
    outline-offset: 2px;
}

/* No scroll on body when interstitial is active */
body.adlogic-interstitial-active {
    overflow: hidden;
}

/* Loading State */
.adlogic-interstitial-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.adlogic-interstitial-loading::after {
    content: '';
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2196F3;
    border-radius: 50%;
    animation: adlogic-spin 1s linear infinite;
}

@keyframes adlogic-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Debug Mode Styling */
.adlogic-debug-mode .adlogic-interstitial-overlay {
    border: 4px dashed #ff0000;
}

.adlogic-debug-mode .adlogic-interstitial-container::before {
    content: 'CUSTOM INTERSTITIAL';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: #ff0000;
    color: white;
    text-align: center;
    padding: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 1;
}

/* Print Styles */
@media print {
    .adlogic-interstitial-overlay {
        display: none !important;
    }
}

/* Enhanced Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .adlogic-interstitial-container {
        background: #1a1a1a;
        color: #e0e0e0;
    }
    
    .adlogic-interstitial-header {
        background: #2a2a2a;
        border-bottom-color: #444;
    }
    
    .adlogic-interstitial-title {
        color: #ffffff !important;
    }
    
    /* All text elements in content */
    .adlogic-interstitial-content {
        color: #ffffff !important;
    }
    
    .adlogic-interstitial-content h1,
    .adlogic-interstitial-content h2,
    .adlogic-interstitial-content h3,
    .adlogic-interstitial-content h4,
    .adlogic-interstitial-content h5,
    .adlogic-interstitial-content h6,
    .adlogic-interstitial-content p,
    .adlogic-interstitial-content span,
    .adlogic-interstitial-content div,
    .adlogic-interstitial-content li,
    .adlogic-interstitial-content a {
        color: #1f2937 !important;
    }
    
    /* Close button keeps its gradient in dark mode - removed overrides */
    
    .adlogic-interstitial-close::before,
    .adlogic-interstitial-close::after {
        background: #ffffff;
    }
    
    .adlogic-interstitial-ad-slot {
        background: #2a2a2a;
        border-color: #444;
    }
    
    /* Ad placeholder text */
    .adlogic-ad-placeholder,
    .adlogic-interstitial-ad-placeholder {
        color: #cccccc !important;
        background: #2a2a2a !important;
    }
    
    /* Loading spinner */
    .adlogic-interstitial-loading::after {
        border-color: #444;
        border-top-color: #2196F3;
    }
    
    /* Debug info */
    .adlogic-debug-info {
        color: #999999 !important;
    }
}

/* Debug Panel Styles */
.adlogic-interstitial-debug {
    background: #fff;
    border: 3px solid #ff0000;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.adlogic-interstitial-debug .debug-header {
    font-size: 16px;
    font-weight: bold;
    color: #ff0000;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ff0000;
}

.adlogic-interstitial-debug .debug-checklist {
    font-family: monospace;
    font-size: 13px;
}

.adlogic-interstitial-debug .checklist-item {
    padding: 8px 10px;
    margin: 5px 0;
    background: #f5f5f5;
    border-left: 4px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.adlogic-interstitial-debug .checklist-item[data-check="gpt"] {
    border-left-color: #2196F3;
}

.adlogic-interstitial-debug .checklist-item[data-check="config"] {
    border-left-color: #4CAF50;
}

.adlogic-interstitial-debug .checklist-item[data-check="trigger"] {
    border-left-color: #FF9800;
}

.adlogic-interstitial-debug .checklist-item[data-check="frequency"] {
    border-left-color: #9C27B0;
}

.adlogic-interstitial-debug .status {
    font-weight: bold;
    color: #666;
    background: #fff;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid #ddd;
}

.adlogic-interstitial-debug .status.success {
    color: #4CAF50;
    border-color: #4CAF50;
}

.adlogic-interstitial-debug .status.error {
    color: #f44336;
    border-color: #f44336;
}

.adlogic-interstitial-debug .status.warning {
    color: #FF9800;
    border-color: #FF9800;
}

/* Alternative class-based dark mode support */
.dark .adlogic-interstitial-container,
body.dark-mode .adlogic-interstitial-container,
html.dark .adlogic-interstitial-container {
    background: #1a1a1a;
    color: #e0e0e0;
}

.dark .adlogic-interstitial-header,
body.dark-mode .adlogic-interstitial-header,
html.dark .adlogic-interstitial-header {
    background: #2a2a2a;
    border-bottom-color: #444;
}

.dark .adlogic-interstitial-title,
body.dark-mode .adlogic-interstitial-title,
html.dark .adlogic-interstitial-title {
    color: #ffffff !important;
}

.dark .adlogic-interstitial-content,
body.dark-mode .adlogic-interstitial-content,
html.dark .adlogic-interstitial-content,
.dark .adlogic-interstitial-content *,
body.dark-mode .adlogic-interstitial-content *,
html.dark .adlogic-interstitial-content * {
    color: #ffffff !important;
}

/* Close button maintains gradient in dark mode - no overrides needed */

.dark .adlogic-interstitial-close::before,
.dark .adlogic-interstitial-close::after,
body.dark-mode .adlogic-interstitial-close::before,
body.dark-mode .adlogic-interstitial-close::after,
html.dark .adlogic-interstitial-close::before,
html.dark .adlogic-interstitial-close::after {
    background: #ffffff;
}

.dark .adlogic-interstitial-ad-slot,
body.dark-mode .adlogic-interstitial-ad-slot,
html.dark .adlogic-interstitial-ad-slot {
    background: #2a2a2a;
    border-color: #444;
}

.dark .adlogic-ad-placeholder,
.dark .adlogic-interstitial-ad-placeholder,
body.dark-mode .adlogic-ad-placeholder,
body.dark-mode .adlogic-interstitial-ad-placeholder,
html.dark .adlogic-ad-placeholder,
html.dark .adlogic-interstitial-ad-placeholder {
    color: #cccccc !important;
    background: #2a2a2a !important;
}