.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none; 
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-content {
    background: #fff;
    width: 95%;
    max-width: 70vw; 
    height: 70vh;
    border-radius: 12px;
    padding: 40px;
    display: flex;
    gap: 50px;
    position: relative;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

@keyframes quickFade {
    0% { scale: 1.01; }
    100% { scale: 1; }
}

.fade-anim {
    animation: quickFade 0.3s ease-out;
}

.modal-content {
    background: #fff;
    width: 95%;
    max-width: 70vw; 
    height: 70vh;
    border-radius: 12px;
    padding: 40px;
    display: flex;
    gap: 50px;
    position: relative;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    
    overflow: hidden; 
}

.modal-clickable-tag {
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}
.modal-clickable-tag:hover {
    background-color: #e2e2e2;
    transform: scale(1.03);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 105;
    background: #fff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: large;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-close:hover {
    transform: scale(1.1) rotate(90deg);
    color: #B87B5C;
}

.modal-main-wrapper {
    flex: 1;
    background-color: #f9f9f9;
    border-radius: 8px;
    margin-bottom: 15px;
    overflow: hidden; 
    position: relative;
}

.modal-main-img {
    width: 100%;
    height: 100%;
    object-fit: cover; 
    cursor: zoom-in;
    transition: opacity 0.3s ease;
}

    .modal-main-img:hover {
        transform: scale(1.005);
    }

    .modal-main-img.zoomed {
        transform: scale(2);
        cursor: zoom-out;
    }

.modal-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.85);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    color: #333;
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 5px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

    .modal-arrow:hover {
        background: #B87B5C;
        color: #fff;
        transform: translateY(-50%) scale(1.1);
    }

.arrow-left { left: 15px; padding-right: 10px;}
.arrow-right { right: 15px; padding-left: 7px;}

.modal-thumbnails img {
    opacity: 0.7;
}

.modal-thumbnails img.active-thumb {
    border-color: #B87B5C;
    opacity: 1;
}

.modal-thumbnails img:hover {
    opacity: 1;
}


.modal-thumbnails {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    flex-shrink: 0;
    padding-bottom: 5px;
}

.modal-thumbnails img {
    width: 90px;
    height: 65px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s, opacity 0.2s;
}

.modal-thumbnails img:hover {
    border-color: #B87B5C;
    opacity: 0.9;
}

.modal-thumbnails::-webkit-scrollbar {
    height: 6px;
}
.modal-thumbnails::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}
.modal-thumbnails::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}
.modal-thumbnails::-webkit-scrollbar-thumb:hover {
    background: #B87B5C;
}


.modal-gallery {
    width: 50%;
    height: 100%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.modal-info {
    width: 50%;
    height: 100%; 
    display: flex;
    flex-direction: column;
    font-family: 'Montserrat', sans-serif;
    color: #2E2B28;
    box-sizing: border-box;
}

.modal-info-scrollable {
    flex: 1;
    overflow-y: auto;
    padding-right: 15px;
    margin-bottom: 20px;
}

.modal-info-scrollable::-webkit-scrollbar {
    width: 5px;
}
.modal-info-scrollable::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 10px;
}
.modal-info-scrollable::-webkit-scrollbar-thumb {
    background: #B87B5C;
    border-radius: 10px;
}

.modal-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: #2E2B28;
    letter-spacing: -0.5px;
    margin-top: 0;
    margin-bottom: 16px;
    line-height: 1.3;
}

.modal-desc {
    font-size: 0.95rem;
    line-height: 1.7;
    color: #5A5652;
    font-weight: 400;
    margin-bottom: 28px;
}

.modal-details-clean {
    border-top: 1px solid #EAE7E4;
    border-bottom: 1px solid #EAE7E4;
    padding: 20px 0;
    margin-bottom: 28px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 1rem;
}

.detail-row:last-child {
    margin-bottom: 0;
}

.detail-label {
    color: #8C8680;
    font-weight: 400;
}

.detail-value {
    color: #2E2B28;
    font-weight: 600;
}

.modal-tags-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 10px;
}

.modal-tag-group {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.tag-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #A6A09B;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    min-width: 105px; 
    padding-top: 6px;
}

.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.modal-tag {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
                background-color 0.25s ease, 
                color 0.25s ease, 
                box-shadow 0.25s ease,
                border-color 0.25s ease;
}

.modal-tag:hover {
    transform: translateY(-2px);
}

.tag-style {
    background-color: rgba(184, 123, 92, 0.08);
    color: #B87B5C;
    border: 1px solid rgba(184, 123, 92, 0.2);
}
.tag-style:hover {
    background-color: #B87B5C;
    color: #ffffff;
    border-color: #B87B5C;
    box-shadow: 0 4px 12px rgba(184, 123, 92, 0.25);
}

.tag-material {
    background-color: rgba(74, 101, 114, 0.07);
    color: #4A6572;
    border: 1px solid rgba(74, 101, 114, 0.18);
}
.tag-material:hover {
    background-color: #4A6572;
    color: #ffffff;
    border-color: #4A6572;
    box-shadow: 0 4px 12px rgba(74, 101, 114, 0.25);
}

