/* 购物车容器 */
.cart-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

/* 购物车头部 */
.cart-header {
    margin-bottom: 40px;
    text-align: center;
}

.cart-title {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 20px;
    color: #333;
    position: relative;
    display: inline-block;
}

.cart-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background-color: #007bff;
}

/* 购物车内容布局 */
.cart-content {
    display: flex;
    gap: 40px;
    align-items: flex-start;
}

.cart-items {
    flex: 1 1 0%;
    min-width: 0;
}

.cart-summary {
    flex: 0 0 340px;
    margin-left: auto;
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 25px;
    height: fit-content;
}

.cart-checkout-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.checkout-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkout-field label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.checkout-field input,
.checkout-field textarea {
    padding: 12px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.checkout-field input:focus,
.checkout-field textarea:focus {
    outline: none;
    border-color: #4c6ef5;
    box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.12);
}

.checkout-field textarea {
    resize: vertical;
    min-height: 90px;
}

.checkout-hint {
    margin: -4px 0 0;
    font-size: 12px;
    color: #666;
}

.contact-field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.contact-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid #d9d9d9;
    border-radius: 999px;
    background: #fff;
}

.contact-toggle-btn {
    border: none;
    background: transparent;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.contact-toggle-btn:hover {
    color: #333;
    background: rgba(76, 110, 245, 0.08);
}

.contact-toggle-btn.active {
    background: #4c6ef5;
    color: #fff;
    box-shadow: 0 3px 8px rgba(76, 110, 245, 0.25);
}

.contact-toggle-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.25);
}

.cart-notice {
    margin-bottom: 20px;
    padding: 14px 18px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid transparent;
}

.cart-notice-success {
    background: #f0f9f4;
    border-color: #b5dfc2;
    color: #1d7a46;
}

.cart-notice-error {
    background: #fff2f2;
    border-color: #f0b5b5;
    color: #b71c1c;
}

.cart-toast-backdrop {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.35);
    z-index: 1100;
}

.cart-toast-backdrop.is-active {
    display: flex;
}

.cart-toast {
    width: min(420px, 90%);
    padding: 30px;
    border-radius: 18px;
    text-align: center;
    color: #0f172a;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.cart-toast-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: rgba(67, 181, 103, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: #1f8a4c;
    border: 1px solid rgba(67, 181, 103, 0.35);
}

.cart-toast-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
}

.cart-toast-message {
    font-size: 15px;
    line-height: 1.6;
    color: #243046;
    margin-bottom: 24px;
}

.cart-toast-close {
    padding: 12px 32px;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, #4c6ef5, #4fb973);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(76, 110, 245, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cart-toast-close:hover,
.cart-toast-close:focus {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(76, 110, 245, 0.3);
    outline: none;
}

.cart-toast[data-state="error"] {
    background: rgba(255, 245, 245, 0.72);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #7f1d1d;
}

.cart-toast[data-state="error"] .cart-toast-title {
    color: #b91c1c;
}

.cart-toast[data-state="error"] .cart-toast-message {
    color: #7f1d1d;
}

.cart-toast[data-state="error"] .cart-toast-icon {
    background: rgba(248, 113, 113, 0.2);
    color: #b91c1c;
    border-color: rgba(248, 113, 113, 0.35);
}

.cart-toast[data-state="error"] .cart-toast-close {
    background: linear-gradient(135deg, #fb7185, #f43f5e);
    box-shadow: 0 8px 18px rgba(244, 63, 94, 0.32);
}

.cart-toast[data-state="error"] .cart-toast-close:hover,
.cart-toast[data-state="error"] .cart-toast-close:focus {
    box-shadow: 0 12px 26px rgba(244, 63, 94, 0.35);
}

body.cart-toast-open {
    overflow: hidden;
}

.summary-selection {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 15px 0 25px;
}

.select-all-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #333;
}

.select-all-input {
    width: 20px;
    height: 20px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    border: 2px solid #cbd5f5;
    border-radius: 50%;
    background: #fff;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    position: relative;
}

.select-all-input:checked {
    border-color: #4c6ef5;
    background: radial-gradient(circle at center, #4c6ef5 55%, #3451d3 100%);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

.select-all-input::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.15s ease;
}

.select-all-input:checked::after {
    transform: translate(-50%, -50%) scale(1);
}

.select-all-input:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.25);
}

