/* cart.css */

h4,
h3{
    font-family: 'Manrope', sans-serif;
    font-weight: 700;
}

/* ===== Переменные ===== */
:root {
    --bg-page: #fbf9f3;
    --bg-card: #ffffff;
    --bg-sidebar: #f4efe6;
    --text-dark: #4a3b32;
    --text-muted: #8c7a6e;
    --text-light: #a49485;
    --accent: #c39776;
    --accent-hover: #b58666;
    --border: #e0d6cc;
    --border-light: #e8dfd4;
    --danger: #d9534f;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
    --transition: 0.3s ease;
}

/* ===== Базовые стили ===== */
body {
    overflow-x: hidden;
}

.cart-section {
    padding: 40px 0 80px;
    background-color: var(--bg-page);
}

.cart-title {
    font-size: clamp(28px, 5vw, 36px);
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 40px;
    font-family: 'Inter', sans-serif;
}

.cart-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 40px;
    align-items: start;
}

/* ===== Список товаров ===== */
.cart-items {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cart-item-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

.cart-item-card:hover {
    box-shadow: var(--shadow-md);
}

.cart-item-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0; /* чтобы не переполнялся */
}

.cart-item-img {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: #f4efe6;
    flex-shrink: 0;
}

.cart-item-details {
    min-width: 0;
}

.cart-item-details h4 {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-dark);
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-details p {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

.cart-item-qty {
    width: 40px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 14px;
    background: transparent;
    color: var(--text-dark);
    /* Скрываем стрелки */
    -moz-appearance: textfield;
    appearance: textfield;
}
.cart-item-qty::-webkit-outer-spin-button,
.cart-item-qty::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.cart-item-qty:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.cart-item-price {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-dark);
    min-width: 60px;
    text-align: right;
    white-space: nowrap;
}

.cart-item-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: #c4b5a9;
    transition: color 0.2s;
    padding: 4px;
    flex-shrink: 0;
}

.cart-item-remove:hover {
    color: var(--danger);
}

.cart-item-remove:focus-visible {
    outline: 2px solid var(--danger);
    outline-offset: 2px;
}

.empty-cart-message {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
}

/* ===== Сайдбар заказа ===== */
.order-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.order-details,
.order-form-wrapper {
    background: var(--bg-sidebar);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.order-details h3,
.order-form-wrapper h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 16px 0;
}

.order-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 14px;
    color: var(--text-dark);
    border-bottom: 1px solid var(--border-light);
}

.order-summary-row:last-child {
    border-bottom: none;
}

.order-summary-row.total {
    font-weight: 600;
    font-size: 18px;
    padding-top: 16px;
    color: var(--accent);
}

/* --- Доставка --- */
.delivery-block {
    margin: 16px 0;
    padding-top: 12px;
    border-top: 1px solid #e5ddd0;
}

.delivery-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: #3a3128;
}

.delivery-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border: 1px solid #d9cfc2;
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

/* Для современных браузеров (Chrome, Safari, Firefox 121+) */
.delivery-option:has(input:checked) {
    border-color: #75a77b;
    background: #f5f9f6;
}

/* Фолбэк для браузеров без :has() – подсветка текста */
.delivery-option input:checked + .delivery-option__name {
    color: #2e6b3e;
    font-weight: 600;
}
.delivery-option input:checked ~ .delivery-option__fee {
    color: #2e6b3e;
    font-weight: 600;
}

.delivery-option:hover {
    border-color: var(--accent);
}

.delivery-option input[type="radio"] {
    margin-right: 8px;
    accent-color: var(--accent); /* для современных браузеров */
}

.delivery-option__name {
    flex: 1;
    font-size: 14px;
    color: var(--text-dark);
}

.delivery-option__fee {
    font-size: 13px;
    color: #6b5b4f;
    font-weight: 600;
}

/* ===== Форма ===== */
.form-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.form-group .required {
    color: var(--danger);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-card);
    color: var(--text-dark);
    outline: 1px solid transparent;
    transition: outline 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: 2px solid var(--accent);
}

.form-group textarea {
    resize: vertical;
}

.submit-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 30px;
    background: var(--accent);
    color: #ffffff;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
    margin-top: 8px;
}

.submit-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    background: #cccccc;
    cursor: not-allowed;
    transform: none;
}

.agreement-text {
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    margin-top: 12px;
}

/* ===== Сообщения формы ===== */
.form-messages {
    margin-top: 15px;
    padding: 10px;
    border-radius: 5px;
    font-weight: 500;
}
.form-messages.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.form-messages.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* ===== Дополнительные элементы ===== */
.cart-item-sku-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: #6b5b4f;
    background: #f2ece4;
    padding: 3px 8px;
    border-radius: 4px;
    margin: 4px 0;
}

.cart-item-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.cart-item-chip {
    font-size: 12px;
    color: #4a4038;
    background: #fff;
    border: 1px solid #d9cfc2;
    border-radius: 12px;
    padding: 3px 10px;
}

.cart-chip__label {
    color: var(--text-muted);
    font-weight: 600;
}

/* ===== Адаптивность ===== */
@media (max-width: 1200px) {
    .cart-layout {
        grid-template-columns: 1fr 340px;
        gap: 30px;
    }
}

@media (max-width: 991px) {
    .cart-layout {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    .order-sidebar {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .cart-section {
        padding: 30px 0 60px;
    }
    .cart-item-card {
        padding: 16px;
    }
    .cart-item-controls {
        gap: 12px;
    }
}

@media (max-width: 576px) {
    .cart-item-card {
        flex-wrap: wrap;
        gap: 12px;
    }
    .cart-item-info {
        width: 100%;
    }
    .cart-item-controls {
        width: 100%;
        justify-content: space-between;
    }
    .cart-item-qty {
        width: 50px;
        height: 36px;
    }
    .cart-item-price {
        font-size: 18px;
    }
    .order-details,
    .order-form-wrapper {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .cart-title {
        margin-bottom: 25px;
    }
    .cart-item-img {
        width: 52px;
        height: 52px;
    }
    .cart-item-details h4 {
        font-size: 14px;
    }
    .cart-item-details p {
        font-size: 12px;
    }
    .delivery-option {
        padding: 6px 8px;
        font-size: 13px;
    }
}

/* ===== Улучшения для устройств с вырезом ===== */
@supports (padding: max(0px)) {
    .cart-section,
    .container {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
}

/* ===== Уважение к настройкам уменьшенного движения ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== Доступность: фокус ===== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===== Предотвращение горизонтальной прокрутки ===== */
body {
    overflow-x: hidden;
}

/* ===== Кнопки количества в корзине ===== */
.cart-qty-selector {
    display: flex;
    align-items: center;
    background: var(--bg-sidebar);
    border-radius: 30px;
    padding: 4px;
    gap: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.cart-qty-btn {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.cart-qty-btn:hover {
    background: var(--accent);
    color: #fff;
}

.cart-qty-btn:active {
    transform: scale(0.95);
}

.qty-value {
    min-width: 30px;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    user-select: none;
}

/* Блок согласия */
.consent-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;          /* уменьшенный размер текста */
    line-height: 1.4;
    color: var(--text-dark);
    cursor: pointer;           /* курсор-указатель на всей метке (для удобства) */
}

.consent-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Ссылка на политику */
.privacy-link {
    color: #8c7a6e;            /* серый, близкий к text-muted */
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s ease;
    font-weight: 500;
}

.privacy-link:hover {
    color: var(--accent);      /* при наведении становится акцентным */
}
