/* --- Cart Page Styles --- */
/* (Base styles like .container, .card, .button are in products.css) */

.cart-page-main {
    margin-top: 5%;
    padding: 2rem 0 4rem; /* Adjusted padding */
}

.cart-page-main h1 {
    font-family: var(--font-secondary);
    font-size: clamp(1.8rem, 5vw, 2.2rem); /* Responsive font size */
    text-align: center;
    margin-bottom: 2.5rem; /* Increased margin */
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.cart-layout {
    display: grid;
    grid-template-columns: 2.5fr 1fr;
    gap: 2rem;
    align-items: flex-start;
}

/* --- Cart Items --- */
.cart-items-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.cart-loading {
    font-size: 1.1rem; /* Adjusted font */
    color: var(--text-secondary);
    text-align: center;
    padding: 3rem;
}
.cart-loading i {
    margin-right: 0.5rem;
    font-size: 1.3rem; /* Slightly larger spinner */
}

.cart-item {
    display: grid;
    /* Columns: Image | Details | Actions | Subtotal */
    grid-template-columns: 100px 1fr auto auto;
    gap: 1rem;
    align-items: center;
    background: var(--secondary-bg);
    padding: 1.25rem; /* Increased padding */
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: opacity 0.3s ease; /* For remove feedback */
}

.cart-item-image img {
    width: 100%;
    height: 100px;
    object-fit: contain;
    background: #000;
    border-radius: 6px;
}

.cart-item-details {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    align-self: flex-start; /* Align to top */
}
.cart-item-details .item-name {
    font-family: var(--font-secondary);
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1rem; /* Controlled font size */
    line-height: 1.3;
}
.cart-item-details .item-name:hover {
    color: var(--accent-1);
}
.cart-item-details .item-price {
    color: var(--text-secondary);
    font-size: 0.9rem; /* Controlled font size */
}
.item-remove-btn {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 0.8rem; /* Controlled font size */
    font-weight: 600; /* Bolder */
    cursor: pointer;
    text-align: left;
    padding: 0.2rem 0;
    margin-top: 0.5rem;
    transition: color 0.2s ease;
}
.item-remove-btn:hover {
    color: #ff6b81; /* Lighter red */
    text-decoration: none;
}
.item-remove-btn i {
    margin-right: 0.3rem;
}


/* --- NEW: Quantity Selector --- */
.cart-item-actions {
    justify-self: center;
}
.quantity-selector {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    background: var(--primary-bg);
}
.quantity-btn {
    background: var(--secondary-bg);
    border: none;
    color: var(--text-primary);
    width: 35px;
    height: 35px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 1rem;
    line-height: 1; /* Center icon */
}
.quantity-btn:hover {
    background: var(--accent-1);
    color: #000;
}
.quantity-btn:disabled {
    color: var(--text-secondary);
    background: var(--card-bg);
    cursor: not-allowed;
}
.item-quantity-input {
    width: 40px;
    height: 35px;
    padding: 0.5rem;
    text-align: center;
    background: transparent; /* Changed */
    border: none;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-secondary); /* Match style */
    font-weight: 700;
    font-size: 1.1rem; /* Larger font */
    -moz-appearance: textfield;
    appearance: textfield;
    pointer-events: none; /* Make it non-editable */
    transition: opacity 0.3s ease;
}
.item-quantity-input::-webkit-outer-spin-button,
.item-quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none; margin: 0;
}


.cart-item-subtotal {
    justify-self: flex-end;
    font-family: var(--font-secondary);
    font-weight: 700;
    font-size: 1.1rem; /* Controlled font */
    color: var(--accent-1);
    padding-left: 0.5rem; /* Ensure space */
    white-space: nowrap; /* Prevent wrap */
}

/* --- Cart Summary --- */
.cart-summary-container.card {
    position: sticky;
    top: calc(var(--header-height) + 2rem);
    padding: 1.5rem;
}
.cart-summary-container h2 {
    font-family: var(--font-secondary);
    font-size: 1.4rem; /* Controlled font */
    margin-top: 0; margin-bottom: 1.5rem;
    padding-bottom: 1rem; border-bottom: 1px solid var(--border-color);
}
.summary-row {
    display: flex; justify-content: space-between;
    font-size: 0.9rem; /* Controlled font */
    color: var(--text-secondary); margin-bottom: 1rem;
}
.summary-row span:last-child { font-weight: 600; color: var(--text-primary); }
.summary-row.total {
    font-size: 1.1rem; /* Controlled font */
    font-weight: 700; color: var(--text-primary);
    margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border-color);
}
.summary-row.total span:last-child {
    color: var(--accent-1); font-size: 1.2rem; /* Controlled font */
}
.checkout-btn {
    width: 100%; margin-top: 1rem;
    font-family: var(--font-secondary); font-size: 1.1rem;
}
.checkout-btn:disabled {
    background: var(--secondary-bg); border-color: var(--border-color);
    color: var(--text-secondary); cursor: not-allowed; opacity: 0.7;
}