.select-all-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.selected-count {
    font-size: 14px;
    color: #666;
}

.selected-count strong {
    color: #333;
    font-weight: 600;
}

/* 购物车商品项 */
.cart-item {
    display: grid;
    grid-template-columns: minmax(0, 52px) 100px minmax(0, 1fr) auto auto;
    column-gap: 20px;
    padding: 20px 0;
    border-bottom: 1px solid #eee;
    align-items: flex-start;
}

.item-select {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    justify-self: flex-start;
}

.item-select-input {
    width: 20px;
    height: 20px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    border: 2px solid #cbd5f5;
    border-radius: 50%;
    background: #fff;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    position: relative;
}

.item-select-input:checked {
    border-color: #4c6ef5;
    background: radial-gradient(circle at center, #4c6ef5 55%, #3451d3 100%);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

.item-select-input::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.15s ease;
}

.item-select-input:checked::after {
    transform: translate(-50%, -50%) scale(1);
}

.item-select-input:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.25);
}

.item-image {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.item-details {
    min-width: 0;
}

.item-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.item-description {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

.item-price {
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

.item-quantity {
    display: flex;
    align-items: center;
    justify-self: center;
    margin: 0;
}

.quantity-btn {
    width: 30px;
    height: 30px;
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-btn:hover {
    background: #e0e0e0;
}

.quantity-input {
    width: 50px;
    height: 30px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin: 0 10px;
}

.item-subtotal {
    min-width: 120px;
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-self: end;
}

.subtotal-amount {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.item-remove-btn {
    padding: 6px 14px;
    background: #f6f6f6;
    border: none;
    border-radius: 999px;
    font-size: 14px;
    color: #555;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.item-remove-btn:hover,
.item-remove-btn:focus {
    background: #ededed;
    color: #ff4d4f;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    outline: none;
}

/* 购物车摘要 */
.summary-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.summary-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 16px;
    color: #666;
}

.summary-row.total {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.checkout-btn {
    display: block;
    width: 100%;
    padding: 15px;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 15px;
    transition: background 0.3s ease;
}

.checkout-btn:hover {
    background: #0069d9;
}

.continue-shopping {
    display: block;
    text-align: center;
    color: #007bff;
    text-decoration: none;
    font-size: 14px;
}

.continue-shopping:hover {
    text-decoration: underline;
}

/* 空购物车状态 */
.empty-cart {
    text-align: center;
    padding: 60px 0;
}

.empty-icon {
    font-size: 80px;
    color: #e0e0e0;
    margin-bottom: 30px;
}

.empty-cart h3 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
}

.empty-cart p {
    font-size: 16px;
    color: #666;
    margin-bottom: 30px;
}

.shopping-btn {
    display: inline-block;
    padding: 12px 30px;
    background: #007bff;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: background 0.3s ease;
}

.shopping-btn:hover {
    background: #0069d9;
}

/* 响应式设计 */
@media (max-width: 992px) {
    .cart-content {
        flex-direction: column;
    }

    .cart-items {
        margin-bottom: 30px;
    }

    .cart-summary {
        width: 100%;
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .cart-item {
        display: flex;
        flex-wrap: wrap;
        row-gap: 10px;
    }

    .item-select {
        margin-right: 12px;
    }

    .item-image {
        margin-right: 15px;
    }

    .item-details {
        flex: 1 1 100%;
        margin-top: 10px;
    }

    .item-quantity {
        margin: 10px 20px 0 0;
        justify-self: flex-start;
    }

    .item-subtotal {
        margin-top: 10px;
        align-items: flex-start;
        text-align: left;
    }
}

@media (max-width: 480px) {
    .cart-title {
        font-size: 28px;
    }

    .item-image {
        width: 80px;
        height: 80px;
    }

    .contact-toggle {
        width: 100%;
        justify-content: space-between;
    }

    .contact-toggle-btn {
        flex: 1;
        text-align: center;
    }
}
