/* ==========================================
   Cart Page – Professional Design
   ========================================== */

/* ===== PAGE WRAPPER ===== */
.cart-page-wrapper {
    padding: 2rem 0 3rem;
    min-height: 60vh;
}

/* ===== PAGE HEADER ===== */
.cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-bottom: 1.8rem;
}

.cart-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cart-title {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--primary-deep);
    margin: 0;
}

.cart-title-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.cart-item-count {
    background: var(--primary-tint);
    color: var(--primary-deep);
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
}

.cart-continue-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: gap 0.2s ease;
}
.cart-continue-link:hover {
    gap: 0.7rem;
    color: var(--primary-deep);
}

/* ===== EMPTY STATE ===== */
.cart-empty {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 5rem 2rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.cart-empty-icon {
    width: 90px;
    height: 90px;
    background: var(--primary-tint);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2.4rem;
    color: var(--primary-color);
}

.cart-empty h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-deep);
    margin-bottom: 0.6rem;
}

.cart-empty p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.7;
}

/* ===== MAIN GRID ===== */
.cart-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 1.5rem;
    align-items: start;
}

/* ===== CART ITEMS CARD ===== */
.cart-items-card {
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* Table Header Row */
.cart-table-head {
    display: grid;
    grid-template-columns: 2.5fr 1fr 1.2fr 1fr 40px;
    align-items: center;
    padding: 0.85rem 1.5rem;
    background: var(--primary-subtle);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.col-price, .col-qty, .col-subtotal {
    text-align: center;
}

.col-remove {
    text-align: right;
}

/* Cart Items List */
.cart-items-list {
    display: flex;
    flex-direction: column;
}

/* Single Cart Item */
.cart-item {
    display: grid;
    grid-template-columns: 2.5fr 1fr 1.2fr 1fr 40px;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease, opacity 0.3s ease, transform 0.3s ease;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item:hover {
    background: var(--bg-alt);
}

/* Product Column */
.col-product {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.cart-item-media {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    background: var(--primary-subtle);
    border: 1px solid var(--border-color);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cart-item-emoji {
    font-size: 2rem;
    line-height: 1;
}

.cart-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.cart-item-name {
    font-weight: 700;
    font-size: 0.97rem;
    color: var(--primary-deep);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s;
}

.cart-item-name:hover {
    color: var(--primary-color);
}

.cart-item-unit-price {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Price label (mobile only) */
.cart-price-label {
    display: none;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.3rem;
}

/* Price */
.col-price {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cart-item-price {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* Quantity */
.col-qty {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.qty-control {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg-alt);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.2rem 0.5rem;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-deep);
    font-size: 0.7rem;
    transition: background 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.qty-btn:hover {
    background: var(--primary-color);
    color: #fff;
}

.qty-value {
    font-weight: 700;
    font-size: 0.95rem;
    min-width: 22px;
    text-align: center;
    color: var(--primary-deep);
}

/* Subtotal */
.col-subtotal {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cart-item-subtotal {
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary-color);
}

/* Remove */
.col-remove {
    display: flex;
    justify-content: flex-end;
}

.cart-remove-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.cart-remove-btn:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

/* Cart Actions Row */
.cart-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-alt);
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-ghost {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-secondary);
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.btn-ghost:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

/* ===== RIGHT SIDEBAR ===== */
.cart-right {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    position: sticky;
    top: 100px;
}

/* ===== COUPON CARD ===== */
.cart-coupon-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid rgba(46, 125, 50, 0.14);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
    padding: 1.35rem 1.5rem;
    transition: box-shadow 0.25s ease;
}

.cart-coupon-card:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.07);
}

.coupon-card-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary-deep);
    margin-bottom: 1.1rem;
}

.coupon-card-header i {
    color: var(--primary-color);
    font-size: 1.1rem;
}

.coupon-available-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 0.6rem;
}

.coupon-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.6rem;
}

.coupon-chip {
    background: #f1f8f3;
    color: var(--primary-deep);
    border: 1.5px dashed var(--primary-color);
    border-radius: 24px;
    padding: 0.35rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.coupon-chip i {
    font-size: 0.78rem;
    color: var(--primary-color);
}

.coupon-chip:hover {
    background: var(--primary-color);
    color: #ffffff;
    border-style: solid;
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.25);
}

.coupon-chip:hover i {
    color: #ffffff;
}

.coupon-input-row {
    display: flex;
    gap: 0.6rem;
}

.coupon-input {
    flex: 1;
    padding: 0.7rem 1.1rem;
    border: 1.5px solid rgba(46, 125, 50, 0.2);
    border-radius: 12px;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-deep);
    background: #fafdfa;
    outline: none;
    transition: all 0.2s ease;
}

.coupon-input:focus {
    border-color: var(--primary-color);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.12);
}

.coupon-apply-btn {
    padding: 0.7rem 1.35rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-deep) 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.2);
}

.coupon-apply-btn:hover {
    box-shadow: 0 6px 16px rgba(46, 125, 50, 0.3);
}

.coupon-msg {
    font-size: 0.82rem;
    margin-top: 0.5rem;
    min-height: 1.2em;
    font-weight: 600;
}

.coupon-msg.success { color: var(--success-color); }
.coupon-msg.error   { color: var(--accent-color); }

/* Applied Coupon */
.coupon-applied {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    background: #edf7ed;
    border: 1.5px solid var(--success-color);
    border-radius: 12px;
    padding: 0.85rem 1.1rem;
}

.coupon-applied-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.9rem;
    color: var(--primary-deep);
}

.coupon-applied-info i {
    color: var(--success-color);
    font-size: 1.2rem;
}

