/* Modern Minimalistic Cart Styles */

/* Base & Typography */
:root {
    --primary-color: #000000;
    --accent-color: #e74c3c;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --bg-page: #f9fafb;
    --bg-card: #ffffff;
    --border-color: #e5e7eb;
    --radius-sm: 8px;
    --radius-md: 12px;
    --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-page);
    font-family: var(--font-body);
    color: var(--text-primary);
    line-height: 1.5;
}

/* Layout */
.cart-container {
    max-width: 1440px;
    /* Increased from 1200px for 3-column space */
    margin: 120px auto 40px;
    padding: 0 24px;
}

/* Header */
.cart-header {
    margin-bottom: 32px;
    text-align: center;
    /* Centered visually pleasing header */
}

.cart-header h1 {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.025em;
}

.cart-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Content Grid */
.cart-content {
    display: grid;
    grid-template-columns: 1fr 340px 300px;
    gap: 20px;
    /* Reduced gap slightly */
    align-items: start;
    /* Fixed height for independent scrolling */
    height: calc(100vh - 120px);
    overflow: hidden;
    padding-bottom: 0;
}

/* Shared Scroll Settings (Hidden Scrollbars) */
.cart-items,
.cart-middle,
.cart-right {
    height: 100%;
    overflow-y: auto;
    padding-bottom: 20px;
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.cart-items::-webkit-scrollbar,
.cart-middle::-webkit-scrollbar,
.cart-right::-webkit-scrollbar {
    display: none;
}

/* Cart Items List */
.cart-items {
    background: transparent;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.cart-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 24px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.cart-item:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    border-color: #d1d5db;
}

.item-image {
    width: 140px;
    height: 140px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #fff;
    /* White background for transparent images */
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Ensure full image is visible */
    transition: transform 0.3s ease;
    padding: 4px;
}

.cart-item:hover .item-image img {
    transform: scale(1.05);
}

.item-details {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.item-details h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    line-height: 1.3;
}

/* Options Grid */
/* Options Grid - Refined for readability */
.item-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Increased gap for breathing room */
    margin: 16px 0 24px 0;
}

.option-item {
    font-size: 0.95rem;
    color: var(--text-secondary);
    display: grid;
    grid-template-columns: 175px 1fr;
    align-items: center;
    gap: 12px;
    padding-bottom: 8px;
    border-bottom: 1px dotted #e5e7eb;
}

.option-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.option-label {
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.option-value {
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.4;
}

.opt-price {
    font-size: 0.85em;
    color: #111827;
    /* Near black */
    font-weight: 600;
    /* Bolder */
    margin-left: 6px;
    background: #e5e7eb;
    /* Darker background */
    padding: 2px 8px;
    border-radius: 4px;
}

.discount-tag {
    color: #16a34a;
    /* Green */
    grid-column: 1 / -1;
    margin-top: 4px;
}

.success-text {
    color: #16a34a;
    font-weight: 700;
}

/* Footer of Card (Price + Remove) */
.item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    border-top: 1px solid #f3f4f6;
    padding-top: 16px;
}

