/* CART>[GRP: Cart Styles] */

/* Убираем синее подсвечивание при таче */
button,
a,
.nav-item,
.btn-qty,
.btn-remove,
.btn-checkout,
.btn-back,
.btn-clear {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

button:focus,
button:active,
a:focus,
a:active {
    outline: none;
}

/* ========== CSS Variables ========== */
:root {
    --accent: #8B5CF6;
    --accent-dark: #7C3AED;
    --orange: #FF8C42;
    --orange-dark: #FF6B35;
    --danger: #EF4444;
    --success: #10B981;
    --warning: #F59E0B;
    --bg: #F3F4F6;
    --card: #FFFFFF;
    --text: #111827;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.12);
}

/* ========== Reset & Base ========== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body {
    padding-bottom: 100px;
}

/* ========== Material Icons ========== */
.material-icons-round {
    font-family: 'Material Icons Round';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}

/* ========== Header ========== */
.cart-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.cart-header h1 {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
}

.btn-back,
.btn-clear {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 500;
}

.btn-clear-text {
    display: none;
}

.btn-back:hover,
.btn-clear:hover {
    background: #FEE2E2;
    color: var(--danger);
}

@media (min-width: 400px) {
    .btn-clear-text {
        display: inline;
    }
}

/* ========== Content ========== */
.cart-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px;
}

/* ========== Empty State ========== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-icon {
    font-size: 80px;
    color: var(--border);
    margin-bottom: 20px;
}

.empty-state h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--orange) 0%, var(--orange-dark) 100%);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 140, 66, 0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(255, 140, 66, 0.2);
}

/* ========== Cart List ========== */
.cart-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cart-item {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: 12px;
    padding: 16px;
    background: var(--card);
    border-radius: 16px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, opacity 0.2s;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* Photo */
.item-image {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-image .item-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.no-photo {
    color: var(--border);
    font-size: 32px;
}

/* Info */
.item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.item-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text);
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    /* -webkit-line-clamp: 2; */
    /* overflow: hidden; */
}

.item-badge {
    display: inline-flex;
    width: fit-content;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    margin-top: 2px;
}

.item-badge.unavailable {
    background: #FEE2E2;
    color: #DC2626;
}

.item-badge.changed {
    background: #FEF3C7;
    color: #D97706;
}

.item-price {
    display: flex;
    align-items: center;
    gap: 8px;
    /* margin-top: auto; */
}

.price-current {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.price-diff {
    font-size: 12px;
    font-weight: 600;
    color: var(--danger);
}

/* Controls */
.item-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.qty-control {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg);
    border-radius: 8px;
    padding: 4px;
}

.btn-qty {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--card);
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-qty:hover {
    background: var(--accent);
    color: #fff;
}

.btn-qty:active {
    transform: scale(0.95);
}

.qty-value {
    min-width: 24px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
}

.line-total {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-dark);
}

.btn-remove {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-remove:hover {
    background: #FEE2E2;
    color: var(--danger);
}

/* ========== Footer ========== */
.cart-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 12px 16px 20px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    z-index: 100;
}

.totals {
    max-width: 800px;
    margin: 0 auto 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
}

.total-row .warning {
    color: var(--danger);
    font-weight: 600;
}

.total-sum {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.total-sum .label {
    font-size: 16px;
    color: var(--text);
}

.total-sum .sum {
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
}

.btn-checkout {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--orange) 0%, var(--orange-dark) 100%);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 140, 66, 0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}

.btn-checkout:hover {
    box-shadow: 0 6px 20px rgba(255, 140, 66, 0.4);
}

.btn-checkout:active {
    transform: scale(0.98);
}

/* ========== Toast ========== */
.toast {
    position: fixed;
    left: 50%;
    top: 50px;
    bottom: auto;
    transform: translate(-50%, -20px);
    background: rgba(31, 31, 31, 0.95);
    color: #fff;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    z-index: 200;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast.error {
    background: rgba(220, 38, 38, 0.95);
}

