/* static/css/cart.css */

.cart-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Arial', sans-serif;
}

/* Хлебные крошки */
.breadcrumbs {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
    font-size: 14px;
    color: #666;
}

.breadcrumbs a {
    color: #007bff;
    text-decoration: none;
    transition: color 0.3s ease;
}

.breadcrumbs a:hover {
    color: #0056b3;
    text-decoration: underline;
}

.breadcrumbs .separator {
    margin: 0 10px;
    color: #999;
}

.breadcrumbs .current {
    color: #333;
    font-weight: 500;
}

/* Заголовок страницы */
.page-title {
    font-size: 28px;
    font-weight: 600;
    color: #333;
    margin-bottom: 30px;
    text-align: center;
}

/* Контент корзины */
.cart-content {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
    margin-top: 20px;
}

/* Заголовок корзины с действиями */
.cart-header {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.cart-actions .btn {
    padding: 8px 16px;
    font-size: 14px;
}

/* Список товаров в корзине */
.cart-items {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Элемент корзины */
.cart-item {
    display: grid;
    grid-template-columns: 150px 1fr 120px 120px 40px; /* Фиксированные колонки */
    gap: 15px;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.cart-item:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

/* Изображение товара */
.item-image {
    width: 150px;
    height: 150px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    flex-shrink: 0; /* Запрещаем уменьшение размера */
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Детали товара */
.item-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.item-name {
    margin: 0;
}

.item-name a {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.item-name a:hover {
    color: #007bff;
}

.item-category, .item-car, .item-article {
    font-size: 14px;
    color: #666;
}

.item-stock {
    font-size: 14px;
    font-weight: 500;
    margin-top: 5px;
}

.item-stock.in-stock {
    color: #28a745;
}

.item-stock.out-of-stock {
    color: #dc3545;
}

/* Количество товара */
.item-quantity {
    display: flex;
    justify-content: center;
    border: 1px solid #e9ecef;
}

.quantity-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100px; /* Фиксированная ширина для селектора количества */
}

.quantity-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 500;
    color: #333;
    transition: all 0.3s ease;
}

.quantity-btn:hover:not(:disabled) {
    background: #007bff;
    color: white;
}

.quantity-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quantity-input {
    width: 50px;
    height: 32px;
    text-align: center;
    border: none;
    font-size: 14px;
    font-weight: 500;
}

.quantity-input:focus {
    outline: none;
}

/* Убираем стрелки у всех числовых полей */
input[type="number"] {
    -moz-appearance: textfield;
    -webkit-appearance: none;
    appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Цена товара */
.item-price {
    min-width: 120px; /* Фиксированная минимальная ширина */
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.price-per-item {
    font-size: 14px;
    color: #666;
}

.total-price {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.price-per-item, .total-price {
    white-space: nowrap; /* Запрещаем перенос текста */
}

/* Действия с товаром */
.item-actions {
    display: flex;
    justify-content: center;
}

.remove-item-btn {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-item-btn:hover {
    background: #ffeaea;
    color: #c82333;
}

/* Сводка корзины */
.cart-summary {
    position: sticky;
    top: 20px;
    height: fit-content;
}

.summary-card {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}

.summary-title {
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
    text-align: center;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.summary-row.total {
    font-size: 18px;
    font-weight: 600;
    border-bottom: none;
    padding-top: 15px;
    color: #333;
}

.summary-actions {
    margin-top: 25px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Кнопки */
.btn {
    padding: 12px 20px;
    border: none;
    text-decoration: none;
    text-align: center;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    display: inline-block;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #0056b3;
    box-shadow: 0 4px 8px rgba(0,123,255,0.3);
}

.btn-primary:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-outline {
    background: transparent;
    color: #dc3545;
    border: 1px solid #dc3545;
}

.btn-outline:hover {
    background: #dc3545;
    color: white;
}

.summary-note {
    margin-top: 15px;
    font-size: 12px;
    color: #666;
    text-align: center;
    font-style: italic;
}

/* Пустая корзина */
.empty-cart {
    text-align: center;
    padding: 60px 20px;
    display: none;
}

.empty-cart-icon {
    color: #6c757d;
    margin-bottom: 20px;
}

.empty-cart h2 {
    font-size: 24px;
    color: #333;
    margin-bottom: 10px;
}

.empty-cart p {
    font-size: 16px;
    color: #666;
    margin-bottom: 30px;
}

/* Уведомления */
.error-notifications {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.error-notification {
    padding: 15px 20px;
    border-radius: 6px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
}

.error-notification.error {
    background: #dc3545;
    border-left: 4px solid #c82333;
}

.error-notification.success {
    background: #28a745;
    border-left: 4px solid #1e7e34;
}

.error-notification.warning {
    background: #ffc107;
    color: #212529;
    border-left: 4px solid #e0a800;
}

.error-notification.info {
    background: #17a2b8;
    border-left: 4px solid #138496;
}

.close-error {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    margin-left: 10px;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.close-error:hover {
    opacity: 1;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Адаптивность */
@media (max-width: 1024px) {
    .cart-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .cart-summary {
        position: static;
        order: -1;
    }
}

@media (max-width: 768px) {
    .cart-container {
        padding: 15px;
    }

    .cart-item {
        grid-template-columns: 80px 1fr;
        grid-template-rows: auto auto auto;
        gap: 15px;
        padding: 15px;
    }

    .item-quantity {
        grid-column: 1;
        grid-row: 2;
        justify-content: start;
    }

    .item-price {
        grid-column: 2;
        grid-row: 2;
        text-align: right;
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }

    .item-actions {
        grid-column: 2;
        grid-row: 3;
        justify-content: end;
    }

    .item-image {
        width: 60px;
        height: 60px;
    }

    .price-per-item {
        font-size: 12px;
    }

    .total-price {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .cart-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .cart-actions {
        display: flex;
        justify-content: center;
    }

    .summary-actions {
        gap: 8px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }
}

/* Стили для уведомления о регионе */
.region-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 16px;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
}

.notification-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.notification-icon {
    color: #f39c12;
    flex-shrink: 0;
}

.notification-text h4 {
    margin: 0 0 4px 0;
    color: #e67e22;
    font-size: 16px;
    font-weight: 600;
}

.notification-text p {
    margin: 0;
    color: #856404;
    font-size: 14px;
    line-height: 1.4;
}

.notification-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #856404;
    padding: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

.notification-close:hover {
    color: #e67e22;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .region-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* Мобильная адаптация для корзины */
@media (max-width: 768px) {
    .cart-container {
        padding: 10px;
    }

    .breadcrumbs {
        margin-bottom: 20px;
        font-size: 12px;
        flex-wrap: wrap;
    }

    .page-title {
        font-size: 22px;
        margin-bottom: 20px;
    }

    .cart-content {
        display: flex;
        flex-direction: column;
        gap: 15px;
        margin-top: 15px;
    }

    /* Переносим summary в конец */
    .cart-content {
        flex-direction: column;
    }

    .cart-summary {
        order: 2; /* Перемещаем в конец */
        margin-top: 20px;
    }

    .cart-items {
        order: 1; /* Товары остаются в начале */
    }

    .cart-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
        margin-bottom: 15px;
        padding-bottom: 10px;
    }

    .cart-actions {
        display: flex;
        justify-content: center;
    }

    .cart-actions .btn {
        padding: 10px 16px;
        font-size: 14px;
        width: 100%;
        max-width: 200px;
    }

    /* Адаптация элементов корзины */
    .cart-item {
        grid-template-columns: 80px 1fr;
        grid-template-rows: auto auto auto;
        gap: 12px;
        padding: 12px;
        position: relative;
    }

    .item-image {
        grid-column: 1;
        grid-row: 1 / span 3;
        width: 80px;
        height: 80px;
        align-self: start;
    }

    .item-details {
        grid-column: 2;
        grid-row: 1;
        gap: 4px;
    }

    .item-name a {
        font-size: 14px;
        line-height: 1.3;
    }

    .item-category, .item-car, .item-article {
        font-size: 12px;
    }

    .item-stock {
        font-size: 12px;
        margin-top: 3px;
    }

    .item-quantity {
        grid-column: 1;
        grid-row: 3;
        justify-content: start;
        border: none;
    }

    .quantity-selector {
        min-width: 90px;
    }

    .quantity-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .quantity-input {
        width: 40px;
        height: 28px;
        font-size: 13px;
    }

    .item-price {
        grid-column: 2;
        grid-row: 2;
        text-align: right;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        min-width: auto;
        justify-content: flex-end;
    }

    .price-per-item {
        font-size: 12px;
    }

    .total-price {
        font-size: 16px;
        font-weight: 600;
    }

    .item-actions {
        grid-column: 2;
        grid-row: 3;
        justify-content: end;
        position: absolute;
        bottom: 12px;
        right: 12px;
    }

    .remove-item-btn {
        padding: 6px;
    }

    .remove-item-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Адаптация сводки корзины */
    .cart-summary {
        position: static;
    }

    .summary-card {
        padding: 20px 15px;
    }

    .summary-title {
        font-size: 18px;
        margin-bottom: 15px;
    }

    .summary-row {
        padding: 10px 0;
        font-size: 14px;
    }

    .summary-row.total {
        font-size: 16px;
        padding-top: 12px;
    }

    .summary-actions {
        margin-top: 20px;
        gap: 10px;
        display: flex;
        flex-direction: column;
    }

    /* Фикс для кнопок в мобильной версии */
    .summary-actions .btn {
        padding: 12px 16px;
        font-size: 14px;
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }

    /* Специально для кнопки Continue shopping */
    .summary-actions .btn-secondary {
        order: 2; /* Перемещаем вниз */
        margin-top: 5px;
    }

    .summary-actions .btn-primary {
        order: 1; /* Checkout остается сверху */
    }

    .summary-note {
        font-size: 11px;
        margin-top: 12px;
    }

    /* Адаптация пустой корзины */
    .empty-cart {
        padding: 40px 15px;
    }

    .empty-cart-icon svg {
        width: 48px;
        height: 48px;
    }

    .empty-cart h2 {
        font-size: 20px;
    }

    .empty-cart p {
        font-size: 14px;
        margin-bottom: 25px;
    }

    /* Адаптация уведомлений */
    .error-notifications {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .error-notification {
        padding: 12px 15px;
        font-size: 14px;
    }

    .region-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        padding: 12px;
    }

    .notification-content {
        gap: 10px;
    }

    .notification-icon svg {
        width: 20px;
        height: 20px;
    }

    .notification-text h4 {
        font-size: 14px;
    }

    .notification-text p {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .cart-container {
        padding: 8px;
    }

    .cart-item {
        grid-template-columns: 70px 1fr;
        gap: 10px;
        padding: 10px;
    }

    .item-image {
        width: 70px;
        height: 70px;
    }

    .item-name a {
        font-size: 13px;
    }

    .item-category, .item-car, .item-article {
        font-size: 11px;
    }

    .quantity-selector {
        min-width: 80px;
    }

    .quantity-btn {
        width: 26px;
        height: 26px;
    }

    .quantity-input {
        width: 35px;
        height: 26px;
    }

    .price-per-item {
        font-size: 11px;
    }

    .total-price {
        font-size: 15px;
    }

    .summary-card {
        padding: 15px 12px;
    }

    .summary-title {
        font-size: 16px;
    }

    .summary-row {
        font-size: 13px;
        padding: 8px 0;
    }

    .summary-row.total {
        font-size: 15px;
    }

    .summary-actions .btn {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* Особые стили для очень маленьких экранов */
@media (max-width: 360px) {
    .cart-item {
        grid-template-columns: 60px 1fr;
    }

    .item-image {
        width: 60px;
        height: 60px;
    }

    .item-details {
        min-width: 0; /* Разрешаем сжатие */
    }

    .item-name a {
        font-size: 12px;
    }

    .quantity-selector {
        min-width: 70px;
    }

    .item-price {
        flex-direction: column;
        gap: 2px;
        align-items: flex-end;
    }

    .price-per-item {
        font-size: 10px;
    }

    .summary-actions .btn {
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* Горизонтальная ориентация на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
    .cart-content {
        display: flex;
        flex-direction: column;
    }

    .cart-summary {
        order: 2;
    }

    .cart-items {
        order: 1;
    }

    .cart-item {
        grid-template-columns: 80px 1fr 100px;
        grid-template-rows: auto auto;
    }

    .item-image {
        grid-row: 1 / span 2;
    }

    .item-details {
        grid-column: 2;
        grid-row: 1;
    }

    .item-quantity {
        grid-column: 2;
        grid-row: 2;
        justify-content: start;
    }

    .item-price {
        grid-column: 3;
        grid-row: 1;
        flex-direction: column;
        text-align: right;
        gap: 4px;
    }

    .item-actions {
        grid-column: 3;
        grid-row: 2;
        position: static;
        justify-content: center;
    }
}