/* ---------- صفحة السلة ---------- */
.cart-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
    background-color: #f9f9f9;
    min-height: 70vh;
}

.container-fluid {
    padding: 0 12px;
}

.cart-header h2 {
    font-size: 1.75rem;
    color: #333;
}

/* ---------- تنسيق الجداول ---------- */
.cart-table,
.cart-vendors-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.cart-table th,
.cart-vendors-table th {
    font-weight: 600;
    background: #333;
    color: #fff;
    border: 1px solid #ddd;
    padding: 12px 15px;
    text-align: center;
}

.cart-table td,
.cart-vendors-table td {
    max-width: 500px;
    vertical-align: middle !important;
    padding: 12px 15px;
    border: 1px solid #ddd;
    text-align: center !important;
}

/* ✅ الصور */
.cart-table tbody img,
.cart-vendors-table tbody img {
    min-width: 80px;
    min-height: 80px;
    max-width: 80px;
    max-height: 80px;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}

/* ✅ اتجاه النصوص حسب اللغة */
html[lang="en"] .cart-table td:first-child {
    text-align: left !important;
}

html[lang="ar"] .cart-table td:first-child {
    text-align: right !important;
}

/* ✅ تنسيق الحاوية */
.table-responsive {
    margin-top: 20px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
    background: #fff;
}

