/**
 * modal.css — Стили модальных окон
 *
 * Грузится ГЛОБАЛЬНО.
 * Модалки: форма связи (#modal-contact) и корзина (#modal-cart).
 * Управление через data-modal="contact" / data-modal="cart".
 */


/* ===================================================
   1. MODAL BASE
   =================================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    visibility: hidden;
    padding: var(--gap-md);
}

.modal.is-open {
    pointer-events: auto;
    visibility: visible;
}


/* ===================================================
   2. OVERLAY
   =================================================== */

.modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity var(--transition-slow);
    cursor: pointer;
}

.modal.is-open .modal__overlay {
    opacity: 1;
}


/* ===================================================
   3. CONTAINER
   =================================================== */

.modal__container {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    background: var(--c-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow-y: auto;
    transform: scale(0.9) translateY(30px);
    opacity: 0;
    transition: all var(--transition-slow);
    z-index: 1;
}

.modal.is-open .modal__container {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Широкий контейнер (для корзины) */
.modal__container--wide {
    max-width: 700px;
}


/* ===================================================
   4. CLOSE BUTTON
   =================================================== */

.modal__close {
    position: absolute;
    top: var(--gap-md);
    right: var(--gap-md);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--c-gray);
    transition: all var(--transition);
    z-index: 2;
    cursor: pointer;
    background: none;
    border: none;
}

.modal__close:hover {
    background: var(--c-light);
    color: var(--c-dark);
}


/* ===================================================
   5. BODY
   =================================================== */

.modal__body {
    padding: var(--gap-xl) var(--gap-xl) var(--gap-xl);
}

.modal__title {
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    color: var(--c-dark);
    margin-bottom: var(--gap-lg);
    padding-right: 40px; /* Место для кнопки закрытия */
}


/* ===================================================
   6. CART ITEMS (внутри модалки корзины)
   =================================================== */

.cart-items {
    display: flex;
    flex-direction: column;
    gap: var(--gap-md);
    margin-bottom: var(--gap-lg);
}

/* Одна строка товара в корзине */
.cart-item {
    display: flex;
    align-items: center;
    gap: var(--gap-md);
    padding: var(--gap-md);
    background: var(--c-light-warm);
    border-radius: var(--radius-md);
    position: relative;
}

.cart-item__image {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--c-white);
    border: 1px solid var(--c-border);
}

.cart-item__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item__image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--c-gray-light);
}

.cart-item__info {
    flex: 1;
    min-width: 0;
}

.cart-item__title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    color: var(--c-dark);
    margin-bottom: 2px;
    /* Обрезка длинного названия */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-item__title a {
    color: var(--c-dark);
    transition: color var(--transition);
}

.cart-item__title a:hover {
    color: var(--c-primary-dark);
}

.cart-item__category {
    font-size: 11px;
    color: var(--c-gray-light);
}

.cart-item__price {
    font-size: var(--fs-sm);
    color: var(--c-dark);
    margin-top: 4px;
}

.cart-item__price .price-from {
    font-size: 11px;
    color: var(--c-gray);
}

/* Удалить из корзины */
.cart-item__remove {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--c-gray-light);
    transition: all var(--transition);
    cursor: pointer;
    background: none;
    border: none;
}

.cart-item__remove:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--c-danger);
}


/* ===================================================
   7. CART EMPTY
   =================================================== */

.cart-empty {
    text-align: center;
    padding: var(--gap-2xl) 0;
}

.cart-empty__icon {
    margin-bottom: var(--gap-md);
}

.cart-empty__text {
    font-size: var(--fs-base);
    color: var(--c-gray);
    margin-bottom: var(--gap-lg);
}


/* ===================================================
   8. CART FORM
   =================================================== */

.cart-form__heading {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    color: var(--c-dark);
    margin-bottom: var(--gap-md);
}

.cart-count-label {
    font-size: var(--fs-sm);
    font-weight: var(--fw-normal);
    color: var(--c-gray);
}