/* ===================================
   Cart Page - Unified Clean Design (Matching Profile Style)
   Colors: #79499c, #784e9a, #584b75, #898e97
   =================================== */

:root {
    --primary: #79499c;
    --primary-dark: #784e9a;
    --accent-gray: #898e97;
    --dark-purple: #584b75;
    --light-bg: #f8f7fa;
    --card-bg: rgba(255, 255, 255, 0.98);
    --shadow-sm: 0 4px 15px rgba(121, 73, 156, 0.08);
    --shadow-md: 0 12px 30px rgba(121, 73, 156, 0.15);
    --shadow-lg: 0 20px 50px rgba(121, 73, 156, 0.2);
    --shadow-hover: 0 16px 40px rgba(121, 73, 156, 0.18);
    --transition: all 0.3s ease;
}

.cart-section {
    padding: 2rem 0;
    background: linear-gradient(135deg, var(--light-bg) 0%, #f2f0f5 100%);
    min-height: 80vh;
}

/* ===== Main Cards - Matching Profile Style ===== */
.cart-items-card,
.order-summary-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    box-shadow: var(--shadow-md);
    
    overflow: hidden;
    transition: var(--transition);
}

.cart-items-card:hover,
.order-summary-card:hover {
    box-shadow: var(--shadow-hover);
}

/* Card Headers - Gradient like Profile */
.cart-items-card .card-header,
.order-summary-card .card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1.8rem 2.5rem;
    border: none;
    position: relative;
    overflow: hidden;
}

.cart-items-card .card-header::before,
.order-summary-card .card-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23ffffff' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
}

.cart-items-card .card-header h5,
.order-summary-card .card-header h5 {
    font-weight: 700;
    font-size: 1.4rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    z-index: 1;
}

.cart-items-card .card-header .badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1.2rem;
    border-radius: 30px;
    font-size: 0.95rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ===== Cart Table - Modern Design ===== */
.cart-table {
    margin: 0;
    border-collapse: separate;
    border-spacing: 0 1rem;
}

.cart-table thead {
    display: none;
}

.cart-table tbody tr.modern-cart-row {
    display: block;
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    transition: var(--transition);
    
}

.cart-table tbody tr.modern-cart-row:hover {
    box-shadow: var(--shadow-md);
    border-left-color: var(--primary);
}

/* Table Cells - Mobile First */
.cart-table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.3rem 1.8rem;
    border: none;
}

.cart-table tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--primary);
    font-size: 0.95rem;
    min-width: 100px;
}

/* Image Cell */
.cart-table td:first-child {
    justify-content: center;
    background: linear-gradient(135deg, #f5f3f8, #f0edf5);
    padding: 2rem;
}

.cart-item-image-wrapper {
    width: 100px;
    height: 140px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.cart-item-image-wrapper:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-hover);
}

.cart-item-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Book Details */
.cart-table td:nth-child(2) {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), #faf9fc);
}

.cart-item-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--dark-purple);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.cart-item-title a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

.cart-item-title a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.cart-item-details small {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-gray);
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
}

/* Price & Total */
.cart-item-price,
.cart-item-total {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--dark-purple);
}

.cart-item-total {
    background: linear-gradient(135deg, rgba(121, 73, 156, 0.1), rgba(120, 78, 154, 0.08));
    padding: 0.6rem 1.2rem;
    border-radius: 12px;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Quantity Controls */
.quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.quantity-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f0edf5, #e8e4f0);
    border: 2px solid rgba(121, 73, 156, 0.1);
    color: var(--dark-purple);
    font-size: 1.2rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.quantity-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow-md);
    border-color: transparent;
    transform: scale(1.05);
}

.quantity-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.quantity-input {
    width: 70px;
    height: 42px;
    text-align: center;
    border: 2px solid rgba(121, 73, 156, 0.15);
    border-radius: 12px;
    font-weight: 700;
    background: white;
    color: var(--dark-purple);
    transition: var(--transition);
}

.quantity-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(121, 73, 156, 0.15);
    outline: none;
}

.stock-info {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--accent-gray);
    background: rgba(121, 73, 156, 0.08);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Remove Button */
