/* Modal Styles - Shared between index.html and admin.html */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease-out;
    justify-content: center;
    align-items: center;
}

.modal.show {
    opacity: 1;
}

.modal.hide {
    opacity: 0;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    width: calc(100vw - 200px); /* Leave space for arrows */
    max-width: 1200px; /* Reduced max width */
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
    margin: 0 auto;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes modalSlideOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-50px);
    }
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 2rem;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: #333;
}

/* Modal Navigation Arrows */
.modal-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #1976D2;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.8rem;
    color: #1976D2;
    transition: all 0.3s ease;
    z-index: 1001;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Show arrows when modal is open */
.modal.show .modal-nav {
    display: flex;
}

.modal-nav:hover {
    background: #1976D2;
    color: white;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.25);
}

.modal-nav.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.modal-nav-prev {
    left: calc((100vw - min(calc(100vw - 200px), 1200px)) / 4 - 30px);
}

.modal-nav-next {
    right: calc((100vw - min(calc(100vw - 200px), 1200px)) / 4 - 30px);
}

.modal-nav-prev::before {
    content: '‹';
}

.modal-nav-next::before {
    content: '›';
}

/* Modal Content Transitions */
.modal-content {
    transition: opacity 0.3s ease;
}

.modal-content.transitioning {
    opacity: 0;
}

/* Modal Content Styling */
#modal-title, #previewModalTitle {
    font-family: var(--font-heading);
    color: #0D47A1;
    margin-bottom: 20px;
    font-size: 2.6rem;
    font-weight: 600;
}

#modal-body, #previewModalBody {
    font-family: var(--font-body);
    color: #333;
    line-height: 1.6;
    font-size: 1.5rem;
}

#modal-body h3, #previewModalBody h3 {
    color: #1976D2;
    margin: 20px 0 10px 0;
    font-size: 1.4rem;
}

#modal-body ul, #previewModalBody ul {
    margin: 10px 0;
    padding-left: 20px;
}

#modal-body li, #previewModalBody li {
    margin: 5px 0;
}

#modal-body p, #previewModalBody p {
    margin: 10px 0;
}

#modal-body strong, #previewModalBody strong {
    font-weight: bold;
}

#modal-body em, #previewModalBody em {
    font-style: italic;
}

#modal-body a, #previewModalBody a {
    color: #1976D2;
    text-decoration: underline;
}

/* Modal Images and Links */
.modal-content img {
    max-width: 100%;
    max-height: 500px;
    height: auto;
    object-fit: contain;
}

.modal-image img {
    max-width: 100%;
    max-height: 500px;
    height: auto;
    border-radius: 8px;
    margin-bottom: 20px;
}

.modal-links {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.modal-links a {
    display: inline-block;
    background: #1976D2;
    color: white;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
}

.modal-links a:hover {
    background: #1565C0;
}

/* Two-column layout for modal body */
.modal-body-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.modal-text-content {
    flex: 1;
    min-width: 0; /* Allow text to shrink */
}

.modal-media-content {
    flex: 0 0 600px; /* Larger fixed width for media */
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-media-content.empty {
    display: none;
}

/* YouTube video styling - using responsive wrapper technique */
.modal-youtube-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio (9/16 = 0.5625) */
    height: 0;
    overflow: hidden;
    border-radius: 12px;
    background: #000;
}

.modal-youtube-wrapper iframe,
.modal-youtube {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 12px;
}

/* Fallback for direct iframe usage (if wrapper is not applied) */
.modal-youtube {
    width: 100%;
    aspect-ratio: 16/9;
    min-height: 300px; /* Quick fix to prevent squishing */
}

/* Enhanced image styling in modal */
.modal-image {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 0;
}

.modal-image img {
    width: 100%;
    max-height: 500px;
    height: auto;
    display: block;
    border-radius: 12px;
    margin-bottom: 0;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .modal-content {
        width: calc(100vw - 160px); /* Less space for arrows on medium screens */
    }
    
    .modal-nav-prev {
        left: calc((100vw - min(calc(100vw - 160px), 1200px)) / 4 - 25px);
    }
    
    .modal-nav-next {
        right: calc((100vw - min(calc(100vw - 160px), 1200px)) / 4 - 25px);
    }
}

@media (max-width: 768px) {
    .modal-content {
        width: calc(100vw - 120px); /* Even less space for arrows on mobile */
        max-width: none;
        padding: 20px;
    }
    
    .modal-nav {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .modal-nav-prev {
        left: calc((100vw - min(calc(100vw - 120px), 1200px)) / 4 - 25px);
    }
    
    .modal-nav-next {
        right: calc((100vw - min(calc(100vw - 120px), 1200px)) / 4 - 25px);
    }
    
    .modal-body-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .modal-media-content {
        flex: none;
        width: 100%;
    }
    
    #modal-title, #previewModalTitle {
        font-size: 2rem;
    }
    
    #modal-body, #previewModalBody {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: calc(100vw - 100px);
        padding: 15px;
    }
    
    .modal-nav {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .modal-nav-prev {
        left: calc((100vw - min(calc(100vw - 100px), 1200px)) / 4 - 20px);
    }
    
    .modal-nav-next {
        right: calc((100vw - min(calc(100vw - 100px), 1200px)) / 4 - 20px);
    }
}
