/* Стили для корзины */

/* Кнопка корзины в header */
.cart-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    background: var(--primary-color, #2c3e50);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.3s;
}

.cart-button:hover {
    background: var(--primary-hover, #34495e);
}

.cart-badge {
    display: none;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    line-height: 20px;
    position: absolute;
    top: -5px;
    right: -5px;
}

/* Кнопка "В корзину" на странице товара */
.add-to-cart-btn {
    padding: 12px 30px;
    background: var(--primary-color, #2c3e50);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    max-width: 300px;
}

.add-to-cart-btn:hover {
    background: var(--primary-hover, #34495e);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.add-to-cart-btn:active {
    transform: translateY(0);
}

/* Модальное окно корзины */
.cart-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
}

.cart-modal-content {
    background: white;
    margin: 50px auto;
    padding: 30px;
    border-radius: 8px;
    max-width: 800px;
    width: 90%;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.cart-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 32px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    z-index: 10;
}

.cart-modal-close:hover {
    color: #000;
    background: rgba(0, 0, 0, 0.05);
}

/* Список товаров в корзине */
.cart-items {
    margin: 20px 0;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border-bottom: 1px solid #eee;
    position: relative;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    background: #f5f5f5;
    display: block;
    flex-shrink: 0;
    /* Предотвращаем мигание при загрузке */
    opacity: 1;
    transition: opacity 0.2s;
}

.cart-item-image[src=""],
.cart-item-image:not([src]) {
    opacity: 0;
}

.cart-item-image.loading {
    opacity: 0.5;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
    margin-bottom: 5px;
}

.cart-item-volume {
    color: #666;
    font-size: 14px;
}

.cart-item-price {
    font-weight: 600;
    color: var(--primary-color, #2c3e50);
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quantity-btn {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.quantity-btn:hover {
    background: #f5f5f5;
    border-color: var(--primary-color, #2c3e50);
}

.quantity-btn:active {
    transform: scale(0.95);
}

.quantity-input {
    width: 60px;
    min-height: 44px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    font-size: 16px;
    font-weight: 600;
}

.cart-item-remove {
    color: #e74c3c;
    cursor: pointer;
    font-size: 28px;
    font-weight: bold;
    padding: 10px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    background: rgba(231, 76, 60, 0.1);
}

.cart-item-remove:hover {
    color: #c0392b;
    background: rgba(231, 76, 60, 0.2);
    transform: scale(1.1);
}

.cart-item-remove:active {
    transform: scale(0.95);
}

/* Итого */
.cart-total {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #eee;
    text-align: right;
}

.cart-total-sum {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color, #2c3e50);
}

/* Форма заказа */
.order-form {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #eee;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color, #2c3e50);
}

.form-group input.invalid {
    border-color: #e74c3c;
}

.form-group input.valid {
    border-color: #27ae60;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 20px;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin-top: 3px;
}

.checkbox-group label {
    font-weight: normal;
    font-size: 14px;
    line-height: 1.5;
}

.submit-order-btn {
    width: 100%;
    padding: 15px;
    background: var(--primary-color, #2c3e50);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    margin-top: 20px;
}

.submit-order-btn:hover:not(:disabled) {
    background: var(--primary-hover, #34495e);
}

.submit-order-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Анимации */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .cart-modal-content {
        margin: 10px auto;
        padding: 15px;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        min-height: 100vh;
        box-sizing: border-box;
    }
    
    .cart-modal-close {
        top: 10px;
        right: 15px;
        font-size: 32px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .cart-item {
        flex-wrap: wrap;
        padding: 12px;
        gap: 12px;
        position: relative;
        padding-right: 50px; /* Место для кнопки удаления */
    }
    
    .cart-item-image {
        width: 70px;
        height: 70px;
        flex-shrink: 0;
    }
    
    .cart-item-info {
        flex: 1;
        min-width: 0; /* Позволяет тексту переноситься */
    }
    
    .cart-item-name {
        font-size: 15px;
        line-height: 1.4;
    }
    
    .cart-item-volume {
        font-size: 13px;
        margin-top: 4px;
    }
    
    .cart-item-price {
        font-size: 16px;
        margin-top: 6px;
    }
    
    .cart-item-quantity {
        width: 100%;
        justify-content: flex-start;
        margin-top: 8px;
        gap: 8px;
    }
    
    .quantity-btn {
        min-width: 48px;
        min-height: 48px;
        width: 48px;
        height: 48px;
        font-size: 22px;
    }
    
    .quantity-input {
        width: 70px;
        min-height: 48px;
        font-size: 18px;
        padding: 10px;
    }
    
    .cart-item-remove {
        position: absolute;
        top: 12px;
        right: 12px;
        min-width: 44px;
        min-height: 44px;
        font-size: 32px;
        padding: 8px;
    }
    
    .cart-total {
        text-align: left;
        margin-top: 15px;
        padding-top: 15px;
    }
    
    .cart-total-sum {
        font-size: 22px;
    }
    
    .form-group input,
    .form-group textarea {
        font-size: 16px; /* Предотвращает зум на iOS */
        padding: 12px;
    }
    
    .submit-order-btn {
        padding: 18px;
        font-size: 18px;
        min-height: 50px;
    }
    
    .checkbox-group {
        gap: 12px;
    }
    
    .checkbox-group input[type="checkbox"] {
        min-width: 20px;
        min-height: 20px;
        margin-top: 2px;
    }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
    .cart-modal-content {
        padding: 12px;
    }
    
    .cart-item {
        padding: 10px;
        padding-right: 45px;
    }
    
    .cart-item-image {
        width: 60px;
        height: 60px;
    }
    
    .cart-item-name {
        font-size: 14px;
    }
    
    .quantity-btn {
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
    }
    
    .quantity-input {
        width: 60px;
        min-height: 44px;
    }
}

/* Улучшения для сенсорных устройств */
@media (hover: none) and (pointer: coarse) {
    /* Для устройств с сенсорным экраном */
    .cart-item-remove:active,
    .quantity-btn:active,
    .cart-modal-close:active {
        transform: scale(0.9);
        opacity: 0.8;
    }
    
    .cart-item-remove,
    .quantity-btn,
    .cart-modal-close {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
}

/* Улучшенная видимость для всех устройств */
.cart-item-remove {
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.quantity-btn {
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

