/* ==========================================
   КОРЗИНА (Mobile First)
   ========================================== */

/* Базовые стили (мобильные) */
.cart-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
    padding: 0 12px;
}

.cart-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

/* На мобильных таблица — карточки */
.cart-table thead { display: none; }

.cart-table tbody tr {
    display: block;
    margin-bottom: 12px;
    padding: 12px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    position: relative;
}

.cart-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px dashed #f0f0f0;
    font-size: 13px;
}
.cart-table tbody td:last-child { border-bottom: none; }
.cart-table tbody td::before {
    content: attr(data-label);
    font-weight: 500;
    color: #777;
    margin-right: 8px;
    font-size: 12px;
}

/* Название товара (на мобильном — сверху, крупно) */
.cart-table .cart-name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
    margin-bottom: 8px;
}
.cart-table .cart-name::before { display: none; }

/* Крестик удаления (на мобильном — в правом верхнем углу карточки) */
.cart-table .btn-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,255,255,0.9);
    border: 1px solid #eee;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 18px;
    color: #c00;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.cart-table .btn-remove:hover { background: #ffeaea; }

/* Управление количеством (на мобильном — компактно) */
.qty-control {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 2px;
}
.qty-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.qty-btn:active { background: #e0e0e0; }
.packs-input, .area-input {
    border: none;
    background: transparent;
    font-size: 14px;
    text-align: center;
    padding: 4px 0;
    outline: none;
    font-weight: 500;
    color: #222;
    width: 50px;
}

/* Сумма строки */
.row-sum {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

/* Калькулятор (на мобильном — под таблицей) */
.cart-calc {
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 16px;
}
.cart-calc h3 {
    margin: 0 0 8px;
    font-size: 18px;
}
.cart-calc p {
    margin: 0 0 12px;
    font-size: 13px;
    color: #777;
}

/* Поля калькулятора */
.cart-calc select,
.cart-calc input[type="text"],
.cart-calc input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    margin-bottom: 8px;
    box-sizing: border-box;
}

/* Радиокнопки % (на мобильном — в строку) */
.cart-calc .calc-reserve-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.cart-calc .calc-reserve-row label {
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
}

/* Итоговая площадь и сумма */
.calc-summary {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 12px;
}
.calc-summary > div {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
}
.calc-summary > div:not(:last-child) { border-bottom: 1px dashed #f0f0f0; }
.calc-summary strong { color: #8b6f3d; font-size: 16px; }

/* Кнопка "Оформить заказ" (на мобильном — на всю ширину) */
.cart-actions {
    margin-top: 16px;
    text-align: center;
}
.cart-actions .btn-buy {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    background: #8b6f3d;
    color: #fff;
    border: none;
    cursor: pointer;
}

/* ==========================================
   ДЕСКТОП (от 900px)
   ========================================== */
@media (min-width: 900px) {
    .cart-layout {
        display: grid;
        grid-template-columns: 1fr 380px;
        gap: 32px;
        padding: 0;
        margin-top: 24px;
    }

    /* Таблица — как обычная таблица */
    .cart-table thead { display: table-header-group; }
    .cart-table tbody tr {
        display: table-row;
        margin: 0;
        padding: 0;
        background: none;
        border: none;
        border-radius: 0;
    }
    .cart-table tbody td {
        display: table-cell;
        padding: 12px 8px;
        border-bottom: 1px solid #f0f0f0;
        font-size: 14px;
    }
    .cart-table tbody td::before { display: none; }
    .cart-table .cart-name {
        display: table-cell;
        font-size: 14px;
        font-weight: 500;
        border-bottom: 1px solid #f0f0f0;
        padding: 12px 8px;
        margin: 0;
    }
    .cart-table .btn-remove {
        position: static;
        background: none;
        border: none;
        width: auto;
        height: auto;
        font-size: 18px;
        color: #c00;
        display: inline;
    }

    .cart-table th {
        text-align: left;
        padding: 12px 8px;
        color: #777;
        font-weight: 500;
        border-bottom: 2px solid #eee;
        white-space: nowrap;
    }
    .cart-table tfoot td {
        padding-top: 16px;
        font-size: 16px;
        border-bottom: none;
    }

    .cart-actions { text-align: right; }
    .cart-actions .btn-buy { width: auto; padding: 14px 32px; }
}