/* ---------- الأزرار ---------- */
.delete-btn,
.btn-success {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s;
    border: 1px solid var(--gray-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn {
    color: #dc3545;
    background: none;
}

.delete-btn:hover {
    background: var(--danger-color);
    color: white;
    transform: scale(1.1);
}

.btn-success {
    color: var(--dark-color);
    background: none;
}

.btn-success:hover {
    transform: scale(1.1);
}

.btn-details {
    color: #007bff;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-details:hover {
    transform: scale(1.1);
}

/* ---------- النصوص ---------- */
.text-muted {
    color: #6c757d;
    font-size: 14px;
    font-weight: 500;
}

.discount-percent {
    display: inline-block;
    background-color: var(--secondary-color);
    color: white;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 8px;
    white-space: nowrap;
    margin-top: 4px;
}

.sku-container {
    white-space: nowrap;
}

.sku-text {
    font-size: 0.9rem;
    display: block;
    min-width: 100px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== التحكم في الكمية ========== */
#qty_container {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.qty-controls {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #fff;
    padding: 4px 8px;
    transition: box-shadow 0.2s ease;
}

.qty-controls:hover {
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.15);
}

.qty-btn {
    background: transparent;
    color: black;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover {
    transform: scale(1.05);
    background: var(--primary-color);
}

.qty-input {
    width: 60px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    background: transparent;
    outline: none;
    transition: border-color 0.2s;
}

.qty-input:focus {
    border-color: var(--primary-color);
}

/* ---------- الإجماليات ---------- */
.table tfoot .table-total-row {
    background: linear-gradient(90deg, #fdf3e6, #f9e7c8);
    font-weight: 700;
    border-top: 3px solid var(--danger-color);
}

.table tfoot .table-total-row td {
    padding: 10px 6px;
    font-size: 1rem;
}

.sub-total-price-cell,
.shipping-price-cell,
.grand-total-price-cell {
    text-align: var(--align-end);
    font-weight: 700;
}

.table tfoot .grand-total-price-cell {
    color: var(--danger-color);
    font-size: 1.12rem;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* ---------- الملخص للموبايل ---------- */
.cart-mobile-summary {
    display: none;
}

.mobile-summary-card {
    border: 1px solid #eee;
    border-radius: 14px;
    padding: 16px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
    margin-top: 16px;
}

.mobile-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f1f1f1;
}

.mobile-summary-row:last-child {
    border-bottom: none;
}

.mobile-summary-label {
    font-weight: 600;
    color: #444;
    font-size: 0.95rem;
}

.mobile-summary-value {
    font-weight: 700;
    color: #111;
    font-size: 0.95rem;
}

.mobile-summary-grand .mobile-summary-label,
.mobile-summary-grand .mobile-summary-value {
    font-size: 1.05rem;
    color: #000;
}

.mobile-checkout-btn {
    width: 100%;
    margin-top: 14px;
}

/* ---------- السلة الفارغة ---------- */
.empty-cart {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 36px 18px;
    text-align: center;
    box-shadow: var(--shadow);
}

.empty-cart a {
    width: 100%;
}

.empty-cart h4 {
    margin: 12px 0 8px;
    color: var(--text);
}

/* ---------- الطباعة ---------- */
@media print {
    body {
        background: #fff;
        color: #000;
    }

    .table-responsive {
        box-shadow: none;
        border-radius: 0;
    }

    .delete-btn,
    .qty-controls,
    .cart-mobile-summary,
    #checkout,
    #mobile-checkout {
        display: none !important;
    }
}

/* ---------- شاشات متوسطة ---------- */
@media (max-width: 991px) {
    .cart-page {
        padding: 12px;
    }

    .table th,
    .table td {
        padding: 10px;
    }

    .sku-text {
        max-width: 140px;
        font-size: 0.9rem;
    }

    #cart-vendors-container {
        display: none !important;
    }

    .cart-mobile-summary {
        display: block;
    }
}

/* ---------- موبايل / تابلت ---------- */
@media (max-width: 768px) {
    #cart-products-table thead {
        display: none;
    }

    #cart-products-table,
    #cart-products-table tbody {
        display: block;
        width: 100%;
    }

    #cart-products-table tr {
        display: flex;
        flex-wrap: wrap;
        border: 1px solid #ddd;
        border-radius: 10px;
        background: #fff;
        margin-bottom: 15px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        overflow: hidden;
    }

    #cart-products-table td {
        border: none;
        padding: 10px;
    }

    /* المنتج */
    #cart-products-table td:first-child {
        flex: 1 1 100%;
    }

    #cart-products-table td:first-child img {
        width: 90px;
        height: 90px;
        object-fit: cover;
        border-radius: 8px;
    }

    /* السعر */
    #cart-products-table tr td:nth-child(2) {
        flex: 1 1 100%;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 15px;
        flex-wrap: wrap;
    }

    /* الكمية + الإجمالي + الحذف */
    #cart-products-table tr td:nth-child(3),
    #cart-products-table tr td:nth-child(4),
    #cart-products-table tr td:nth-child(5) {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 1 1 calc(100% / 3);
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ✅ Footer يبقى طبيعي ومرتب */
    #cart-products-table tfoot {
        display: table-footer-group;
    }

    #cart-products-table tfoot tr {
        display: table-row;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        border: none;
    }

    #cart-products-table tfoot td {
        display: table-cell;
        border-top: 1px solid #ddd;
        padding: 10px 6px;
        text-align: center !important;
        white-space: normal;
    }

    .sub-total-label {
        font-size: 0.95rem;
    }

    .sub-total-price-cell {
        font-size: 1rem;
        font-weight: 700;
    }

    .qty-controls {
        padding: 4px 6px;
        border-radius: 6px;
    }

    .qty-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .qty-input {
        width: 48px;
        font-size: 0.9rem;
        padding: 4px;
    }

    .mobile-summary-card {
        margin-top: 10px;
        padding: 14px;
        border-radius: 12px;
    }

    .mobile-summary-row {
        padding: 10px 0;
    }

    .mobile-summary-label,
    .mobile-summary-value {
        font-size: 0.92rem;
    }

    .mobile-summary-grand .mobile-summary-label,
    .mobile-summary-grand .mobile-summary-value {
        font-size: 1rem;
    }
}

/* ---------- شاشات صغيرة جدًا ---------- */
@media (max-width: 480px) {
    #cart-products-table tr {
        border-radius: 8px;
    }

    #cart-products-table td:first-child img {
        width: 80px;
        height: 80px;
    }

    .sku-text {
        max-width: 110px;
        font-size: 0.82rem;
    }

    .qty-input {
        width: 44px;
        font-size: 0.9rem;
    }

    .qty-btn {
        width: 30px;
        height: 30px;
        font-size: 13px;
    }

    .discount-percent {
        font-size: 11px;
        padding: 3px 6px;
    }

    .mobile-summary-card {
        padding: 12px;
    }

    .mobile-summary-label,
    .mobile-summary-value {
        font-size: 0.88rem;
    }

    .mobile-summary-grand .mobile-summary-label,
    .mobile-summary-grand .mobile-summary-value {
        font-size: 0.96rem;
    }

    #cart-products-table tbody img {
        width: 64px;
        height: 64px;
    }
}