/* =========================================================
   ОСНОВНЫЕ НАСТРОЙКИ
   ========================================================= */

* {
    box-sizing: border-box;
}


html {
    width: 100%;
    min-height: 100%;
}


body {

    margin: 0;

    width: 100%;
    min-height: 100vh;

    background: #f5f5f5;

    color: #222;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;

    padding-bottom: calc(
        130px +
        var(
            --tg-content-safe-area-inset-bottom,
            env(safe-area-inset-bottom, 0px)
        )
    );

}


/* =========================================================
   ОСНОВНАЯ СТРАНИЦА
   ========================================================= */

.cart-page {

    width: 100%;

    max-width: 760px;

    margin: 0 auto;

    padding:
        max(
            16px,
            var(--tg-content-safe-area-inset-top, 0px)
        )
        12px
        calc(
            20px +
            var(
                --tg-content-safe-area-inset-bottom,
                env(safe-area-inset-bottom, 0px)
            )
        );

}



/* ЗАГОЛОВОК КОРЗИНЫ */
.cart-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 14px;
}

.cart-header h1 {
    margin: 0;
    color: #72383D !important;
    font-size: 24px;
    line-height: 1.2;
    font-weight: 700;
}

@media (max-width: 600px) {
    .cart-header h1 {
        font-size: 22px;
    }
}



/* =========================================================
   ПАНЕЛЬ УПРАВЛЕНИЯ
   ========================================================= */

.cart-toolbar {

    width: 100%;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 10px;

    padding: 12px;

    background: white;

    border-radius: 16px;

    margin-bottom: 12px;

    box-shadow:
        0 2px 8px
        rgba(0, 0, 0, 0.05);

}


/* =========================================================
   ВЫБРАТЬ ВСЕ
   ========================================================= */

.cart-select-all {

    display: flex;

    align-items: center;

    gap: 8px;

    min-width: 0;

}


.cart-select-all label {

    font-size: 15px;

    font-weight: 500;

    cursor: pointer;

    user-select: none;

}


#select-all {

    width: 20px;

    height: 20px;

    margin: 0;

    cursor: pointer;

    accent-color: #222;

}


/* =========================================================
   КНОПКИ ДЕЙСТВИЙ
   ========================================================= */

.cart-toolbar-actions {

    display: flex;

    align-items: center;

    gap: 8px;

}


.cart-action-button {

    height: 38px;

    padding:
        0
        14px;

    border: none;

    border-radius: 10px;

    background: #222;

    color: white;

    font-size: 14px;

    font-weight: 600;

    cursor: pointer;

    transition:
        background 0.2s ease,
        opacity 0.2s ease,
        transform 0.1s ease;

}


.cart-action-button:hover:not(:disabled) {

    background: #000;

}


.cart-action-button:active:not(:disabled) {

    transform: scale(0.97);

}


/* =========================================================
   DISABLED
   ========================================================= */

.cart-action-button:disabled {

    background: #e2e2e2;

    color: #999;

    cursor: default;

    opacity: 1;

}


/* =========================================================
   ПАНЕЛЬ ТОВАРОВ
   ========================================================= */

.cart-products-panel {

    width: 100%;

    background: white;

    border-radius: 18px;

    padding: 4px 0;

    box-shadow:
        0 2px 10px
        rgba(0, 0, 0, 0.05);

    overflow: hidden;

}


/* =========================================================
   КАРТОЧКА ТОВАРА
   ========================================================= */

.cart-item {

    position: relative;

    display: grid;

    grid-template-columns:
        28px
        92px
        minmax(0, 1fr);

    gap: 12px;

    align-items: center;

    min-height: 150px;

    padding:
        14px 14px;

    background: white;

    border-bottom:
        1px solid #ededed;

    transition:
        background-color 0.15s ease;

}


.cart-item:last-child {

    border-bottom: none;

}


.cart-item.selected {

    background: #f8f8f8;

}


/* =========================================================
   ЧЕКБОКС
   ========================================================= */

.cart-checkbox-wrapper {

    display: flex;

    align-items: center;

    justify-content: center;

}


.cart-checkbox {

    width: 21px;

    height: 21px;

    margin: 0;

    cursor: pointer;

    accent-color: #222;

}


/* =========================================================
   ФОТО
   ========================================================= */

.cart-item-image-wrapper {

    width: 92px;

    height: 122px;

    overflow: hidden;

    border-radius: 10px;

    background: #eeeeee;

    flex-shrink: 0;

}


.cart-item-image {

    display: block;

    width: 100%;

    height: 100%;

    object-fit: cover;

}


.cart-item-image.no-image {

    background: #eeeeee;

}


/* =========================================================
   ИНФОРМАЦИЯ
   ========================================================= */

