/* ===============================
   GLOBAL RESET & SAFETY
================================ */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden; /* 🔒 hard lock */
}

body {
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f3f3f3;
    color: #222;
}

/* ===============================
   BASIC ELEMENTS
================================ */

a {
    text-decoration: none;
    color: #2563eb;
}

a:hover {
    text-decoration: underline;
}

h1 {
    font-size: clamp(20px, 4vw, 28px);
    margin: 20px 0;
    padding: 0 16px;
}

/* ===============================
   MAIN LAYOUT
================================ */

.cart-wrapper {
    display: flex;
    gap: 20px;
    padding: 16px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* ===============================
   LEFT: CART ITEMS
================================ */

.cart-items {
    flex: 1;
    background: #ffffff;
    padding: 16px;
    border-radius: 12px;
    width: 100%;
    overflow-x: hidden;
}

/* ===============================
   RIGHT: SUMMARY
================================ */

.cart-summary {
    width: 320px;
    max-width: 100%;
    background: #ffffff;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    position: sticky;
    top: 16px;
}

/* ===============================
   TABLE (DESKTOP)
================================ */

.cart-table {
    width: 100%;
    border-collapse: collapse;
}

.cart-table th,
.cart-table td {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    text-align: center;
    font-size: 14px;
}

/* DESKTOP FIX: Keep Action column in one line */
.cart-table th:last-child,
.cart-table td:last-child {
    white-space: nowrap;
    vertical-align: middle;
}

.cart-table th {
    background: #f8fafc;
    font-weight: 600;
}

.cart-img {
    width: 60px;
    max-width: 100%;
    border-radius: 8px;
}

/* ===============================
   QUANTITY CONTROLS
================================ */

.qty-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.qty-input {
    width: 48px;
    padding: 6px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.qty-btn {
    width: 32px;
    height: 32px;
    background: #ffffff;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
}

.qty-btn:hover {
    background: #f1f5f9;
}

/* ===============================
   REMOVE
================================ */

.remove-btn {
    color: #dc2626;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ===============================
   SUMMARY CONTENT
================================ */

.cart-summary p {
    font-size: 15px;
    margin: 10px 0;
}

.cart-summary .total-line {
    font-size: 18px;
    font-weight: 700;
}

/* ===============================
   CHECKOUT BUTTON
================================ */

.btn-checkout {
    width: 100%;
    background: #ffd814;
    color: #000;
    padding: 12px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    margin-top: 20px;
    text-align: center;
}

.btn-checkout:hover {
    background: #f7ca00;
}

/* ===============================
   COUPON
================================ */

.coupon-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.coupon-section form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.coupon-section input {
    flex: 1;
    min-width: 0;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
}

.coupon-section button {
    padding: 10px 16px;
    border-radius: 6px;
    border: none;
    background: #2563eb;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.coupon-section button:hover {
    background: #1e40af;
}

/* ===============================
   TOAST
================================ */

.toast {
    position: fixed;
    top: 16px;
    right: 16px;
    background: #16a34a;
    color: #ffffff;
    padding: 12px 18px;
    border-radius: 8px;
    z-index: 9999;
    animation: fadeOut 4s forwards;
}

@keyframes fadeOut {
    0% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* ===============================
   MOBILE / TABLET
================================ */

@media (max-width: 900px) {

    .cart-wrapper {
        flex-direction: column;
        padding: 12px;
    }

    .cart-summary {
        width: 100%;
        position: static;
        margin-top: 20px;
    }

    /* TABLE → CARD */
    .cart-table,
    .cart-table thead,
    .cart-table tbody,
    .cart-table th,
    .cart-table td,
    .cart-table tr {
        display: block;
        width: 100%;
    }

    .cart-table thead {
        display: none;
    }

    .cart-table tr {
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 12px;
        margin-bottom: 16px;
    }

    .cart-table td {
        border: none;
        padding: 6px 0;
        text-align: left;
        font-size: 14px;
        word-break: break-word;
    }

    .cart-img {
        width: 70px;
    }

    .qty-controls {
        justify-content: flex-start;
    }

    .btn-checkout {
        font-size: 15px;
    }
}
/* ===============================
   MOBILE: IMAGE LEFT, DETAILS RIGHT
================================ */
@media (max-width: 900px) {

    /* Make each cart item a 2-column grid */
    .cart-table tr {
        display: grid;
        grid-template-columns: 90px 1fr; /* image | content */
        gap: 12px;
        align-items: start;
    }

    /* First td (image + product name) */
    .cart-table tr td:first-child {
        grid-row: span 10;
        text-align: center;
    }

    .cart-table tr td:first-child img {
        width: 80px;
        margin-bottom: 6px;
    }

    /* All other details on right */
    .cart-table tr td:not(:first-child) {
        text-align: left;
        padding: 4px 0;
    }

    /* Quantity buttons align left */
    .qty-controls {
        justify-content: flex-start;
    }

    /* Remove button spacing */
    .remove-btn {
        display: inline-block;
        margin-top: 6px;
    }
}
/* ===============================
   MOBILE STYLISH PRODUCT CARDS
================================ */
@media (max-width: 900px) {

    /* Card background & spacing */
    .cart-table tr {
        background: #ffffff;
        border-radius: 14px;
        padding: 14px;
        box-shadow: 0 4px 14px rgba(0,0,0,0.06);
    }

    /* Image column */
    .cart-table tr td:first-child {
        text-align: center;
    }

    .cart-table tr td:first-child img {
        width: 78px;
        height: auto;
        border-radius: 10px;
    }

    /* Product name */
    .cart-table tr td:nth-child(2) {
        font-weight: 600;
        font-size: 15px;
        color: #111827;
    }

    /* Model / color text */
    .cart-table tr td {
        font-size: 14px;
        color: #374151;
    }

    /* Price emphasis */
    .cart-table tr td:has(span),
    .cart-table tr td strong {
        font-weight: 600;
    }

    /* Quantity row */
    .qty-controls {
        margin: 8px 0;
        gap: 8px;
    }

    .qty-btn {
        background: #f1f5f9;
        border-radius: 8px;
        font-size: 16px;
    }

    .qty-input {
        font-weight: 600;
        border-radius: 8px;
    }

    /* Subtotal */
    .cart-table tr td span.subtotal {
        font-weight: 700;
        font-size: 15px;
        color: #111827;
    }

    /* Remove button */
    .remove-btn {
        color: #ef4444;
        font-weight: 600;
        font-size: 14px;
    }

    /* Tighten vertical spacing */
    .cart-table tr td {
        padding: 4px 0;
    }
}
