@import url('styles.css');

/* Общие стили для таблицы корзины */
.cart-table {
    width: 90%;
    max-width: 800px;
    margin: 20px auto;
    border-collapse: collapse; /* Убираем зазоры между ячейками */
}

.cart-table th, .cart-table td {
    border: 1px solid #ddd;
    text-align: center;
    vertical-align: middle;
    padding: 5px; /* Уменьшенный отступ для равномерности */
}

.cart-table th {
    background-color: #f4f4f4;
    font-weight: bold;
}

/* Ширина столбцов */
.cart-table th:nth-child(1), .cart-table td:nth-child(1) { width: 10%; }
.cart-table th:nth-child(2), .cart-table td:nth-child(2) { width: 30%; }
.cart-table th:nth-child(3), .cart-table td:nth-child(3) { width: 15%; }
.cart-table th:nth-child(4), .cart-table td:nth-child(4) { width: 15%; }
.cart-table th:nth-child(5), .cart-table td:nth-child(5) { width: 15%; }
.cart-table th:nth-child(6), .cart-table td:nth-child(6) { width: 15%; }

/* Высота и выравнивание ячеек */
.cart-table td {
    height: 60px; /* Универсальная высота */
    padding: 0; /* Убираем лишние отступы */
    vertical-align: middle; /* Центрирование по вертикали */
    box-sizing: border-box; /* Учитываем границы и отступы */
}

/* Управление количеством */
.quantity-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px; /* Расстояние между кнопками */
    height: 100%; /* Растяжение на всю высоту ячейки */
}

.quantity-controls .quantity-button {
    width: 30px;
    height: 30px;
    font-size: 16px;
    color: white;
    background-color: #dc3545;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.quantity-controls .quantity-button:hover {
    background-color: #c82333;
}

.quantity-controls input[type="number"] {
    width: 50px;
    height: 30px;
    font-size: 16px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
}

/* Кнопка отправить заказ */
#send-order-button {
    background-color: #28a745;
    color: white;
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#send-order-button:hover {
    background-color: #218838;
}

/* Кнопка очистить корзину */
#clear-cart-button {
    background-color: #dc3545;
    color: white;
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#clear-cart-button:hover {
    background-color: #c82333;
}

/* Адаптация для мобильных устройств */
@media (max-width: 768px) {
    .cart-table {
        width: 100%; /* Растягиваем таблицу на всю ширину */
        display: block;
    }

    .cart-table thead {
        display: none; /* Убираем заголовки */
    }

    .cart-table tbody {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .cart-table tr {
        display: flex;
        flex-direction: column;
        padding: 10px;
        border: 1px solid #ddd;
        background-color: #f9f9f9;
        border-radius: 8px;
    }

    .cart-table td {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
    }

    .cart-table td::before {
        content: attr(data-label);
        font-weight: bold;
        color: #333;
        margin-right: 10px;
    }

    /* Центрирование итоговой суммы */
    .cart-total {
        text-align: center;
        margin-top: 15px;
    }
}

/* Мобильная версия корзины */
@media (max-width: 768px) {
    .cart-table {
        display: none; /* Скрываем десктопную таблицу на мобильных */
    }

    .mobile-cart {
        display: block;
        width: 100%;
        margin: 20px auto;
        background-color: #f9f9f9;
        border-radius: 10px;
        padding: 10px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .mobile-cart-item {
        display: flex;
        flex-direction: column;
        margin-bottom: 15px;
        border: 1px solid #ddd;
        padding: 10px;
        border-radius: 8px;
        background-color: #fff;
    }

    .mobile-cart-item img {
        max-width: 100px;
        height: auto;
        margin: 0 auto 10px;
    }

    .mobile-cart-item .item-details {
        text-align: center;
    }

    .mobile-cart-item .item-controls {
        display: flex;
        justify-content: space-between; /* Кнопки + и - располагаются по краям */
        align-items: center;
        margin-top: 10px;
        gap: 5px; /* Расстояние между кнопками и числом */
    }

   .mobile-cart-item .item-controls button {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

.mobile-cart-item .item-controls button:hover {
    background-color: #c82333;
}
}

.mobile-cart-item .item-controls input[type="number"] {
    text-align: center; /* Центрируем число */
    width: 50px; /* Ширина поля */
    height: 40px; /* Высота поля */
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    margin: 0 10px; /* Расстояние между кнопками и числом */
    box-sizing: border-box;
}