/* ========== Bottom Navigation ========== */
.bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        border-top: 1px solid var(--border);
        padding: 8px 0 12px;
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }

    .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: var(--text-muted);
        font-size: 11px;
        gap: 2px;
        flex: 1;
        position: relative;
        transition: color 0.2s ease;
    }

    .nav-item .material-icons-round {
        font-size: 24px;
        transition: transform 0.2s ease;
    }

    .nav-item:hover .material-icons-round,
    .nav-item:active .material-icons-round {
        transform: scale(1.1);
    }

    .nav-item:hover,
    .nav-item.active {
        color: var(--accent);
    }

    .nav-label {
        font-size: 10px;
        font-weight: 500;
    }

    /* Cart badge */
    .nav-cart {
        position: relative;
    }

    .nav-badge {
        position: absolute;
        top: -2px;
        right: 50%;
        transform: translateX(12px);
        background: #FF2465;
        color: #fff;
        font-size: 10px;
        font-weight: 700;
        min-width: 16px;
        height: 16px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
    }

    .nav-badge:empty {
        display: none;
    }

    /* Layout adjustments */
    body {
        padding-bottom: 140px;
    }

    .cart-footer {
        bottom: 70px;
    }

    .toast {
        top: 50px;
        bottom: auto;
    }
}

/* ========== Responsive Desktop ========== */
@media (min-width: 768px) {
    body {
        padding-bottom: 100px;
    }

    .cart-header {
        padding: 16px 24px;
    }

    .cart-content {
        padding: 24px;
    }

    .cart-item {
        grid-template-columns: 100px 1fr auto;
        gap: 20px;
        padding: 20px;
    }

    .item-image {
        width: 100px;
        height: 100px;
    }

    .item-title {
        font-size: 16px;
    }

    .cart-footer {
        padding: 16px 24px 24px;
    }
}

/* CART>[SEC: Busy + Hidden + Bottom Nav] »»» */
/* Фикс: явные hidden-состояния, чтобы JS не плодил inline-style кашу */
.badge[hidden],
.item-badge[hidden],
.price-diff[hidden],
.qty-control[hidden],
.line-total[hidden],
.warning[hidden] {
    display: none !important;
}

/* Фикс: блокируем только конкретную карточку, а не весь экран */
.cart-item.busy {
    opacity: .68;
    pointer-events: none;
}

.cart-item.busy .btn-qty,
.cart-item.busy .btn-remove {
    pointer-events: none;
}

.btn-checkout:disabled {
    opacity: .55;
    cursor: not-allowed;
    box-shadow: none;
}

/* Нижняя навигация — такая же mental model как на карточке */
.bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    body {
        padding-bottom: 210px;
    }

    /* Фикс: footer checkout поднимаем над нижним меню */
    .cart-footer {
        bottom: 58px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .toast {
        top: 50px;
        bottom: auto;
    }

    .bottom-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        border-top: 1px solid var(--border);
        padding: 8px 0 calc(12px + env(safe-area-inset-bottom));
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }

    .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: var(--text-muted);
        font-size: 11px;
        gap: 2px;
        flex: 1;
        position: relative;
        transition: color .2s ease;
    }

    .nav-item .material-icons-round {
        font-size: 24px;
        transition: transform .2s ease;
    }

    .nav-item:hover .material-icons-round,
    .nav-item:active .material-icons-round {
        transform: scale(1.1);
    }

    .nav-item:hover,
    .nav-item.active {
        color: var(--accent);
    }

    .nav-label {
        font-size: 10px;
        font-weight: 500;
    }

    .nav-cart {
        position: relative;
    }

    .nav-badge {
        position: absolute;
        top: -2px;
        right: 50%;
        transform: translateX(12px);
        background: #FF2465;
        color: #fff;
        font-size: 10px;
        font-weight: 700;
        min-width: 16px;
        height: 16px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
        opacity: 0;
        transition: opacity .2s ease, transform .2s ease;
    }

    .nav-badge.show {
        opacity: 1;
        transform: translateX(12px) scale(1);
    }

    .nav-badge:empty,
    .nav-badge[data-count="0"],
    #nav-cart-badge:empty,
    #nav-cart-badge[data-count="0"] {
        opacity: 0 !important;
    }
}

.item-meta {
    grid-column: 1 / -1;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    word-break: break-word;
    /* margin-top: 4px;
    display: -webkit-box;
    overflow: hidden; */
}
