/**
 * Professional Iframe Embed Module - Mobile Demo Style
 * @package     mod_iframe_embed
 * @copyright   Copyright (C) 2025 Your Name. All rights reserved.
 * @license     GNU General Public License version 2 or later
 */

/* ========================================
   ROOT VARIABLES
   ======================================== */

:root {
    --device-bg: #1a1a1a;
    --device-border: #2d2d2d;
    --device-shadow: rgba(0, 0, 0, 0.3);
    --loading-color: #3498db;
    --iframe-bg: #ffffff;
    --notch-bg: #000000;
    --border-radius: 40px;
    --device-padding: 12px;
}

/* ========================================
   BASE CONTAINER - MOBILE FIRST
   ======================================== */

.iframe-embed-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ========================================
   DEVICE FRAME STYLES (iPhone/Android)
   ======================================== */

.iframe-embed-container.with-device-frame {
    padding: 40px 20px;
}

.device-frame {
    position: relative;
    width: 100%;
    max-width: 375px;
    background: var(--device-bg);
    border-radius: var(--border-radius);
    padding: var(--device-padding);
    box-shadow: 
        0 20px 60px var(--device-shadow),
        0 0 0 1px var(--device-border),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

/* Device Notch (iPhone Style) */
.device-notch {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
    height: 30px;
    background: var(--notch-bg);
    border-radius: 0 0 20px 20px;
    z-index: 10;
}

.device-speaker {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    z-index: 11;
}

.device-camera {
    position: absolute;
    top: 8px;
    right: 70px;
    width: 12px;
    height: 12px;
    background: rgba(30, 60, 90, 0.8);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    z-index: 11;
}

/* Home Indicator (iPhone bottom bar) */
.device-home-indicator {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    height: 5px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

/* ========================================
   IFRAME WRAPPER
   ======================================== */

.iframe-embed-wrapper {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 177.78%; /* 9:16 aspect ratio */
    background: var(--iframe-bg);
    border-radius: 28px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.with-device-frame .iframe-embed-wrapper {
    border-radius: 28px;
}

/* ========================================
   IFRAME STYLES
   ======================================== */

.iframe-embed-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background: #fff;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.iframe-embed-container.iframe-loaded iframe {
    opacity: 1;
}

/* ========================================
   LOADING STATE - PROFESSIONAL SPINNER
   ======================================== */

.iframe-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 5;
    opacity: 1;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.iframe-embed-wrapper.loaded .iframe-loading {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Spinner Animation */
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 20px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.5px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Mobile Small (320px - 374px) */
@media (max-width: 374px) {
    .device-frame {
        max-width: 100%;
        border-radius: 30px;
    }
    
    .iframe-embed-wrapper {
        border-radius: 20px;
    }
}

/* Mobile Medium (375px - 414px) */
@media (min-width: 375px) and (max-width: 414px) {
    .device-frame {
        max-width: 375px;
    }
}

/* Mobile Large (415px - 767px) */
@media (min-width: 415px) and (max-width: 767px) {
    .device-frame {
        max-width: 414px;
    }
    
    .iframe-embed-wrapper {
        padding-bottom: 160%;
    }
}

/* Tablet (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .device-frame {
        max-width: 450px;
    }
    
    .iframe-embed-wrapper {
        padding-bottom: 150%;
    }
}

/* Desktop (1025px and up) */
@media (min-width: 1025px) {
    .iframe-embed-container {
        padding: 60px 20px;
    }
    
    .device-frame {
        max-width: 390px;
        box-shadow: 
            0 30px 80px rgba(0, 0, 0, 0.4),
            0 0 0 1px var(--device-border),
            inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    }
    
    .iframe-embed-wrapper {
        padding-bottom: 177.78%;
    }
}

/* Extra Large Desktop (1440px+) */
@media (min-width: 1440px) {
    .device-frame {
        max-width: 430px;
    }
}

/* ========================================
   LANDSCAPE MODE
   ======================================== */

@media (max-width: 767px) and (orientation: landscape) {
    .iframe-embed-wrapper {
        padding-bottom: 56.25%; /* 16:9 */
    }
    
    .device-frame {
        max-width: 100%;
    }
}

/* ========================================
   MINIMAL STYLE (Without Device Frame)
   ======================================== */

.iframe-embed-container:not(.with-device-frame) .iframe-embed-wrapper {
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-width: 100%;
}

/* ========================================
   ANDROID DEVICE STYLE
   ======================================== */

.iframe-embed-container.device-android .device-frame {
    border-radius: 35px;
    background: linear-gradient(145deg, #2d2d2d, #1a1a1a);
}

.iframe-embed-container.device-android .device-notch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    top: 15px;
}

.iframe-embed-container.device-android .device-home-indicator {
    display: none;
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --device-bg: #0d0d0d;
        --device-border: #1a1a1a;
        --iframe-bg: #1a1a1a;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.iframe-embed-container iframe:focus {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .spinner,
    .loading-text,
    .iframe-embed-container iframe {
        animation: none;
        transition: none;
    }
}

/* ========================================
   ERROR STATE
   ======================================== */

.iframe-embed-wrapper.error .iframe-loading {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.iframe-embed-wrapper.error .loading-text::after {
    content: ' Failed to load';
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .device-frame,
    .iframe-loading,
    .device-notch,
    .device-speaker,
    .device-camera,
    .device-home-indicator {
        display: none !important;
    }
    
    .iframe-embed-container {
        max-width: 100%;
    }
    
    .iframe-embed-wrapper {
        border: 1px solid #000;
        border-radius: 0;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.iframe-embed-container.iframe-shadow {
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.2));
}

.iframe-embed-container.iframe-centered {
    margin: 0 auto;
}

.iframe-embed-container.iframe-fullwidth .device-frame {
    max-width: 100%;
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */

.iframe-embed-container iframe::-webkit-scrollbar {
    width: 6px;
}

.iframe-embed-container iframe::-webkit-scrollbar-track {
    background: transparent;
}

.iframe-embed-container iframe::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.iframe-embed-container iframe::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
}

/* ========================================
   SAFE AREA (Notched Devices)
   ======================================== */

@supports (padding: max(0px)) {
    .iframe-embed-container {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
}

/* ========================================
   TOUCH OPTIMIZATION
   ======================================== */

.iframe-embed-container iframe {
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    -webkit-tap-highlight-color: transparent;
}

/* ========================================
   HOVER EFFECTS (Desktop Only)
   ======================================== */

@media (min-width: 1025px) {
    .device-frame {
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
    
    .iframe-embed-container:hover .device-frame {
        transform: translateY(-5px);
        box-shadow: 
            0 35px 90px rgba(0, 0, 0, 0.5),
            0 0 0 1px var(--device-border);
    }
}
