/* ==========================================================================
   1. Base Page Layout (Cart & Checkout)
   ========================================================================== */
body.cart-page,
body.checkout-page {
    background: var(--background);
    padding: 20px;
    min-height: 100vh;
    box-sizing: border-box;
}

/* Titles on both pages */
.cart-page h2,
.checkout-page h2 {
    text-align: center;
    color: #1F2937;
    font-size: 2em;
    margin-bottom: 20px;
}

/* Sub-titles, like in the checkout form */
.checkout-page h3 {
    text-align: center;
    color: #1F2937;
    font-size: 1.5em;
    margin-bottom: 15px;
}

/* ==========================================================================
   2. Cart & Checkout Summary Table (Shared Styles)
   ========================================================================== */
#cartItems,
#summary-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 20px auto;
}

#cartItems p {
    text-align: center;
    color: #374151;
    font-size: 1em;
    margin: 20px 0;
}

.cart-summary-table,
.checkout-summary-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: #FFFFFF;
    border: 1px solid #D1D5DB;
    box-shadow: var(--shadow-neumorphic);
    border-radius: 12px;
    overflow: hidden;
}

.cart-summary-table th, .cart-summary-table td,
.checkout-summary-table th, .checkout-summary-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #D1D5DB;
    vertical-align: middle;
}

.cart-summary-table tr:last-child td,
.checkout-summary-table tr:last-child td {
    border-bottom: none;
}

.cart-summary-table th,
.checkout-summary-table th {
    font-weight: bold;
    background: #E5E7EB;
}

.remove-item-btn {
    padding: 8px 12px;
    font-size: 0.9em;
    background: #6c757d;
    border: none;
    border-radius: 8px;
    box-shadow: var(--shadow-neumorphic);
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    color: #FFFFFF;
}

.remove-item-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.summary-img,
.img-carrito,
.checkout-product-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #E5E7EB;
}

.quantity-btn {
    padding: 4px 8px;
    font-weight: bold;
    cursor: pointer;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
}

.quantity-value {
    margin: 0 10px;
    font-weight: bold;
}

/* ==========================================================================
   3. Totals and Action Buttons
   ========================================================================== */
#cartTotal,
#checkout-total {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--accent);
    text-align: right;
    margin: 20px 0;
}

.cart-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin: 20px 0;
}

.link-separator {
    text-align: right;
    margin: 10px 0;
    color: #6B7280;
}

/* ==========================================================================
   4. Checkout Form Specific Styles
   ========================================================================== */
.checkout-form {
    width: 100%;
    max-width: 700px;
    margin: 20px auto;
}

.checkout-form fieldset {
    border: 1px solid #ddd;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
}

.checkout-form legend {
    padding: 0 10px;
    font-weight: bold;
    color: var(--primary);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #1F2937;
}

.form-group-inline {
    display: flex;
    gap: 15px;
}

.form-group-inline > div {
    flex: 1;
}

.checkout-form .entry {
    width: 100%;
    max-width: none;
    margin: 0;
    box-sizing: border-box;
}

.checkout-form .entry:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-hover);
}

#confirmPurchaseBtn {
    width: 100%;
}

#successMessage {
    text-align: center;
    color: var(--accent);
    font-size: 1.2em;
    font-weight: bold;
    margin: 40px 0;
    padding: 20px;
    border: 2px solid var(--accent);
    border-radius: 8px;
    background-color: #f0f9f4;
}

/* ==========================================================================
   5. Responsive Design
   ========================================================================== */
@media (max-width: 768px) {
    body.cart-page,
    body.checkout-page {
        padding: 10px;
    }

    .cart-summary-table thead, .checkout-summary-table thead {
        display: none;
    }
    .cart-summary-table tr, .checkout-summary-table tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 8px;
    }
    .cart-summary-table td, .checkout-summary-table td {
        display: block;
        text-align: right;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50%;
    }
    .cart-summary-table td::before, .checkout-summary-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        font-weight: bold;
        text-align: left;
    }

    .summary-img,
    .img-carrito,
    .checkout-product-image {
        width: 40px;
        height: 40px;
    }

    #cartItems,
    #summary-container {
        max-width: 100%;
    }
}