/**
 * MADÁ - Vanguard Londrina
 * Componentes CSS - Otimizado para Performance
 * Versão: 2.0.0
 */

/* ===== MODAL TETRIS ===== */
.tetris-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.tetris-modal-show {
    opacity: 1;
    visibility: visible;
}

.tetris-modal-closing {
    opacity: 0;
    visibility: hidden;
}

.tetris-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.tetris-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: #fff;
    border-radius: 12px;
    padding: 0;
    max-width: 400px !important;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.tetris-modal-show .tetris-modal-content {
    transform: translate(calc(-50% - 20px), -50%) scale(1);
}

.tetris-modal-closing .tetris-modal-content {
    transform: translate(-50%, -50%) scale(0.8);
}

.tetris-modal-header {
    background: linear-gradient(135deg, #71ACAD 0%, #FFFF00 100%);
    padding: 20px;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tetris-blocks {
    display: flex;
    gap: 8px;
}

.tetris-block {
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 4px;
    animation: tetrisFloat 2s ease-in-out infinite;
}

.tetris-block-1 { animation-delay: 0s; }
.tetris-block-2 { animation-delay: 0.5s; }
.tetris-block-3 { animation-delay: 1s; }
.tetris-block-4 { animation-delay: 1.5s; }

@keyframes tetrisFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.tetris-modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.tetris-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tetris-modal-body {
    padding: 30px;
    text-align: center;
}

.tetris-icon {
    margin-bottom: 20px;
}

.tetris-modal-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 15px 0;
    color: #333;
}

.tetris-modal-message {
    font-size: 16px;
    line-height: 1.5;
    color: #666;
    margin: 0;
}

.tetris-modal-footer {
    padding: 20px 30px 30px;
    text-align: center;
}

.tetris-modal-btn {
    background: linear-gradient(135deg, #71ACAD 0%, #FFFF00 100%);
    border: none;
    color: #fff;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-width: 120px;
}

.tetris-modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(113, 172, 173, 0.3);
}

.tetris-modal-btn:active {
    transform: translateY(0);
}

/* ===== MODAL DE IMAGEM ===== */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.image-modal.show {
    opacity: 1;
    visibility: visible;
}

/* Melhorias para imagens clicáveis */
.fluid-image-clickable {
    cursor: pointer !important;
    transition: transform 0.2s ease;
}

.fluid-image-clickable:hover {
    transform: scale(1.02);
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.image-modal.show .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.2s ease;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.9);
}

.modal-image {
    width: 100%;
    height: auto;
    display: block;
}

/* ===== ESTADOS DE LOADING ===== */
.submit-btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.submit-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ===== LAZY LOADING ===== */
.lazy {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy.loaded {
    opacity: 1;
}

/* ===== OTIMIZAÇÕES DE PERFORMANCE ===== */
.effect-parallax,
.item-1,
.item-2,
.item-3,
.item-fluid-1,
.item-fluid-2,
.item-fluid-3,
.item-fluid-4,
.embed,
.sd-abs {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ===== CRITICAL IMAGES - CLS PREVENTION ===== */
.top img.top-img {
    object-fit: cover;
    object-position: center;
    max-width: 100%;
    height: auto;
    display: block;
    /* Otimizações para LCP */
    will-change: transform;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Logo otimizado para LCP */
.logo {
    max-width: 194px;
    height: auto;
    /* Garante que o logo seja renderizado imediatamente */
    display: block;
    will-change: auto;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure aspect ratio is maintained even if CSS aspect-ratio is not supported */
.top img.desktop {
    aspect-ratio: 3000/2164; /* ~1.39:1 - Landscape */
}

.top img.mobile {
    aspect-ratio: 752/2980; /* ~0.25:1 - Portrait/Vertical */
}

/* Fallback for browsers that don't support aspect-ratio */
@supports not (aspect-ratio: 3000/2164) {
    .top img.desktop {
        height: 72.13vw; /* 3000/2164 aspect ratio */
        max-height: 100vh;
    }
    
    .top img.mobile {
        height: 396.28vw; /* 752/2980 aspect ratio */
        max-height: 100vh;
    }
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 768px) {
    .tetris-modal-content {
        max-width: 95vw;
        margin: 20px;
    }
    
    .tetris-modal-header {
        padding: 15px;
    }
    
    .tetris-modal-body {
        padding: 20px;
    }
    
    .tetris-modal-footer {
        padding: 15px 20px 20px;
    }
    
    .tetris-modal-title {
        font-size: 20px;
    }
    
    .tetris-modal-message {
        font-size: 14px;
    }
    
    .tetris-modal-btn {
        padding: 10px 25px;
        font-size: 14px;
    }
    
    .modal-content {
        max-width: 95vw;
        max-height: 80vh;
    }
}

/* ===== ACESSIBILIDADE ===== */
@media (prefers-reduced-motion: reduce) {
    .tetris-modal,
    .tetris-modal-content,
    .tetris-block,
    .tetris-modal-btn,
    .image-modal,
    .lazy {
        animation: none !important;
        transition: none !important;
    }
}

/* ===== FOCUS VISIBLE ===== */
.tetris-modal-close:focus-visible,
.tetris-modal-btn:focus-visible,
.modal-close:focus-visible {
    outline: 2px solid #FFFF00;
    outline-offset: 2px;
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    .tetris-modal-content {
        background: #1a1a1a;
        color: #fff;
    }
    
    .tetris-modal-title {
        color: #fff;
    }
    
    .tetris-modal-message {
        color: #ccc;
    }
    
    .modal-content {
        background: #1a1a1a;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .tetris-modal,
    .image-modal {
        display: none !important;
    }
}
