/* ====== CART PAGE ONLY ====== */
.cart-container {
    max-width: 1100px;
    margin: 40px auto;
    padding: 20px;
    overflow-x: hidden; /* منع الـ scroll الأفقي */
}
.cart-container h1 {
    text-align: center;
    margin-bottom: 25px;
    font-size: 2rem;
}

/* Table */
.cart-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    table-layout: fixed; /* علشان الأعمدة توزع المساحة بالتساوي */
}

.cart-table th, .cart-table td {
    padding: 12px 8px; /* تقليل الـ padding */
    text-align: center;
    border-bottom: 1px solid #eee;
    word-wrap: break-word; /* كسر الكلمات الطويلة */
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-table th {
    background: #f0f4f3;
    font-weight: bold;
    font-size: 0.9rem; /* تصغير حجم الخط للعناوين */
}

.cart-table td {
    font-size: 0.85rem; /* تصغير حجم الخط للمحتوى */
}

.cart-table img {
    width: 60px; /* تصغير حجم الصور */
    height: 60px;
    border-radius: 6px;
    object-fit: cover;
}

.cart-table input[type="number"] {
    width: 50px; /* تصغير حجم حقل الإدخال */
    padding: 4px;
    border: 1px solid #ccc;
    border-radius: 5px;
    text-align: center;
    font-size: 0.8rem;
}

.remove-btn {
    background: none;
    border: none;
    color: crimson;
    font-size: 1rem; /* تصغير حجم الأيقونة */
    cursor: pointer;
    transition: transform 0.2s;
    padding: 5px;
}

.remove-btn:hover {
    transform: scale(1.2);
}

/* أزرار الكمية */
.qty-btn {
    width: 25px;
    height: 25px;
    border: 1px solid #ccc;
    background: #f0f4f3;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
    margin: 0 2px;
}

.qty-btn:hover {
    background: #ddd;
}

.quantity-input {
    width: 40px;
    margin: 0 5px;
}

/* تنسيق أفضل لمجموعة أزرار الكمية */
.quantity-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: fit-content;
}

