/* Általános modal stílusok */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    backdrop-filter: blur(3px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-background);
    border-radius: var(--radius-md);
    max-width: 90%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow-md);
    position: relative;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-color);
    transition: transform 0.2s ease;
}

.close-modal:hover {
    transform: rotate(90deg);
}

/* Javított kép modal stílusok - scroll pozíció megőrzéssel */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal-high); /* 4000 */
    opacity: 0;
    transition: opacity 0.3s ease;
    
    /* Scroll megakadályozása */
    overscroll-behavior: contain;
    overflow: hidden;
}

.image-modal.active {
    display: flex;
    opacity: 1;
}

.image-modal .modal-content {
    background: transparent;
    box-shadow: none;
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    margin: auto;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal .modal-image {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    display: block;
    transition: transform 0.3s ease;
}

/* Zoom effect hover-re (csak desktop-on) */
@media (min-width: 769px) {
    .image-modal .modal-image:hover {
        transform: scale(1.02);
    }
}

.image-modal .close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: var(--z-local); /* Lokális kiemelés a modalon belül */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    transition: all 0.2s ease;
    
    /* Accessibility javítás */
    outline: none;
}

.image-modal .close-modal:hover,
.image-modal .close-modal:focus {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg) scale(1.1);
    outline: 2px solid rgba(255, 255, 255, 0.5);
}

/* Body rögzítés modal aktív állapotában */
body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
}

/* Loading indikátor a kép betöltéséhez */
.image-modal .modal-content::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: var(--z-local); /* Lokális */
}

.image-modal .modal-image:not([src=""]) + .modal-content::before,
.image-modal.active .modal-content::before {
    display: none;
}

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

/* Mobil optimalizálás */
@media (max-width: 768px) {
    .image-modal {
        padding: 10px;
    }
    
    .image-modal .close-modal {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .image-modal .modal-content {
        width: 95vw;
        max-width: 95vw;
    }
    
    .image-modal .modal-image {
        max-width: 95vw;
        max-height: 80vh;
    }
}

/* Nagyon kis mobilok */
@media (max-width: 480px) {
    .image-modal .close-modal {
        top: 5px;
        right: 5px;
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .image-modal .modal-image {
        max-height: 75vh;
    }
}

/* Swipe indikátor mobilon */
@media (max-width: 768px) {
    .image-modal::after {
        content: 'Húzd felfelé vagy lefelé a bezáráshoz';
        position: absolute;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        color: rgba(255, 255, 255, 0.7);
        font-size: 12px;
        text-align: center;
        pointer-events: none;
        z-index: var(--z-local); /* Lokális */
        background: rgba(0, 0, 0, 0.5);
        padding: 5px 10px;
        border-radius: 15px;
    }
}

/* Google Translate */
.google-translate-container {
    position: fixed;
    top: -100%;
    left: 0;
    right: 0;
    width: 100%;
    background: var(--header-color);
    padding: 8px;
    text-align: right;
    z-index: var(--z-nav-sticky); /* 900 - nav szinten */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: top 0.3s ease;
}

.google-translate-container.visible {
    top: 0;
}