.tag-misc {
    background-color: rgba(132, 165, 157, 0.1); 
    color: #5C7A73;
    border: 1px solid rgba(132, 165, 157, 0.25);
}

.tag-misc:hover {
    background-color: #5C7A73;
    color: #ffffff;
    border-color: #5C7A73;
    box-shadow: 0 4px 12px rgba(132, 165, 157, 0.25);
}


@media (max-width: 768px) {
    .modal-tag-group {
        flex-direction: column;
        gap: 6px;
    }
    
    .tag-label {
        min-width: auto;
        padding-top: 0;
        margin-bottom: 2px;
    }

    .modal-title {
        font-size: 1.4rem;
    }

    .modal-desc {
        font-size: 0.9rem;
    }
}

.modal-desc {
    font-size: 1.05rem;
    line-height: 1.7;
    color: #555;
    margin-bottom: 30px;
}

.modal-details-clean {
    border-top: 1px solid #eaeaea;
    border-bottom: 1px solid #eaeaea;
    padding: 20px 0;
}

.detail-row {
    display: flex;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.detail-row:last-child {
    margin-bottom: 0;
}

.detail-label {
    color: #777;
}

.detail-value {
    color: #1a1a1a;
    font-weight: 500;
}

.modal-actions {
    flex-shrink: 0; 
    background: #fff; /* Белый фон, чтобы под ними не просвечивал прокручиваемый текст */
    padding-top: 15px;
    border-top: 1px solid #EAE7E4; /* Элегантная линия-разделитель */
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.btn-primary, .btn-secondary {
    width: 100%;
    padding: 16px;
    font-size: 1.05rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    text-align: center;
}

.btn-primary {
    background-color: #B87B5C;
    color: #fff;
    border: none;
}
.btn-primary:hover {
    background-color: #9e694e;
}

.btn-secondary {
    background-color: transparent;
    color: #B87B5C;
    border: 2px solid #B87B5C;
}
.btn-secondary:hover {
    background-color: #B87B5C;
    color: #fff;
}

@media (max-width: 1300px) {
    .modal-content {
        flex-direction: column;
        height: 80vh;
        padding: 25px;
        width: 50%;
        gap: 20px;
    }
    .modal-gallery {
        flex: 0 0 45%;
    }

    .modal-content {
        max-width: 92vw;
        height: 85vh; /* Модалка занимает почти весь экран по высоте */
        flex-direction: column; /* Элементы ложатся друг под друга */
        gap: 20px;
        padding: 35px 20px 20px 20px;
        overflow: hidden; /* Кнопки будут зафиксированы и на мобилках! */
    }

    /* Галерея сверху */
    .modal-gallery {
        width: 100% !important; /* На весь экран */
        height: 220px; /* Фиксируем высоту картинок, чтобы они не съедали всё место */
        flex-shrink: 0;
    }

    /* Инфо-блок снизу */
    .modal-info {
        width: 100% !important; /* На весь экран, левая половина больше не сжимает */
        flex: 1;
        height: calc(100% - 240px); /* Высчитываем точное оставшееся место */
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .modal-info-scrollable {
        flex: 1;
        overflow-y: auto; /* Текст внутри инфо-блока скроллится на мобилке отдельно */
        padding-right: 5px;
    }

    .modal-title {
        font-size: 1.4rem;
        text-align: left;
        margin-top: 5px;
    }

    .modal-desc {
        font-size: 0.9rem;
        margin-bottom: 20px;
    }

    .modal-tag-group {
        flex-direction: column;
        gap: 6px;
    }
    
    .tag-label {
        min-width: auto;
        padding-top: 0;
    }

    /* Кнопка закрытия на мобилке поверх картинок */
    .modal-close {
        top: 15px;
        right: 15px;
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(4px);
        box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }
}

@media (max-width: 900px) {
    .modal-content {
        flex-direction: column;
        height: 80vh;
        padding: 25px;
        gap: 20px;
    }
    .modal-gallery {
        flex: 0 0 45%;
    }
}

@media (max-width: 768px) {
    .modal-content {
        flex-direction: column;
        display: block;
        width: 90%;
        max-width: 100%;
        height: auto;
        max-height: 90vh;
        overflow-y: auto;
        padding: 20px 15px;
        gap: 0;
    }

    .modal-gallery {
        display: block;
        flex: none;
        width: 100%;
        margin-bottom: 80px;
    }

    .modal-main-wrapper {
        height: 250px;
        margin-bottom: 10px;
    }

    .modal-thumbnails {
        display: flex;
        gap: 8px;
        justify-content: flex-start;
        padding-bottom: 10px;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .modal-thumbnails::-webkit-scrollbar {
        display: none; 
    }

    .modal-thumbnails img {
        width: 45px;  
        height: 35px; 
        border-radius: 4px;
        border-width: 1px;
        flex-shrink: 0;
        object-fit: cover;
    }

}

@media (max-width: 400px) {
    .modal-main-wrapper {
        height: 200px;
    }
    .modal-title {
        font-size: 1.3rem;
    }
}