.cart-item-info {

    min-width: 0;

    height: 122px;

    display: flex;

    flex-direction: column;

    align-items: flex-start;

}


.cart-item-brand {

    font-size: 12px;

    line-height: 1.2;

    color: #888;

    margin-bottom: 3px;

}


.cart-item-name {

    max-width: 100%;

    font-size: 16px;

    line-height: 1.25;

    font-weight: 600;

    color: #222;

    margin-bottom: 6px;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;

}


.cart-item-detail {

    font-size: 13px;

    line-height: 1.4;

    color: #777;

}


.cart-item-price {

    margin-top: 6px;

    font-size: 16px;

    line-height: 1.2;

    font-weight: 700;

    color: #222;

}


/* =========================================================
   КОЛИЧЕСТВО
   ========================================================= */

.cart-item-quantity {

    display: flex;

    align-items: center;

    gap: 0;

    margin-top: auto;

    height: 34px;

    border:
        1px solid #dddddd;

    border-radius: 9px;

    overflow: hidden;

}


.quantity-button {

    width: 34px;

    height: 32px;

    padding: 0;

    border: none;

    background: #f5f5f5;

    color: #222;

    font-size: 19px;

    line-height: 1;

    cursor: pointer;

    display: flex;

    align-items: center;

    justify-content: center;

    transition:
        background 0.15s ease;

}


.quantity-button:hover {

    background: #e9e9e9;

}


.quantity-button:active {

    background: #dedede;

}


.quantity-value {

    min-width: 34px;

    height: 32px;

    padding: 0 6px;

    display: flex;

    align-items: center;

    justify-content: center;

    font-size: 14px;

    font-weight: 600;

    background: white;

}


/* =========================================================
   ПУСТАЯ КОРЗИНА
   ========================================================= */

.empty-cart {

    min-height: 240px;

    padding: 30px 20px;

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    text-align: center;

}


.empty-cart-title {

    margin: 0 0 8px;

    font-size: 18px;

    font-weight: 600;

}


.empty-cart-text {

    margin: 0;

    font-size: 14px;

    color: #888;

}


/* =========================================================
   НИЖНЯЯ ПАНЕЛЬ СУММЫ
   ========================================================= */

.cart-summary {

    position: fixed;

    left: 0;

    right: 0;

    bottom: 60px;

    z-index: 9998;

    height: 62px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 16px;

    padding:
        8px 16px;

    background: white;

    border-top:
        1px solid #dedede;

    box-shadow:
        0 -3px 10px
        rgba(0, 0, 0, 0.05);

}


/* =========================================================
   ВЫБРАНО
   ========================================================= */

.cart-summary-count {

    display: flex;

    flex-direction: column;

    justify-content: center;

    min-width: 0;

}


.cart-summary-count-label {

    font-size: 12px;

    color: #888;

    line-height: 1.2;

}


.cart-summary-count-value {

    font-size: 15px;

    font-weight: 600;

    line-height: 1.3;

}


/* =========================================================
   СУММА
   ========================================================= */

.cart-summary-total {

    display: flex;

    align-items: center;

    gap: 8px;

    white-space: nowrap;

}


.cart-summary-total-label {

    font-size: 13px;

    color: #777;

}


#cart-total {

    font-size: 19px;

    font-weight: 700;

    color: #222;

}


/* =========================================================
   НИЖНЯЯ НАВИГАЦИЯ
   ========================================================= */

.bottom-navigation {

    position: fixed;

    left: 0;

    right: 0;

    bottom: 0;

    height: 60px;

    display: flex;

    align-items: center;

    justify-content: space-around;

    background: white;

    border-top:
        1px solid #ddd;

    z-index: 10000;

}


/* =========================================================
   КНОПКА НАВИГАЦИИ
   ========================================================= */

.bottom-nav-button {

    flex: 1;

    height: 100%;

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    gap: 3px;

    text-decoration: none;

    color: #777;

    font-size: 12px;

    cursor: pointer;

    transition:
        color 0.15s ease,
        background-color 0.15s ease;

}


.bottom-nav-button:hover {

    background: #f5f5f5;

    color: #222;

}


.bottom-nav-button:active {

    background: #eeeeee;

}


/* =========================================================
   АКТИВНАЯ КНОПКА
   ========================================================= */

.bottom-nav-button.active {

    color: #222;

    font-weight: 600;

}


/* =========================================================
   ИКОНКА НАВИГАЦИИ
   ========================================================= */

.bottom-nav-icon {

    font-size: 21px;

    line-height: 1;

}


.bottom-nav-label {

    font-size: 11px;

    line-height: 1;

}


/* =========================================================
   АДАПТИВНОСТЬ — ТЕЛЕФОН
   ========================================================= */