.item-price {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.item-actions {
    display: flex;
    gap: 12px;
}

.edit-item {
    background: transparent;
    color: #6b7280;
    border: 1px solid #d1d5db;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
}

.edit-item:hover {
    color: var(--text-primary);
    border-color: #9ca3af;
    background: #f9fafb;
}

.remove-item {
    background: transparent;
    color: #ef4444;
    /* Red text */
    border: 1px solid #fee2e2;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
}

.remove-item:hover {
    color: #dc2626;
    background: #fee2e2;
    border-color: #fecaca;
}

/* Middle Column (Inputs) */
.cart-middle {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Right Column (Price Summary) */
.cart-right {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    /* Clean, faint shadow */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.summary-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f3f4f6;
}

/* Form Styles */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.required-badge {
    background: #fee2e2;
    color: #ef4444;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #f9fafb;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

/* Coupon */
.coupon-wrapper {
    display: flex;
    gap: 8px;
}

.btn-secondary {
    background: #f3f4f6;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

/* Coupon Messages */
.coupon-message {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

.coupon-message:empty {
    display: none;
}

.coupon-message.success {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.coupon-message.error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Price Breakdown */
.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.price-row .price-label {
    min-width: 0;
}

.price-row.total {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.25rem;
}

.price-row .val {
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.price-row.discount .val {
    color: #16a34a;
}

/* Checkout Button */
.checkout-btn {
    width: 100%;
    margin-top: 24px;
    padding: 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.checkout-btn:hover {
    background: #222;
    transform: translateY(-1px);
}

.checkout-btn:active {
    transform: translateY(1px);
}

.continue-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
}

.continue-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Empty Cart */
.empty-cart-state {
    text-align: center;
    padding: 80px 20px;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
}

.empty-icon {
    font-size: 48px;
    color: #d1d5db;
    margin-bottom: 24px;
}

/* Responsive */
@media (max-width: 1100px) {
    .cart-content {
        grid-template-columns: 1fr 350px;
        height: auto;
        /* Reset fixed height for tablets */
        overflow: visible;
        /* Restore page scrolling */
    }

    .cart-items,
    .cart-middle,
    .cart-right {
        height: auto;
        /* Reset container height */
        overflow-y: visible;
        /* No internal scroll */
        padding-bottom: 0;
    }

    .cart-items {
        grid-row: 1 / 3;
    }

    .cart-middle {
        grid-column: 2;
        grid-row: 1;
    }

    .cart-right {
        grid-column: 2;
        grid-row: 2;
        position: static;
    }
}

@media (max-width: 800px) {
    .cart-content {
        grid-template-columns: 1fr;
        height: auto;
        /* Reset fixed height */
        overflow: visible;
        /* Restore page scrolling */
    }

    .cart-items,
    .cart-middle,
    .cart-right {
        grid-column: 1;
        grid-row: auto;
        height: auto;
        /* Reset container height */
        overflow-y: visible;
        /* No internal scroll */
        padding-bottom: 0;
    }

    .cart-items {
        order: 1;
    }

    .cart-right {
        order: 2;
    }

    .cart-middle {
        order: 3;
    }
}

.cart-content:not(:has(.cart-middle)) {
    grid-template-columns: 1fr 340px;
}

@media (max-width: 1100px) {
    .cart-content:not(:has(.cart-middle)) {
        grid-template-columns: 1fr 350px;
    }

    .cart-content:not(:has(.cart-middle)) .cart-items,
    .cart-content:not(:has(.cart-middle)) .cart-right {
        grid-row: 1;
    }
}

@media (max-width: 800px) {
    .cart-content:not(:has(.cart-middle)) {
        grid-template-columns: 1fr;
    }

    .cart-content:not(:has(.cart-middle)) .cart-items,
    .cart-content:not(:has(.cart-middle)) .cart-right {
        grid-row: auto;
    }
}

@media (max-width: 600px) {
    .cart-container {
        padding: 16px 12px;
    }

    .cart-item {
        grid-template-columns: 1fr;
        padding: 16px;
        gap: 16px;
    }

    .item-image {
        width: 100%;
        height: 200px;
    }

    .option-item {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .option-label {
        white-space: normal;
    }

    .item-footer {
        flex-direction: column;
        gap: 14px;
        align-items: flex-start;
    }

    .item-price {
        font-size: 1.35rem;
        gap: 8px;
    }

    .item-actions {
        width: 100%;
    }

    .edit-item,
    .remove-item {
        flex: 1;
        justify-content: center;
    }

    .membership-upsell-banner {
        flex-direction: column;
        align-items: stretch !important;
        padding: 14px !important;
    }

    .membership-upsell-banner button {
        width: 100%;
        justify-content: center;
    }

    .summary-card {
        padding: 18px 16px;
    }
}