/* Flexbox Gallery Styles */
.gallery-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 0;
}

.gallery-header {
    background-color: #cccccc;
    padding: 15px;
    margin-bottom: 20px;
    margin-left: 6px;
    margin-right: 6px;
    text-align: left;
}

.gallery-header strong {
    text-decoration: underline;
}

.gallery-nav {
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.gallery-controls {
    text-align: center;
    margin-bottom: 15px;
}

.grid-toggle-btn {
    background-color: #ccc;
    color: white;
    border: none;
    padding: 6px 10px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.grid-toggle-btn:hover {
    background-color: #45a049;
}

.grid-toggle-btn:active {
    background-color: #3d8b40;
}

.gallery-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: flex-start;
    margin: 0 12px;
}

.gallery-item {
    cursor: pointer;
    transition: transform 0.2s ease;
}

/* Grid layout: 8 items per row */
.gallery-grid.grid-8 .gallery-item {
    flex: 0 0 calc(12.5% - 1px);
    /* flex: 1 1 calc(12% - 10px); */
    max-width: calc(12.5% - 1px);
}

/* Grid layout: 4 items per row */
.gallery-grid.grid-4 .gallery-item {
    flex: 0 0 calc(25% - 12px);
    max-width: calc(25% - 12px);
}

.gallery-item:hover {
    transform: scale(1.05);
}

.gallery-item img {
    width: 100%;
    /* height: 150px; */
    object-fit: cover;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #f9f9f9;
}

.gallery-empty {
    text-align: center;
    padding: 40px;
    width: 100%;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    overflow: auto;
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
    position: relative;
}

.modal-close {
    color: #aaa;
    float: left;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.modal-close:hover,
.modal-close:focus {
    color: #000;
}

.modal-image {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    margin: 20px 0;
}

.modal-info {
    padding: 10px;
    background: #f9f9f9;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.modal-info p {
    margin: 10px 0;
}

/* Modal Navigation Buttons */
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(255, 255, 255, 0.8);
    color: #333;
    border: none;
    font-size: 48px;
    font-weight: bold;
    cursor: pointer;
    padding: 20px 15px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    z-index: 1001;
    line-height: 1;
}

.modal-nav:hover {
    background-color: rgba(255, 255, 255, 0.95);
}

.modal-prev {
    left: 20px;
}

.modal-next {
    right: 20px
}

.modal-fullscreen-mode .modal-next {
    right: 76px;
}

/* Fullscreen Button */
.modal-fullscreen {
    position: absolute;
    top: 15px;
    right: 50px;
    background-color: rgba(255, 255, 255, 0.8);
    color: #333;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    z-index: 1002;
    line-height: 1;
}

.modal-fullscreen-mode .modal-fullscreen {
    right: 76px;
}

.modal-fullscreen-mode .modal-close {
    position: absolute;
    top: 20px;
    left: 20px
}

.modal-fullscreen:hover {
    background-color: rgba(255, 255, 255, 0.95);
}

.fullscreen-icon {
    display: inline-block;
}

/* Fullscreen Mode Styles (Maximized View) */
.modal-content.modal-fullscreen-mode {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    margin: 0;
    /* padding: 60px 80px 20px; */
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background-color: #000;
    position: fixed;
    top: 0;
    left: 0;
}

.modal-content.modal-fullscreen-mode .modal-image {
    width: 100%;
    height: calc(100vh - 200px);
    max-height: calc(100vh - 200px);
    object-fit: contain;
    margin: 0 auto;
}

.modal-content.modal-fullscreen-mode .modal-info {
    background-color: rgba(249, 249, 249, 0.95);
    margin-top: 20px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.modal-content.modal-fullscreen-mode .modal-close,
.modal-content.modal-fullscreen-mode .modal-fullscreen {
    background-color: rgba(255, 255, 255, 0.9);
}

/* Adjust navigation buttons in fullscreen */
.modal-content.modal-fullscreen-mode .modal-nav {
    background-color: rgba(255, 255, 255, 0.9);
}

.manufacturer-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

@media (max-width: 768px) {
    .modal-content.modal-fullscreen-mode {
        padding: 50px 20px 20px;
    }
    
    .modal-content.modal-fullscreen-mode .modal-image {
        height: calc(100vh - 180px);
        max-height: calc(100vh - 180px);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .gallery-grid.grid-8 .gallery-item {
        flex: 0 0 calc(25% - 12px); /* 4 items per row on tablets */
        max-width: calc(25% - 12px);
    }
    
    .gallery-grid.grid-4 .gallery-item {
        flex: 0 0 calc(50% - 8px); /* 2 items per row on tablets */
        max-width: calc(50% - 8px);
    }
}

@media (max-width: 768px) {
    .gallery-grid.grid-8 .gallery-item,
    .gallery-grid.grid-4 .gallery-item {
        flex: 0 0 calc(50% - 8px); /* 2 items per row on mobile */
        max-width: calc(50% - 8px);
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}
