/**
 * CSS Frontend - iFrame Embed Pro
 * Estilos responsivos para incorporação de conteúdo e PDFs
 */

/* Container principal */
.iframe-embed-pro-container {
    position: relative;
    max-width: 100%;
    overflow: hidden;
    clear: both;
}

/* Alinhamento */
.iframe-embed-pro-container.align-left {
    float: left;
    margin-right: 1em;
}

.iframe-embed-pro-container.align-right {
    float: right;
    margin-left: 1em;
}

.iframe-embed-pro-container.align-center {
    display: block;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

/* iFrame padrão */
.iframe-embed-pro-iframe {
    display: block;
    width: 100%;
    border: 1px solid #cccccc;
    background: #fff;
    transition: border-color 0.3s ease;
}

.iframe-embed-pro-iframe:hover {
    border-color: #999;
}

/* Botão de tela cheia */
.iframe-embed-pro-fullscreen-wrapper {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
}

.iframe-embed-pro-fullscreen-btn {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    opacity: 0;
}

.iframe-embed-pro-container:hover .iframe-embed-pro-fullscreen-btn {
    opacity: 1;
}

.iframe-embed-pro-fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* Modo tela cheia */
.iframe-embed-pro-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999;
    margin: 0 !important;
    padding: 0 !important;
    background: #000;
}

.iframe-embed-pro-container.fullscreen .iframe-embed-pro-iframe {
    width: 100% !important;
    height: 100% !important;
    border: none;
}

.iframe-embed-pro-container.fullscreen .iframe-embed-pro-fullscreen-btn {
    opacity: 1;
}

/* PDF Viewer */
.iframe-embed-pro-pdf-viewer {
    border: 1px solid #cccccc;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
}

.pdf-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    flex-wrap: wrap;
    gap: 10px;
}

.pdf-viewer-controls,
.pdf-viewer-zoom,
.pdf-viewer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pdf-viewer-page-info {
    font-size: 14px;
    color: #666;
    font-weight: 500;
    min-width: 60px;
    text-align: center;
}

.pdf-viewer-zoom-level {
    font-size: 12px;
    color: #666;
    min-width: 45px;
    text-align: center;
}

.pdf-viewer-btn {
    background: #fff;
    border: 1px solid #ddd;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-viewer-btn:hover {
    background: #f0f0f0;
    border-color: #999;
}

.pdf-viewer-btn:active {
    background: #e0e0e0;
}

.pdf-viewer-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pdf-viewer-container {
    position: relative;
    background: #f9f9f9;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-viewer-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Estados de loading e erro */
.iframe-embed-pro-loading,
.pdf-viewer-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #666;
}

.iframe-embed-pro-error,
.pdf-viewer-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #d63638;
}

.iframe-embed-pro-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: iframe-embed-pro-spin 1s linear infinite;
    margin-bottom: 15px;
}

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