/* Summary */
.cart-summary {
    margin-top: 30px;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    max-width: 320px;
    float: right;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.cart-summary h2 {
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.cart-summary p {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
}

.cart-summary strong {
    font-size: 1.1rem;
}

.checkout-btn {
    width: 100%;
    padding: 12px;
    margin-top: 15px;
    border: none;
    border-radius: 6px;
    background: #19183b;
    color: #fff;
    cursor: pointer;
    transition: background 0.3s;
    font-size: 1rem;
}

.checkout-btn:hover {
    background: #333261;
}

/* ===== RESPONSIVE DESIGN ===== */

/* للشاشات المتوسطة (Tablets) */
@media (max-width: 1024px) {
    .cart-container {
        padding: 15px;
        margin: 20px auto;
    }
    
    .cart-table th, .cart-table td {
        padding: 10px 6px;
        font-size: 0.8rem;
    }
    
    .cart-table img {
        width: 50px;
        height: 50px;
    }
    
    .cart-table input[type="number"] {
        width: 45px;
    }
    
    .quantity-controls {
        gap: 1px;
    }
}

/* للشاشات الصغيرة (Tablets صغيرة) */
@media (max-width: 768px) {
    .cart-container {
        padding: 10px;
        margin: 25px auto;
    }
    
    .cart-container h1 {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }
    
    .cart-table {
        min-width: 100%;
        overflow: visible;
    }
    
    .cart-table th, .cart-table td {
        padding: 8px 4px;
        font-size: 0.75rem;
    }
    
    .cart-table img {
        width: 35px;
        height: 35px;
    }
    
    .cart-table input[type="number"] {
        width: 30px;
        font-size: 0.7rem;
        padding: 2px;
    }
    
    .qty-btn {
        width: 20px;
        height: 20px;
        font-size: 0.7rem;
        margin: 0 1px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .quantity-controls {
        gap: 1px;
        min-width: 80px;
        flex-wrap: nowrap;
    }
    
    .quantity-input {
        width: 30px;
        margin: 0 2px;
        min-width: 30px;
        flex-shrink: 0;
    }
    
    .remove-btn {
        font-size: 0.9rem;
        padding: 2px;
    }
    
    .cart-summary {
        float: none;
        max-width: 100%;
        margin: 20px auto;
    }
}

/* للشاشات الصغيرة جداً (Mobile) */
@media (max-width: 480px) {
    .cart-container {
        padding: 5px;
        margin: 35px auto;
    }
    
    .cart-container h1 {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }
    
    .cart-table {
        font-size: 0.65rem;
        table-layout: auto;
    }
    
    .cart-table th, .cart-table td {
        padding: 4px 2px;
        font-size: 0.65rem;
        vertical-align: middle;
    }
    
    .cart-table th {
        font-size: 0.7rem;
    }
    
    .cart-table img {
        width: 30px;
        height: 30px;
    }
    
    .cart-table input[type="number"] {
        width: 25px;
        padding: 1px;
        font-size: 0.6rem;
        min-width: 25px;
    }
    
    .qty-btn {
        width: 18px;
        height: 18px;
        font-size: 0.6rem;
        margin: 0;
        padding: 0;
        border-width: 1px;
        min-width: 18px;
        flex-shrink: 0;
    }
    
    .quantity-controls {
        gap: 1px;
        min-width: 70px;
        flex-wrap: nowrap;
        justify-content: center;
    }
    
    .quantity-input {
        width: 25px;
        margin: 0 1px;
        min-width: 25px;
        flex-shrink: 0;
    }
    
    .remove-btn {
        font-size: 0.7rem;
        padding: 1px;
    }
    
    .cart-summary {
        padding: 15px;
    }
    
    .cart-summary h2 {
        font-size: 1.1rem;
    }
    
    .cart-summary p {
        font-size: 0.9rem;
    }
    
    .checkout-btn {
        padding: 10px;
        font-size: 0.9rem;
    }
    
    /* تحسين توزيع الأعمدة للجوال */
    .cart-table th:nth-child(1), .cart-table td:nth-child(1) { width: 15%; } /* الصورة */
    .cart-table th:nth-child(2), .cart-table td:nth-child(2) { width: 25%; } /* اسم المنتج */
    .cart-table th:nth-child(3), .cart-table td:nth-child(3) { width: 15%; } /* السعر */
    .cart-table th:nth-child(4), .cart-table td:nth-child(4) { width: 25%; } /* الكمية */
    .cart-table th:nth-child(5), .cart-table td:nth-child(5) { width: 15%; } /* المجموع */
    .cart-table th:nth-child(6), .cart-table td:nth-child(6) { width: 5%; }  /* حذف */
}

/* للشاشات الصغيرة جداً جداً */
@media (max-width: 360px) {
    .cart-table {
        font-size: 0.6rem;
    }
    
    .cart-table th, .cart-table td {
        padding: 3px 1px;
        font-size: 0.6rem;
    }
    
    .cart-table th {
        font-size: 0.65rem;
    }
    
    .cart-table img {
        width: 25px;
        height: 25px;
    }
    
    .cart-table input[type="number"] {
        width: 22px;
        padding: 1px;
        font-size: 0.55rem;
        min-width: 22px;
    }
    
    .qty-btn {
        width: 16px;
        height: 16px;
        font-size: 0.55rem;
        min-width: 16px;
        line-height: 1;
    }
    
    .quantity-controls {
        min-width: 60px;
        gap: 0px;
    }
    
    .quantity-input {
        width: 22px;
        margin: 0;
        min-width: 22px;
    }
    
    .remove-btn {
        font-size: 0.6rem;
        padding: 1px;
    }
}

/* Card layout for very small screens - alternative */
@media (max-width: 320px) {
    .cart-table {
        display: none;
    }
    
    .cart-table-mobile {
        display: block;
    }
    
    .cart-item-mobile {
        background: #fff;
        border-radius: 8px;
        padding: 15px;
        margin-bottom: 15px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .cart-item-header {
        display: flex;
        align-items: center;
        margin-bottom: 10px;
    }
    
    .cart-item-image {
        width: 60px;
        height: 60px;
        border-radius: 6px;
        margin-right: 15px;
    }
    
    .cart-item-details {
        flex: 1;
    }
    
    .cart-item-name {
        font-weight: bold;
        margin-bottom: 5px;
    }
    
    .cart-item-price {
        color: #666;
        font-size: 0.9rem;
    }
    
    .cart-item-controls {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 10px;
    }
    
    .quantity-controls-mobile {
        display: flex;
        align-items: center;
        gap: 5px;
    }
    
    .quantity-controls-mobile .qty-btn {
        width: 25px;
        height: 25px;
        font-size: 0.8rem;
    }
    
    .quantity-controls-mobile .quantity-input {
        width: 35px;
        margin: 0 5px;
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #fff;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    width: 90%;
    max-width: 350px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    animation: fadeIn 0.3s ease;
    margin: 20px;
}

.modal-content h3 {
    color: green;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.modal-content p {
    font-size: 14px;
    color: #444;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
}

#ok-btn, #cancel-btn {
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
    border: none;
    min-width: 80px;
}

#ok-btn {
    background: green;
    color: white;
}

#ok-btn:hover {
    background: darkgreen;
}

#cancel-btn {
    background: #d9534f;
    color: white;
}

#cancel-btn:hover {
    background: #c9302c;
}

@keyframes fadeIn {
    from {opacity: 0; transform: scale(0.9);}
    to {opacity: 1; transform: scale(1);}
}

/* ===== DARK MODE FIXES FOR CART PAGE ===== */
body.dark .cart-container h1,
body.dark .cart-container h2,
body.dark .cart-container h3,
body.dark .cart-container p,
body.dark .cart-container span {
    color: #000000 !important;
}

body.dark .cart-table,
body.dark .cart-table th,
body.dark .cart-table td,
body.dark .cart-table tr {
    color: #000000 !important;
    background-color: #ffffff !important;
}

body.dark .cart-table {
    background: #ffffff !important;
}

body.dark .cart-table th {
    background: #f0f4f3 !important;
    color: #000000 !important;
}

body.dark .modal-content,
body.dark .modal-content h3,
body.dark .modal-content p {
    color: #000000 !important;
}

body.dark .qty-btn {
    color: #000000 !important;
    border: 1px solid #000000 !important;
}

body.dark .quantity-input {
    color: #000000 !important;
    background-color: #ffffff !important;
    border: 1px solid #000000 !important;
}

body.dark .cart-container td[colspan] {
    color: #000000 !important;
}

body.dark .cart-container td[colspan] h3,
body.dark .cart-container td[colspan] p {
    color: #000000 !important;
}

body.dark .cart-container a {
    color: #000000 !important;
}

body.dark .cart-container h1 {
    color: #eeebeb !important;
}

body.dark .cart-container a:hover {
    color: #333333 !important;
}

#discount {
    color: green !important;
}
