/**
 * Reviews Image Modal Base CSS
 * Modal structure, overlay, close button, navigation buttons
 * 
 * Split from image-modal.css
 */

/* Modal pentru vizualizarea imaginilor */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.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: white;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    color: #590202; /* Culoarea vișinie din temă */
    transition: opacity 0.3s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    opacity: 0.7;
    transform: scale(1.1);
}

/* Butoane de navigare în modal */
.modal-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10000;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    padding: 0;
    opacity: 0;
    pointer-events: none;
}

.modal-nav-btn svg {
    width: 24px;
    height: 24px;
    fill: #590202;
    transition: fill 0.2s ease;
}

.modal-nav-btn:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #590202;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.modal-nav-btn:hover svg {
    fill: #590202;
}

.modal-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.modal-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.modal-nav-btn.prev {
    left: 10px;
}

.modal-nav-btn.next {
    right: 10px;
}

/* Previne scroll-ul în fundal când modalul este deschis */
html.modal-open,
body.modal-open {
    overflow: hidden !important;
    /* Previne scroll pe dispozitive touch */
    touch-action: none;
    /* Previne scroll cu mouse wheel */
    overscroll-behavior: none;
}

/* =====================================================================
   RESPONSIVE - Image Modal Base
   ===================================================================== */

/* Afișează butoanele pe desktop când modalul este deschis */
@media (min-width: 768px) {
    #image-modal:not([style*="display: none"]) .modal-nav-btn,
    #image-modal.show .modal-nav-btn {
        opacity: 1;
        pointer-events: auto;
    }
    
    /* Afișează butoanele când modalul este vizibil (fadeIn) */
    #image-modal[style*="display: block"] .modal-nav-btn,
    #image-modal[style*="display: flex"] .modal-nav-btn {
        opacity: 1;
        pointer-events: auto;
    }
    
    /* Dimensiune fixă pentru desktop */
    .modal-content {
        width: 900px;
        height: 700px;
        max-width: 900px;
        max-height: 700px;
    }
}

/* Ascunde butoanele pe mobile */
@media (max-width: 767px) {
    .modal-nav-btn {
        display: none !important;
    }
}

/* Corectii pentru dispozitive mobile reale */
@media (max-width: 768px) {
    .image-modal {
        align-items: center;
        justify-content: center;
    }
    
    .modal-content {
        /* Limitează strict dimensiunile la viewport */
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        
        /* Layout fix */
        display: flex;
        flex-direction: column;
        border-radius: 0;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        overflow: hidden; /* Previne overflow */
    }
    
    /* Corectare pentru Safari iOS - viewport real */
    @supports (-webkit-touch-callout: none) {
        .modal-content {
            height: -webkit-fill-available;
            max-height: -webkit-fill-available;
        }
    }
}

/* Corectii specifice pentru iOS/iPhone */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        .image-modal {
            height: 100vh;
            height: -webkit-fill-available;
            height: 100dvh;
            align-items: center;
            justify-content: center;
        }
        
        .modal-content {
            height: 100vh;
            height: -webkit-fill-available;
            height: 100dvh;
            max-height: 100vh;
            max-height: -webkit-fill-available;
            max-height: 100dvh;
            /* Forțează flexbox să funcționeze pe iOS Safari */
            -webkit-box-orient: vertical;
            -webkit-box-direction: normal;
            -webkit-flex-direction: column;
            flex-direction: column;
        }
    }
}

/* Focus styles pentru accesibilitate */
.photo-item:focus {
    outline: 2px solid #590202;
    outline-offset: 2px;
}