.coupon-applied-info strong {
    font-size: 0.95rem;
    letter-spacing: 0.04em;
}

.coupon-save-text {
    font-size: 0.78rem;
    color: var(--success-color);
    font-weight: 700;
}

.coupon-remove-btn {
    font-size: 0.78rem;
    color: #d32f2f;
    background: #fff;
    border: 1px solid #ffcdd2;
    border-radius: 20px;
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.coupon-remove-btn:hover {
    background: #d32f2f;
    color: #fff;
    border-color: #d32f2f;
}

/* ===== SUMMARY CARD ===== */
.cart-summary-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid rgba(46, 125, 50, 0.14);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
    padding: 1.5rem;
    overflow: hidden;
    transition: box-shadow 0.25s ease;
}

.cart-summary-card:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.07);
}

.summary-card-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-deep);
    margin-bottom: 1.2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.summary-card-header i {
    color: var(--primary-color);
}

.summary-lines {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-bottom: 0.5rem;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.94rem;
    color: var(--text-secondary);
    padding: 0.25rem 0;
}

.summary-discount {
    color: var(--success-color);
    font-weight: 700;
}

.summary-discount i {
    margin-right: 0.3rem;
}

.summary-free {
    color: var(--success-color);
    font-weight: 800;
    background: #e8f5e9;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
}

.summary-free-hint {
    font-size: 0.82rem;
    color: #2e7d32;
    background: #f0f7f0;
    border: 1px solid rgba(46, 125, 50, 0.15);
    border-radius: 10px;
    padding: 0.55rem 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.4rem;
    font-weight: 500;
}

.summary-free-hint i {
    font-size: 0.95rem;
    color: var(--primary-color);
}

.summary-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary-deep);
    border-top: 2px dashed rgba(46, 125, 50, 0.15);
    margin-top: 0.9rem;
    padding-top: 1rem;
}

.checkout-btn {
    margin-top: 1.2rem;
    padding: 0.9rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.checkout-btn:hover {
    box-shadow: 0 8px 24px rgba(240, 33, 33, 0.25);
}

.summary-trust {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.summary-trust span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.summary-trust i {
    color: var(--primary-color);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 960px) {
    .cart-grid {
        grid-template-columns: 1fr;
    }
    .cart-right {
        position: static;
    }
}

@media (max-width: 640px) {
    .cart-page-wrapper { padding: 1rem 0 2rem; }

    /* Hide table head & redundant uppercase price labels on mobile */
    .cart-table-head { display: none; }
    .cart-price-label { display: none !important; }

    .cart-item {
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 0.8rem 0.9rem;
        padding: 1.1rem 1rem;
        position: relative;
        align-items: center;
        border-bottom: 1px solid var(--border-color);
        background: #ffffff;
    }

    /* Top Row: Product Thumbnail + Info */
    .col-product {
        grid-column: 1 / -1;
        display: flex;
        align-items: center;
        gap: 0.85rem;
        padding-right: 2.5rem; /* Room for delete button */
    }

    .cart-item-media {
        width: 60px;
        height: 60px;
        border-radius: 14px;
        flex-shrink: 0;
    }

    .cart-item-info {
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
    }

    .cart-item-name {
        font-size: 0.98rem;
        font-weight: 700;
        color: var(--primary-deep);
        line-height: 1.3;
    }

    .cart-item-unit-price {
        font-size: 0.82rem;
        color: var(--text-muted);
        font-weight: 500;
    }

    /* Hide redundant col-price on mobile */
    .col-price {
        display: none !important;
    }

    /* Bottom Row Left: Quantity Control */
    .col-qty {
        grid-column: 1 / 2;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        padding: 0;
        margin-top: 0.2rem;
    }

    .qty-control {
        height: 34px;
        padding: 2px 4px;
        gap: 4px;
        border-radius: 999px;
        background: var(--primary-subtle, #f4faf4);
    }

    .qty-btn {
        width: 28px;
        height: 28px;
        font-size: 0.78rem;
    }

    .qty-value {
        min-width: 22px;
        font-size: 0.88rem;
        font-weight: 700;
    }

    /* Bottom Row Right: Subtotal Amount */
    .col-subtotal {
        grid-column: 2 / 3;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        padding: 0;
        margin-top: 0.2rem;
    }

    .cart-item-subtotal {
        font-size: 1.1rem;
        font-weight: 800;
        color: var(--primary-deep);
    }

    /* Top Right Remove Icon */
    .col-remove {
        position: absolute;
        top: 1rem;
        right: 1rem;
    }

    .cart-remove-btn {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: #fef2f2;
        color: #ef4444;
        border: 1px solid #fecaca;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.85rem;
        transition: all 0.2s ease;
    }

    .cart-remove-btn:hover {
        background: #ef4444;
        color: #ffffff;
        border-color: #ef4444;
    }

    /* Mobile Header & Bottom Actions */
    .cart-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0.6rem;
    }

    .cart-title {
        font-size: 1.35rem;
    }

    .cart-title-icon {
        width: 38px;
        height: 38px;
        font-size: 0.95rem;
        border-radius: 10px;
    }

    .cart-actions {
        flex-direction: row;
        align-items: center;
        gap: 0.6rem;
        padding: 1rem;
        background: #f9fbf9;
        border-top: 1px solid var(--border-color);
    }

    .cart-actions .btn {
        flex: 1;
        justify-content: center;
        padding: 0.6rem 0.8rem;
        font-size: 0.82rem;
        white-space: nowrap;
    }
}

@media (max-width: 360px) {
    .cart-summary-card, .cart-coupon-card { padding: 1rem; }
    .summary-total { font-size: 1.1rem; }
    .cart-actions { flex-direction: column; }
}