/* Lazy Load */
.iframe-embed-pro-container.lazy-load .iframe-embed-pro-iframe,
.iframe-embed-pro-container.lazy-load .iframe-embed-pro-pdf-viewer {
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

.iframe-embed-pro-container.lazy-load.loaded .iframe-embed-pro-iframe,
.iframe-embed-pro-container.lazy-load.loaded .iframe-embed-pro-pdf-viewer {
    opacity: 1;
}

/* Responsividade */
@media screen and (max-width: 1200px) {
    .iframe-embed-pro-container {
        max-width: 100%;
    }
}

@media screen and (max-width: 768px) {
    .iframe-embed-pro-container.align-left,
    .iframe-embed-pro-container.align-right {
        float: none;
        margin-left: 0;
        margin-right: 0;
        display: block;
    }
    
    .iframe-embed-pro-container.align-center {
        text-align: left;
    }
    
    .pdf-viewer-toolbar {
        padding: 8px 10px;
        gap: 5px;
    }
    
    .pdf-viewer-controls,
    .pdf-viewer-zoom,
    .pdf-viewer-actions {
        gap: 5px;
    }
    
    .pdf-viewer-btn {
        padding: 5px 6px;
    }
    
    .pdf-viewer-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .pdf-viewer-page-info,
    .pdf-viewer-zoom-level {
        font-size: 12px;
    }
    
    .iframe-embed-pro-fullscreen-wrapper {
        top: 5px;
        right: 5px;
    }
    
    .iframe-embed-pro-fullscreen-btn {
        padding: 6px;
    }
}

@media screen and (max-width: 480px) {
    .pdf-viewer-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .pdf-viewer-controls,
    .pdf-viewer-zoom,
    .pdf-viewer-actions {
        justify-content: center;
    }
    
    .pdf-viewer-container {
        min-height: 300px;
    }
    
    .iframe-embed-pro-loading,
    .iframe-embed-pro-error,
    .pdf-viewer-loading,
    .pdf-viewer-error {
        padding: 20px;
    }
    
    .iframe-embed-pro-spinner {
        width: 30px;
        height: 30px;
        border-width: 3px;
    }
}

/* Orientação específica para PDFs em mobile */
@media screen and (max-width: 768px) and (orientation: portrait) {
    .iframe-embed-pro-pdf-viewer[data-orientation="vertical"] .pdf-viewer-canvas {
        max-width: 100%;
        height: auto !important;
    }
    
    .iframe-embed-pro-pdf-viewer[data-orientation="vertical"] .pdf-viewer-container {
        background: #fff;
    }
}

@media screen and (max-width: 768px) and (orientation: landscape) {
    .iframe-embed-pro-pdf-viewer[data-orientation="horizontal"] .pdf-viewer-canvas {
        max-height: 70vh;
        width: auto !important;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .pdf-viewer-canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Modo escuro (se suportado) */
@media (prefers-color-scheme: dark) {
    .iframe-embed-pro-pdf-viewer {
        background: #2d2d2d;
        border-color: #555;
    }
    
    .pdf-viewer-toolbar {
        background: #3d3d3d;
        border-bottom-color: #555;
    }
    
    .pdf-viewer-btn {
        background: #4d4d4d;
        border-color: #666;
        color: #fff;
    }
    
    .pdf-viewer-btn:hover {
        background: #5d5d5d;
        border-color: #777;
    }
    
    .pdf-viewer-page-info,
    .pdf-viewer-zoom-level {
        color: #ccc;
    }
    
    .pdf-viewer-container {
        background: #2d2d2d;
    }
    
    .pdf-viewer-canvas {
        box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
    }
}

/* Impressão */
@media print {
    .iframe-embed-pro-container {
        page-break-inside: avoid;
        max-width: 100% !important;
    }
    
    .iframe-embed-pro-fullscreen-wrapper,
    .pdf-viewer-toolbar {
        display: none !important;
    }
    
    .iframe-embed-pro-iframe,
    .iframe-embed-pro-pdf-viewer {
        border: 1px solid #000 !important;
        max-width: 100% !important;
    }
    
    .pdf-viewer-canvas {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
    }
}

/* Acessibilidade */
.iframe-embed-pro-container:focus-within {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.iframe-embed-pro-fullscreen-btn:focus,
.pdf-viewer-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Animações suaves */
.iframe-embed-pro-container,
.iframe-embed-pro-iframe,
.iframe-embed-pro-pdf-viewer,
.pdf-viewer-canvas {
    transition: all 0.3s ease;
}

/* Performance */
.iframe-embed-pro-container {
    will-change: auto;
}

.iframe-embed-pro-iframe,
.pdf-viewer-canvas {
    will-change: transform;
}

/* Correção para problemas comuns */
.iframe-embed-pro-container {
    box-sizing: border-box;
}

.iframe-embed-pro-iframe,
.iframe-embed-pro-pdf-viewer {
    box-sizing: border-box;
}

/* Evitar overflow horizontal */
.iframe-embed-pro-container {
    overflow-x: hidden;
}

/* Scrollbar personalizada para PDF viewer */
.pdf-viewer-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.pdf-viewer-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.pdf-viewer-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.pdf-viewer-container::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}