@media (
    max-width: 600px
) {

    .cart-page {

        padding:
            12px
            8px
            18px;

    }


    .cart-title {

        font-size: 22px;

    }


    .cart-toolbar {

        padding: 10px;

        border-radius: 14px;

    }


    .cart-toolbar-actions {

        gap: 6px;

    }


    .cart-action-button {

        height: 36px;

        padding:
            0 10px;

        font-size: 13px;

    }


    .cart-item {

        grid-template-columns:
            26px
            82px
            minmax(0, 1fr);

        gap: 9px;

        padding:
            12px 9px;

        min-height: 140px;

    }


    .cart-item-image-wrapper {

        width: 82px;

        height: 112px;

    }


    .cart-item-info {

        height: 112px;

    }


    .cart-item-name {

        font-size: 15px;

    }


    .cart-item-price {

        font-size: 15px;

    }


    .cart-summary {

        height: 60px;

        padding:
            7px 12px;

    }


    #cart-total {

        font-size: 17px;

    }

}


/* =========================================================
   ОЧЕНЬ МАЛЕНЬКИЕ ЭКРАНЫ
   ========================================================= */

@media (
    max-width: 380px
) {

    .cart-toolbar {

        align-items: stretch;

    }


    .cart-select-all {

        flex: 1;

    }


    .cart-toolbar-actions {

        flex-shrink: 0;

    }


    .cart-action-button {

        padding:
            0 8px;

        font-size: 12px;

    }


    .cart-item {

        grid-template-columns:
            24px
            74px
            minmax(0, 1fr);

        gap: 7px;

    }


    .cart-item-image-wrapper {

        width: 74px;

        height: 104px;

    }


    .cart-item-info {

        height: 104px;

    }


    .cart-item-detail {

        font-size: 12px;

    }


    .cart-item-price {

        margin-top: 4px;

        font-size: 14px;

    }


    .quantity-button {

        width: 30px;

    }


    .quantity-value {

        min-width: 28px;

    }

}


/* =========================================================
   КОРЗИНА — СТИЛЬ МАГАЗИНА
   ========================================================= */

:root {
    --cart-accent: #72383D;
    --cart-ink: #322D29;
}

/* Чекбоксы */
#select-all,
.cart-checkbox {
    accent-color: var(--cart-accent) !important;
}

/* Кнопки */
.toolbar-button {
    min-height: 38px;
    padding: 0 12px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .18s ease, transform .1s ease;
}

/* Создать заказ */
.order-button {
    background: var(--cart-accent) !important;
    color: var(--cart-ink) !important;
    border: 1px solid var(--cart-accent) !important;
}

/* Удалить — контурная кнопка */
.delete-button {
    background: #FFFFFF !important;
    color: var(--cart-accent) !important;
    border: 1px solid var(--cart-accent) !important;
}

/* Наведение на активные кнопки */
.order-button:hover:not(:disabled) {
    background: #5D2C31 !important;
}

.delete-button:hover:not(:disabled) {
    background: #F7F0F0 !important;
}

/* Неактивные кнопки */
.toolbar-button:disabled {
    background: #E5E5E5 !important;
    color: #999999 !important;
    border-color: #D5D5D5 !important;
    cursor: default;
}

/* Название, цвет, размер, цена */
.cart-item-brand,
.cart-item-name,
.cart-item-detail,
.cart-item-price {
    color: var(--cart-ink) !important;
}

/* Название не обрезается */
.cart-item-info {
    min-width: 0;
    height: auto !important;
    min-height: 112px;
    align-self: stretch;
}

.cart-item-name {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    overflow-wrap: anywhere;
    line-height: 1.3 !important;
}

/* Кнопки количества */
.quantity-button {
    color: var(--cart-accent) !important;
    background: #F0E5E5 !important;
}

/* Счётчик выбранных товаров */
.cart-summary-label,
.cart-summary-count {
    color: var(--cart-accent) !important;
}

.cart-summary-count {
    font-size: 15px;
    font-weight: 600;
}

/* Подпись суммы */
.cart-summary-total-label {
    color: #777777 !important;
}

/* Число суммы */
#cart-total {
    color: var(--cart-ink) !important;
}

/* Пустую корзину не изменяем */

/* Кнопки корзины */
.toolbar-button {
    min-height: 38px;
    padding: 0 12px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
}

/* Создать заказ — бордовый текст и обводка */
.order-button {
    background: #FFFFFF !important;
    color: #72383D !important;
    border: 1px solid #72383D !important;
}

/* Удалить — бордовый фон и белый текст */
.delete-button {
    background: #72383D !important;
    color: #FFFFFF !important;
    border: 1px solid #72383D !important;
}

/* Неактивные кнопки */
.toolbar-button:disabled {
    opacity: 0.55;
    cursor: default;
}