/* --- Empty Cart --- */
.cart-empty-container {
    display: none; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 4rem 2rem; text-align: center; color: var(--text-secondary);
}
.cart-empty-container i { font-size: 4rem; color: var(--border-color); margin-bottom: 1.5rem; }
.cart-empty-container h2 {
    font-family: var(--font-secondary); color: var(--text-primary);
    font-size: 1.5rem; margin-bottom: 0.5rem;
}
.cart-empty-container .button { 
    margin-top: 2rem; 
    font-family: var(--font-secondary); 
    text-decoration: none; 
    font-size: 1.5rem;
    font-weight: 700;
    color: transparent;
    background: linear-gradient(to right, blue, rgb(255, 0, 0));
    background-clip: text; 
}
.modal-actions .button{
    margin-top: 2rem; 
    font-family: var(--font-secondary); 
    text-decoration: none; 
    font-size: 1rem;
    font-weight: 900;
    color: transparent;
    background: linear-gradient(to right, blue, rgb(255, 0, 0));
    background-clip: text; 
}
/* --- Cart Page Styles --- */
/* ... (all existing styles for .cart-layout, .cart-item, .quantity-selector, etc.) ... */

/* --- NEW: Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

.modal-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    z-index: 1001;
    width: 90%;
    max-width: 450px;
    padding: 2rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}
.modal-popup.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
    transition-delay: 0s;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    font-weight: 300;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
}
.modal-close:hover {
    color: var(--text-primary);
}

.modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.modal-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}
.modal-icon.warning {
    color: var(--warning, #ffc107); /* Use variable or fallback */
}
.modal-popup h2 {
    font-family: var(--font-secondary);
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-top: 0;
    margin-bottom: 0.5rem;
}
.modal-popup p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}
.modal-actions {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 0.8rem;
}
.modal-action-btn {
    width: 100%;
    font-family: var(--font-secondary);
}


/* --- Responsive --- */
@media (max-width: 992px) {
    .cart-layout {
        grid-template-columns: 1fr; /* Stack columns */
    }
    .cart-summary-container.card {
        position: static; /* Unstick */
        margin-top: 2rem;
    }
}

@media (max-width: 600px) {
    .cart-page-main { padding: 1.5rem 0 3rem;margin-top:20%; }
    .cart-page-main h1 { font-size: 1.6rem; margin-bottom: 2rem; }

    .cart-item {
        /* Stack image, details, actions, subtotal vertically */
        grid-template-columns: 80px 1fr; /* Image | Details+Subtotal */
        gap: 0.8rem 1rem;
        padding: 0.8rem;
    }
    .cart-item-image {
        grid-row: 1 / 3; /* Span 2 rows */
        height: 80px; /* Smaller image */
    }
    .cart-item-image img { height: 80px; }
    .cart-item-details {
        grid-column: 2 / 3;
        align-self: flex-start;
        gap: 0.1rem;
    }
    .cart-item-details .item-name { font-size: 0.9rem; }
    .cart-item-details .item-price { font-size: 0.8rem; }
    .item-remove-btn { margin-top: 0.3rem; }

    .cart-item-actions {
        grid-column: 2 / 3; /* Move actions under details */
        grid-row: 2 / 3;
        justify-self: flex-start; /* Align left */
        align-self: flex-end; /* Align bottom */
    }
    .quantity-btn { width: 30px; height: 30px; font-size: 0.8rem; }
    .item-quantity-input { width: 35px; height: 30px; font-size: 1rem; }
    
    .cart-item-subtotal {
        grid-column: 2 / 3; /* Move subtotal under actions */
        grid-row: 3 / 4;
        justify-self: flex-start;
        align-self: flex-end;
        font-size: 1rem;
        margin-top: 0.5rem;
        padding-left: 0; /* Remove padding */
    }

    .cart-summary-container.card { padding: 1.2rem; }
    .cart-summary-container h2 { font-size: 1.2rem; }
    .summary-row { font-size: 0.85rem; }
    .summary-row.total { font-size: 1rem; }
    .summary-row.total span:last-child { font-size: 1.1rem; }
}

@media (max-width: 380px) {
     .cart-item {
        grid-template-columns: 60px 1fr; /* Smaller image */
     }
     .cart-item-image { height: 60px; }
     .cart-item-image img { height: 60px; }
}