.remove-item {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    border: none;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-item:hover {
    box-shadow: var(--shadow-md);
    transform: scale(1.05) rotate(5deg);
    background: linear-gradient(135deg, #b91c1c, #991b1b);
}

/* Card Footer */
.cart-items-card .card-footer {
    background: linear-gradient(135deg, #f5f3f8, #f0edf5);
    padding: 1.8rem 2.5rem;
    border-top: 1px solid rgba(121, 73, 156, 0.1);
}

#continueShoppingBtn,
#clearCartBtn {
    padding: 0.9rem 2rem;
    border-radius: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    font-size: 1rem;
}

#continueShoppingBtn {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#continueShoppingBtn:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow-md);
    
}

#clearCartBtn {
    background: white;
    color: #dc2626;
    border: 2px solid #dc2626;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#clearCartBtn:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    box-shadow: var(--shadow-md);
    
}

/* ===== Order Summary ===== */
.order-summary-card {
    position: sticky;
    top: 100px;
    height: fit-content;
}

.cart-totals {
    padding: 1.8rem;
    background: linear-gradient(135deg, #f5f3f8, #f0edf5);
    border-radius: 18px;
    margin: 1rem 0;
    
}

.cart-totals > div {
    padding: 0.85rem 0;
    border-bottom: 1px dashed rgba(121, 73, 156, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-totals .fs-5 {
    font-size: 1.4rem !important;
    color: var(--dark-purple);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Discount Section */
.discount-section {
    padding: 1.5rem;
    background: linear-gradient(135deg, #f0edf5, #e8e4f0);
    border-radius: 18px;
    margin: 1rem 0;
    
}

.discount-section .form-label {
    color: var(--dark-purple);
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.discount-section .input-group {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.discount-section .form-control {
    border: 2px solid rgba(121, 73, 156, 0.15);
    border-right: none;
    padding: 0.85rem 1.2rem;
    font-size: 1rem;
    transition: var(--transition);
}

.discount-section .form-control:focus {
    border-color: var(--primary);
    box-shadow: none;
}

.discount-section .btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 0.85rem 1.5rem;
    font-weight: 600;
    transition: var(--transition);
}

.discount-section .btn:hover {
    background: linear-gradient(135deg, var(--primary-dark), #584b75);
    box-shadow: var(--shadow-md);
}

/* Checkout Buttons */
.checkout-btn-container .btn {
    border-radius: 16px;
    padding: 1.3rem;
    font-size: 1.1rem;
    font-weight: 700;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    width: 100%;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.checkout-btn-container a.btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.checkout-btn-container a.btn:hover {
    box-shadow: var(--shadow-hover);
    background: linear-gradient(135deg, var(--primary-dark), #584b75);
}

/* Guest Login Button */
.checkout-btn-container .btn[href*="login"] {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.checkout-btn-container .btn[href*="login"]:hover {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-hover);
    
}

.checkout-btn-container .alert-info {
    background: linear-gradient(135deg, rgba(121, 73, 156, 0.08), rgba(120, 78, 154, 0.05));
    border: none;
    
    border-radius: 14px;
    padding: 1.3rem;
    color: var(--dark-purple);
    margin-bottom: 1rem;
}

.checkout-btn-container .alert-info .alert-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.checkout-btn-container .alert-info .alert-link:hover {
    text-decoration: underline;
}

/* Payment Methods */
.payment-methods {
    padding: 1.8rem;
    background: linear-gradient(135deg, #f5f3f8, #f0edf5);
    border-radius: 18px;
    margin: 1rem 0;
}

.payment-methods .d-flex.align-items-center {
    padding: 1.2rem;
    background: white;
    border-radius: 14px;
    border: 2px solid rgba(121, 73, 156, 0.1);
    margin-bottom: 1rem;
    transition: var(--transition);
    cursor: pointer;
}

.payment-methods .d-flex.align-items-center:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateX(5px);
}

.payment-methods .fs-4 {
    color: var(--primary);
    margin-left: 1rem;
    font-size: 1.8rem;
}

.payment-methods .fw-bold {
    color: var(--dark-purple);
    margin-bottom: 0.3rem;
}

.payment-methods .text-muted {
    color: var(--accent-gray);
    font-size: 0.9rem;
}

/* Security Badges */
.security-badges {
    padding: 1.5rem;
    text-align: center;
    background: linear-gradient(135deg, #f0edf5, #e8e4f0);
    border-radius: 16px;
    margin-top: 1rem;
}

.security-icons i {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, white, #faf9fc);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 0.75rem;
    box-shadow: var(--shadow-sm);
    font-size: 1.4rem;
    transition: var(--transition);
}

.security-icons i:hover {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
    transform: scale(1.1);
}

/* ===== Empty Cart State ===== */
.empty-cart-section {
    padding: 3rem 0;
}

.empty-cart-animation {
    margin: 2rem 0;
}

.cart-icon-wrapper {
    position: relative;
    display: inline-block;
}

.cart-icon-wrapper i {
    font-size: 6rem;
    color: var(--primary);
    opacity: 0.3;
    animation: cartFloat 3s ease-in-out infinite;
}

.cart-empty-dots {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.cart-empty-dots span {
    display: block;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    position: absolute;
    opacity: 0;
    animation: dotPulse 1.5s ease-in-out infinite;
}

.cart-empty-dots span:nth-child(1) {
    top: -30px;
    left: -30px;
    animation-delay: 0s;
}

.cart-empty-dots span:nth-child(2) {
    top: -30px;
    right: -30px;
    animation-delay: 0.5s;
}

.cart-empty-dots span:nth-child(3) {
    bottom: -30px;
    left: 0;
    animation-delay: 1s;
}

/* Related Books Section */
.related-books-section .card {
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: var(--shadow-md);
    
    overflow: hidden;
}

.related-books-section .card-body {
    padding: 2rem;
}

/* Animations */
@keyframes cartFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes dotPulse {
    0%, 100% { opacity: 0; transform: scale(0); }
    50% { opacity: 1; transform: scale(1); }
}

/* Loading States */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
}

/* ===== Desktop View ===== */
@media (min-width: 992px) {
    .cart-table thead {
        display: table-header-group;
        background: linear-gradient(135deg, #f5f3f8, #f0edf5);
    }

    .cart-table thead th {
        padding: 1.5rem 1rem;
        font-weight: 700;
        color: var(--dark-purple);
        border-bottom: 3px solid var(--primary);
        font-size: 1.1rem;
    }

    .cart-table tbody tr.modern-cart-row {
        display: table-row;
        box-shadow: var(--shadow-sm);
        background: white;
    }

    .cart-table tbody tr.modern-cart-row:hover {
        box-shadow: var(--shadow-md);
    }

    .cart-table tbody td {
        display: table-cell;
        vertical-align: middle;
        text-align: center;
        padding: 1.5rem 1rem;
    }

    .cart-table tbody td::before { display: none; }

    .cart-table td:first-child { background: none; }
    .cart-table td:nth-child(2) { text-align: right; }

    /* Column widths */
    .cart-table th:nth-child(1), td:nth-child(1) { width: 12%; }
    .cart-table th:nth-child(2), td:nth-child(2) { width: 28%; }
    .cart-table th:nth-child(3), td:nth-child(3) { width: 15%; }
    .cart-table th:nth-child(4), td:nth-child(4) { width: 18%; }
    .cart-table th:nth-child(5), td:nth-child(5) { width: 15%; }
    .cart-table th:nth-child(6), td:nth-child(6) { width: 12%; }
}

@media (max-width: 768px) {
    .cart-item-image-wrapper { width: 90px; height: 130px; }
    .quantity-btn { width: 38px; height: 38px; }
    .quantity-input { width: 65px; }
    .cart-items-card .card-header,
    .order-summary-card .card-header {
        padding: 1.5rem;
    }
}

@media (max-width: 576px) {
    .cart-items-card .card-header,
    .order-summary-card .card-header {
        padding: 1.3rem 1.2rem;
    }
    
    .cart-table tbody td {
        padding: 1.2rem;
    }
    
    .cart-icon-wrapper i {
        font-size: 5rem;
    }
}

/* Form Input Alignment Fix */
.form-control {
    direction: rtl;
    text-align: right;
    padding-right: 1rem;
}

.form-control::placeholder {
    direction: rtl;
    text-align: right;
}

.discount-section .form-control {
    direction: rtl;
    text-align: right;
}