/* ------------------------------------------------------------------
 *  Корзина: кнопка в шапке, выдвижная панель, уведомления
 * ------------------------------------------------------------------ */

/* ── кнопка в навигации ── */
.cart-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1.5px solid #2563eb;
    background: #2563eb;
    color: #fff;
    padding: 8px 18px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
}
.cart-btn:hover {
    background: #1d4ed8;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}
.cart-btn:active { transform: translateY(1px); }
.cart-count {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 12px;
    background: #fff;
    color: #2563eb;
    font-size: 0.8rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.cart-count.is-empty { opacity: 0.55; }

/* компактная кнопка корзины рядом с гамбургером (только на мобильных) */
.cart-btn-mobile { display: none; }
@media (max-width: 900px) {
    .cart-btn-mobile {
        display: inline-flex;
        margin-left: auto;
        margin-right: 6px;
        padding: 8px 14px;
    }
    .nav-links .cart-btn { display: none; }
}

/* ── подложка и панель ── */
body.cart-open { overflow: hidden; }

.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.28s ease;
    z-index: 200;
}
.cart-overlay.show { opacity: 1; }

.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100dvh;
    width: min(460px, 100%);
    background: #fff;
    z-index: 201;
    display: flex;
    flex-direction: column;
    box-shadow: -12px 0 40px rgba(15, 23, 42, 0.16);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.cart-drawer.open { transform: translateX(0); }
.cart-drawer[hidden] { display: none; }

.cart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid #eef2ff;
    flex-shrink: 0;
}
.cart-head h2 {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 10px;
}
.cart-head i { color: #2563eb; }
.cart-close {
    background: #f1f5f9;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    color: #334155;
    font-size: 1.05rem;
    transition: 0.2s;
    flex-shrink: 0;
}
.cart-close:hover { background: #e2e8f0; color: #0f172a; }

.cart-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 22px 28px;
    -webkit-overflow-scrolling: touch;
}

/* ── список позиций ── */
.cart-items { list-style: none; display: grid; gap: 14px; }
.cart-item {
    display: grid;
    grid-template-columns: 66px 1fr auto;
    gap: 12px;
    align-items: start;
    padding: 12px;
    border: 1px solid #eef2ff;
    border-radius: 18px;
    background: #fff;
}
.cart-item-img {
    width: 66px;
    height: 66px;
    object-fit: contain;
    border-radius: 12px;
    background: #f8fafc;
}
.cart-item-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #0f172a;
    margin-bottom: 2px;
}
.cart-item-price { font-size: 0.8rem; color: #64748b; margin-bottom: 8px; }

.cart-qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid #e2e8f0;
    border-radius: 40px;
    overflow: hidden;
}
.qty-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: #f8fafc;
    color: #1e293b;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    transition: 0.15s;
}
.qty-btn:hover { background: #e2e8f0; }
.qty-input {
    width: 40px;
    height: 30px;
    border: none;
    text-align: center;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    color: #0f172a;
    background: #fff;
    -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.cart-item-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    height: 100%;
}
.cart-item-del {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 2px;
    transition: color 0.2s;
}
.cart-item-del:hover { color: #dc2626; }
.cart-item-sum { font-weight: 800; font-size: 0.95rem; color: #0f172a; white-space: nowrap; }

/* ── пустая корзина ── */
.cart-empty { text-align: center; padding: 48px 10px; color: #475569; }
.cart-empty i { font-size: 2.4rem; color: #cbd5e1; margin-bottom: 16px; }
.cart-empty p { font-weight: 700; font-size: 1.1rem; color: #0f172a; margin-bottom: 6px; }
.cart-empty span { display: block; font-size: 0.9rem; max-width: 300px; margin: 0 auto 20px; }
.cart-empty-link { display: inline-flex; }

/* ── итоги и форма ── */
.cart-form { margin-top: 20px; }
.cart-summary {
    background: #f8fafc;
    border-radius: 18px;
    padding: 14px 16px;
    margin-bottom: 22px;
}
.cart-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.92rem;
    color: #475569;
    padding: 3px 0;
}
.cart-summary-row.cart-total {
    font-size: 1.05rem;
    color: #0f172a;
    border-top: 1px dashed #dbe3ef;
    margin-top: 6px;
    padding-top: 10px;
}
.cart-total b { font-size: 1.35rem; font-weight: 800; }
.cart-note { font-size: 0.78rem; color: #b45309; margin-top: 8px; line-height: 1.35; }

.cart-form-title { font-size: 1.05rem; font-weight: 800; color: #0f172a; margin-bottom: 14px; }
.cart-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
}
.cart-label span { color: #dc2626; }

.cart-form .form-group { margin-bottom: 14px; }
.cart-form input[type="text"],
.cart-form input[type="tel"],
.cart-form textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    font: inherit;
    font-size: 0.95rem;
    color: #0f172a;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.cart-form textarea { resize: vertical; }
.cart-form input:focus,
.cart-form textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.cart-form .phone-input-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
}
.cart-form .phone-input-wrapper:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.cart-form .phone-prefix {
    padding: 12px 4px 12px 14px;
    font-weight: 600;
    color: #334155;
}
.cart-form .phone-input-wrapper input {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0;
}

.cart-radio-group { display: grid; gap: 8px; }
.cart-radio { cursor: pointer; }
.cart-radio input { position: absolute; opacity: 0; pointer-events: none; }
.cart-radio span {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    font-size: 0.92rem;
    transition: 0.2s;
}
.cart-radio span i { color: #94a3b8; }
.cart-radio input:checked + span {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 600;
}
.cart-radio input:checked + span i { color: #2563eb; }
.cart-radio input:focus-visible + span { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18); }

.cart-form .file-upload-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #475569;
    transition: 0.2s;
}
.cart-form .file-upload-label:hover { border-color: #2563eb; color: #2563eb; }
.cart-form .file-upload-label.has-file {
    border-style: solid;
    border-color: #16a34a;
    color: #15803d;
    background: #f0fdf4;
}

.cart-submit {
    width: 100%;
    margin-top: 4px;
    padding: 14px 20px;
    border: none;
    border-radius: 40px;
    background: #2563eb;
    color: #fff;
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}
.cart-submit:hover:not(:disabled) {
    background: #1d4ed8;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.28);
}
.cart-submit:disabled { opacity: 0.75; cursor: default; }
.cart-submit.ok { background: #16a34a; }

.cart-msg { font-size: 0.85rem; margin-top: 10px; min-height: 18px; line-height: 1.4; }
.cart-msg.ok { color: #16a34a; }
.cart-msg.err { color: #dc2626; }
.cart-msg a { color: inherit; }
.cart-legal { font-size: 0.72rem; color: #94a3b8; margin-top: 12px; line-height: 1.45; }

/* ── всплывающее уведомление ── */
.cart-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translate(-50%, 20px);
    background: #0f172a;
    color: #fff;
    padding: 12px 20px;
    border-radius: 40px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 300;
    max-width: min(92vw, 460px);
    text-align: center;
}
.cart-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
    .cart-drawer { width: 100%; }
    .cart-head { padding: 14px 16px; }
    .cart-body { padding: 14px 16px 24px; }
    .cart-item { grid-template-columns: 56px 1fr auto; padding: 10px; }
    .cart-item-img { width: 56px; height: 56px; }
    .cart-toast { bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .cart-drawer, .cart-overlay, .cart-toast, .cart-btn { transition: none; }
}
