/* css/cart.css */

/* --- Main Layout --- */
.cart-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

.cart-layout {
    display: flex;
    gap: 30px;
    align-items: flex-start; /* Prevents stretching */
}

/* --- Left Side: Product List --- */
.cart-items-wrapper {
    flex: 2; /* Takes 66% width */
    background: #fff;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    padding: 20px;
}

.cart-item-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding: 20px 0;
    gap: 20px;
}

.cart-item-row:last-child {
    border-bottom: none;
}

/* Image Control - Fixes "Too Big" issue */
.cart-img-wrapper {
    width: 100px;  /* Fixed width */
    height: 100px; /* Fixed height */
    flex-shrink: 0; /* Prevents squishing */
    background: #f9f9f9;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Shows full product inside the box */
}

/* Product Details (Next to Image) */
.cart-details {
    flex-grow: 1; /* Takes available space */
}

.cart-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2c3e50;
    text-decoration: none;
    display: block;
    margin-bottom: 5px;
}
.cart-title:hover { color: #3498db; }

.cart-meta {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 5px;
}

.cart-price {
    font-weight: bold;
    color: #333;
}

/* --- Quantity Selector (Compact) --- */
.qty-form {
    display: flex;
    align-items: center;
}

.qty-selector-sm {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    height: 36px;
    width: 100px;
}

.qty-btn-sm {
    width: 30px;
    height: 100%;
    border: none;
    background: #f1f2f6;
    cursor: pointer;
    font-weight: bold;
    color: #555;
    transition: background 0.2s;
}

.qty-btn-sm:hover { background: #e1e1e1; }

.qty-input-sm {
    width: 40px;
    height: 100%;
    border: none;
    text-align: center;
    font-weight: bold;
    font-size: 0.9rem;
    -moz-appearance: textfield;
}
.qty-input-sm::-webkit-outer-spin-button,
.qty-input-sm::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* --- Right Side: Summary --- */
.cart-summary {
    flex: 1; /* Takes 33% width */
    background: #fff;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    padding: 25px;
    position: sticky;
    top: 90px; /* Sticks when scrolling */
}

.summary-title {
    font-size: 1.3rem;
    margin-bottom: 20px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
    display: inline-block;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    color: #555;
}

.summary-total {
    border-top: 1px solid #eee;
    padding-top: 15px;
    margin-top: 15px;
    font-weight: bold;
    font-size: 1.2rem;
    color: #2c3e50;
}

/* Buttons */
.btn-checkout {
    display: block;
    width: 100%;
    padding: 12px;
    background: #27ae60;
    color: white;
    text-align: center;
    border-radius: 5px;
    font-weight: bold;
    margin-top: 20px;
    transition: background 0.2s;
}
.btn-checkout:hover { background: #219150; }

.btn-continue {
    display: block;
    width: 100%;
    padding: 12px;
    background: transparent;
    color: #7f8c8d;
    text-align: center;
    border: 1px solid #bdc3c7; /* Outline style */
    border-radius: 5px;
    font-weight: 500;
    margin-top: 10px;
    transition: all 0.2s;
}
.btn-continue:hover {
    background: #f1f2f6;
    color: #2c3e50;
    border-color: #95a5a6;
}

.btn-remove {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 1.2rem;
    margin-left: 20px;
}

/* --- Responsive --- */
@media (max-width: 850px) {
    .cart-layout {
        flex-direction: column;
    }
    .cart-items-wrapper, .cart-summary {
        width: 100%;
    }
}


/* --- MOBILE OPTIMIZATIONS --- */
@media (max-width: 650px) {
    
    /* 1. Allow the row to wrap elements to the next line */
    .cart-item-row {
        flex-wrap: wrap;
        position: relative; /* Needed to anchor the X button */
        padding-right: 25px; /* Make space for the X button so text doesn't hit it */
    }

    /* 2. Make image slightly smaller on mobile */
    .cart-img-wrapper {
        width: 70px;
        height: 70px;
        margin-right: 10px;
    }

    /* 3. Details take up the remaining space next to image */
    .cart-details {
        width: calc(100% - 90px); /* Full width minus image size */
        margin-bottom: 10px;
    }

    /* 4. Force Quantity Selector to a new line */
    .qty-form {
        width: auto;
        margin-top: 5px;
    }

    /* 5. Handle the Subtotal Div (The 4th element) */
    /* We move it to the right of the quantity selector */
    .cart-item-row > div:nth-child(4) {
        width: auto !important;
        flex-grow: 1;
        text-align: right !important;
        margin-top: 5px;
        font-size: 1.1rem;
    }

    /* 6. FIX THE RED 'X' BUTTON (Absolute Position) */
    /* This sticks it to the top-right corner regardless of content width */
    .btn-remove {
        position: absolute;
        top: 15px;
        right: 0;
        margin-left: 0;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #fff; /* Optional: adds background so it's easy to see */
    }
}