/* Dark / Light theme — التطبيق ككل */
/* يتم تطبيق الوضع الداكن بإضافة data-theme="dark" على عنصر html */

/* ========== البرنامج الرئيسي (Shared Layout) ========== */
html[data-theme="dark"] body {
    background-color: #1a1d21;
    color: #e4e6eb;
}
html[data-theme="dark"] .sidebar {
    background: #242628;
    border-left-color: #3a3d42;
}
html[data-theme="dark"] .sidebar-section {
    border-bottom-color: #3a3d42;
}
html[data-theme="dark"] .sidebar-section-title {
    color: #7fc9a4;
}
html[data-theme="dark"] .sidebar a {
    color: #e4e6eb;
}
html[data-theme="dark"] .sidebar a:hover {
    background: #3a3d42;
    color: #7fc9a4;
}
html[data-theme="dark"] .sidebar a.active {
    background: rgba(26, 139, 92, 0.25);
    color: #7fc9a4;
}
html[data-theme="dark"] .sidebar a i {
    color: #5db8d4;
}
html[data-theme="dark"] .sidebar .home-link {
    background: linear-gradient(135deg, #1a8b5c 0%, #2d9bb5 100%);
    color: white !important;
}
html[data-theme="dark"] .sidebar .home-link:hover {
    background: #2d3748 !important;
    color: #7fc9a4 !important;
}
html[data-theme="dark"] .sidebar .home-link:hover i {
    color: #7fc9a4 !important;
}
html[data-theme="dark"] .expand-icon {
    color: #9ca3af;
}
html[data-theme="dark"] .sidebar-section.active .expand-icon {
    color: #7fc9a4;
}
html[data-theme="dark"] .card {
    background: #242628;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    border: 1px solid #3a3d42;
}
html[data-theme="dark"] .card-header {
    background: #2d3136;
    border-bottom-color: #3a3d42;
    color: #e4e6eb;
}
html[data-theme="dark"] .card-body {
    background: #242628;
    color: #e4e6eb;
}
/* خلفية الجدول بالكامل (فواتير البيع وكل الشاشات) */
html[data-theme="dark"] .table,
html[data-theme="dark"] .table tbody,
html[data-theme="dark"] .table-responsive {
    background-color: #242628 !important;
}
html[data-theme="dark"] .table tbody tr {
    background-color: #242628;
}
html[data-theme="dark"] .table thead th {
    background: #2d3136 !important;
    border-bottom-color: #3a3d42;
    border-color: #3a3d42;
    color: #e4e6eb;
}
html[data-theme="dark"] .table tbody td,
html[data-theme="dark"] .table tfoot td {
    background-color: #242628 !important;
    border-bottom-color: #3a3d42;
    border-color: #3a3d42;
    color: #e4e6eb;
}
html[data-theme="dark"] .table tbody tr:hover td {
    background-color: #2d3136 !important;
}
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-control-sm,
html[data-theme="dark"] .form-select {
    background-color: #2d3136 !important;
    border-color: #3a3d42 !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-control-sm:focus,
html[data-theme="dark"] .form-select:focus {
    background-color: #2d3136 !important;
    border-color: #1a8b5c !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] .form-control-sm::placeholder {
    color: #9ca3af !important;
}
html[data-theme="dark"] .search-box {
    background: #242628;
    border: 1px solid #3a3d42;
}
html[data-theme="dark"] .main-content {
    color: #e4e6eb;
}
html[data-theme="dark"] .sidebar .sidebar-close {
    color: #9ca3af;
}
html[data-theme="dark"] .text-muted {
    color: #9ca3af !important;
}
html[data-theme="dark"] .bg-light {
    background-color: #2d3136 !important;
}
html[data-theme="dark"] .border,
html[data-theme="dark"] .border-bottom {
    border-color: #3a3d42 !important;
}

/* ========== فاتورة البيع و شاشات الفورم (table-light, bg-warning, table-primary) ========== */
html[data-theme="dark"] .table-light,
html[data-theme="dark"] .table thead.table-light th,
html[data-theme="dark"] .table tfoot.table-light td,
html[data-theme="dark"] .table tfoot.table-light th {
    background: #2d3136 !important;
    border-color: #3a3d42 !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] .card.border-warning {
    border-color: #6b5a2a !important;
}
html[data-theme="dark"] .card-header.bg-warning {
    background: #4a3f1a !important;
    border-color: #6b5a2a !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] .card-header.bg-warning .badge.bg-dark {
    background: #3a3d42 !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] .table-warning,
html[data-theme="dark"] .table-warning th,
html[data-theme="dark"] .table-warning td {
    background: #4a3f1a !important;
    border-color: #3a3d42 !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] .card.border-primary {
    border-color: #2d4a5c !important;
}
html[data-theme="dark"] .card.border-primary .card-body {
    background: #242628 !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] .table-primary,
html[data-theme="dark"] .table-primary th,
html[data-theme="dark"] .table-primary td {
    background: #1a3040 !important;
    border-color: #3a3d42 !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] .form-control[readonly],
html[data-theme="dark"] .form-control-sm[readonly],
html[data-theme="dark"] input.form-control[readonly],
html[data-theme="dark"] input.form-control-sm[readonly] {
    background-color: #2d3136 !important;
    border-color: #3a3d42 !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] .form-check-label {
    color: #e4e6eb;
}
html[data-theme="dark"] .page-header {
    color: #e4e6eb;
}
html[data-theme="dark"] .page-header .btn {
    border-color: #3a3d42;
}

/* ========== دارك مود لكل الشاشات — خلفيات و نصوص ========== */
/* bg-white: كروت وعناوين بيضاء */
html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .card-header.bg-white,
html[data-theme="dark"] .card-footer.bg-white {
    background-color: #2d3136 !important;
    border-color: #3a3d42 !important;
    color: #e4e6eb !important;
}
/* thead.bg-light و أي bg-light داخل الجداول */
html[data-theme="dark"] thead.bg-light th,
html[data-theme="dark"] thead.bg-light td,
html[data-theme="dark"] .table thead.bg-light th {
    background: #2d3136 !important;
    border-color: #3a3d42 !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] td.bg-light,
html[data-theme="dark"] tr.bg-light td,
html[data-theme="dark"] .fw-bold.bg-light,
html[data-theme="dark"] .font-weight-bold.bg-light {
    background: #2d3136 !important;
    color: #e4e6eb !important;
}
/* table-secondary, table-success, table-info, table-danger */
html[data-theme="dark"] .table-secondary,
html[data-theme="dark"] .table-secondary th,
html[data-theme="dark"] .table-secondary td {
    background: #3a3d42 !important;
    border-color: #3a3d42 !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] .table-success,
html[data-theme="dark"] .table-success th,
html[data-theme="dark"] .table-success td {
    background: #1a3d2a !important;
    border-color: #3a3d42 !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] .table-info,
html[data-theme="dark"] .table-info th,
html[data-theme="dark"] .table-info td {
    background: #1a3040 !important;
    border-color: #3a3d42 !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] .table-danger,
html[data-theme="dark"] .table-danger th,
html[data-theme="dark"] .table-danger td {
    background: #3d1f1f !important;
    border-color: #3a3d42 !important;
    color: #e4e6eb !important;
}
/* table-dark في الدارك مود يبقى أغمق شوية */
html[data-theme="dark"] .table-dark,
html[data-theme="dark"] .table thead.table-dark th {
    background: #1e2124 !important;
    border-color: #3a3d42 !important;
    color: #e4e6eb !important;
}
/* table-striped: خطوط متناوبة */
html[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(45, 49, 54, 0.5);
}
html[data-theme="dark"] .table-striped tbody tr:nth-of-type(even) {
    background-color: rgba(36, 38, 40, 0.5);
}
/* text-dark في الدارك مود يتحول لفاتح عشان ميبقاش خط أبيض على خلفية بيضاء */
html[data-theme="dark"] .text-dark {
    color: #e4e6eb !important;
}
html[data-theme="dark"] .text-secondary {
    color: #9ca3af !important;
}
/* العناوين و التسميات */
html[data-theme="dark"] .form-label,
html[data-theme="dark"] label,
html[data-theme="dark"] .card-title,
html[data-theme="dark"] h1, html[data-theme="dark"] h2, html[data-theme="dark"] h3,
html[data-theme="dark"] h4, html[data-theme="dark"] h5, html[data-theme="dark"] h6 {
    color: #e4e6eb !important;
}
html[data-theme="dark"] small {
    color: #9ca3af !important;
}
/* table-borderless */
html[data-theme="dark"] .table-borderless td,
html[data-theme="dark"] .table-borderless th {
    color: #e4e6eb;
}
/* كروت و فورمات بخلفية فاتحة */
html[data-theme="dark"] .card.bg-light {
    background: #242628 !important;
    border-color: #3a3d42 !important;
}
html[data-theme="dark"] .list-group-item.bg-light {
    background: #2d3136 !important;
    color: #e4e6eb !important;
    border-color: #3a3d42 !important;
}
/* badges: لو فيها text-dark نعدّل النص */
html[data-theme="dark"] .badge.bg-warning.text-dark,
html[data-theme="dark"] .badge.bg-info.text-dark {
    color: #e4e6eb !important;
}
html[data-theme="dark"] .badge.bg-light.text-dark {
    background: #2d3136 !important;
    color: #e4e6eb !important;
    border-color: #3a3d42 !important;
}
/* modal */
html[data-theme="dark"] .modal-content {
    background: #242628;
    border-color: #3a3d42;
    color: #e4e6eb;
}
html[data-theme="dark"] .modal-header {
    background: #2d3136;
    border-bottom-color: #3a3d42;
    color: #e4e6eb;
}
html[data-theme="dark"] .modal-footer {
    background: #2d3136;
    border-top-color: #3a3d42;
}
html[data-theme="dark"] .modal-body {
    color: #e4e6eb;
}
/* disabled inputs */
html[data-theme="dark"] .form-control:disabled {
    background: #1e2124 !important;
    color: #9ca3af !important;
    border-color: #3a3d42 !important;
}
/* select option background (بعض المتصفحات) */
html[data-theme="dark"] select.form-control option,
html[data-theme="dark"] select.form-select option {
    background: #242628;
    color: #e4e6eb;
}
/* روابط داخل المحتوى */
html[data-theme="dark"] .main-content a:not(.btn) {
    color: #7fc9a4;
}
html[data-theme="dark"] .main-content a:not(.btn):hover {
    color: #9fd9b4;
}
/* أي div أو section بخلفية بيضاء من inline أو كلاس */
html[data-theme="dark"] [style*="background-color: white"],
html[data-theme="dark"] [style*="background: white"] {
    background-color: #242628 !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] [style*="background-color: #fff"],
html[data-theme="dark"] [style*="background: #fff"] {
    background-color: #242628 !important;
    color: #e4e6eb !important;
}
/* تجاوز أي خلفية فاتحة مضمنة في الحقول (مثل #e9ecef في فاتورة البيع) */
html[data-theme="dark"] input[style*="background"],
html[data-theme="dark"] .form-control[style*="background"],
html[data-theme="dark"] .form-control-sm[style*="background"] {
    background-color: #2d3136 !important;
    color: #e4e6eb !important;
}

/* ========== الرئيسية (Home/Index) — كروت الجرافات و التدفق و الأزرار ========== */
html[data-theme="dark"] .chart-card {
    background: #242628 !important;
    border-color: #3a3d42 !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] .chart-card h5,
html[data-theme="dark"] .chart-card .fw-bold {
    color: #e4e6eb !important;
}
html[data-theme="dark"] .flow-step {
    background: linear-gradient(135deg, #2d3136 0%, #242628 100%) !important;
    border-color: #3a3d42 !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] .flow-step:hover {
    background: #3a3d42 !important;
    border-color: #1a8b5c !important;
    color: #7fc9a4 !important;
}
html[data-theme="dark"] .flow-arrow {
    color: #6b7280 !important;
}
html[data-theme="dark"] .quick-action-btn {
    background: #2d3136 !important;
    border-color: #3a3d42 !important;
    color: #e4e6eb !important;
}
html[data-theme="dark"] .quick-action-btn:hover {
    background: rgba(26, 139, 92, 0.2) !important;
    border-color: #1a8b5c !important;
    color: #7fc9a4 !important;
}

/* ========== بوابة المناديب و بوابة العملاء ========== */
html[data-theme="dark"] .navbar {
    background: linear-gradient(135deg, #1a8b5c 0%, #2d9bb5 100%) !important;
}
html[data-theme="dark"] .main-content {
    background-color: #1a1d21;
    color: #e4e6eb;
}
html[data-theme="dark"] .card {
    background: #242628;
    border: 1px solid #3a3d42;
}
html[data-theme="dark"] .card-header {
    background: #2d3136;
    border-bottom-color: #3a3d42;
    color: #e4e6eb;
}
html[data-theme="dark"] footer {
    background: #242628;
    border-top-color: #3a3d42;
    color: #9ca3af;
}
html[data-theme="dark"] .table thead th {
    background: #2d3136;
    color: #e4e6eb;
    border-color: #3a3d42;
}
html[data-theme="dark"] .table tbody td {
    color: #e4e6eb;
    border-color: #3a3d42;
}
html[data-theme="dark"] .table tbody tr:hover {
    background-color: #2d3136;
}
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
    background: #2d3136;
    border-color: #3a3d42;
    color: #e4e6eb;
}
html[data-theme="dark"] .form-control:focus {
    background: #2d3136;
    color: #e4e6eb;
}
html[data-theme="dark"] .list-group-item {
    background: #242628;
    border-color: #3a3d42;
    color: #e4e6eb;
}
html[data-theme="dark"] .dropdown-menu {
    background: #242628;
    border-color: #3a3d42;
}
html[data-theme="dark"] .dropdown-item {
    color: #e4e6eb;
}
html[data-theme="dark"] .dropdown-item:hover {
    background: #2d3136;
    color: #7fc9a4;
}
html[data-theme="dark"] .alert-warning {
    background: #4a3f1a;
    border-color: #6b5a2a;
    color: #e4e6eb;
}
html[data-theme="dark"] .alert-info {
    background: #1a3040;
    border-color: #2d4a5c;
    color: #e4e6eb;
}
html[data-theme="dark"] .input-group-text {
    background: #2d3136;
    border-color: #3a3d42;
    color: #e4e6eb;
}

/* ========== صفحات تسجيل الدخول (Login / AgentLogin / CustomerLogin) ========== */
html[data-theme="dark"] body {
    background-color: #1a1d21;
    color: #e4e6eb;
}
/* اللوجن الرئيسي (Login/Index) */
html[data-theme="dark"] .main-container {
    background: #242628;
    box-shadow: 0 2px 20px rgba(0,0,0,0.4);
    border: 1px solid #3a3d42;
}
html[data-theme="dark"] .login-content {
    border-color: #3a3d42;
}
html[data-theme="dark"] .form-side .form-group label {
    color: #e4e6eb;
}
html[data-theme="dark"] .logo-side {
    border-right-color: #3a3d42;
    border-bottom-color: #3a3d42;
}
html[data-theme="dark"] .logo-side p {
    color: #5db8d4;
}
html[data-theme="dark"] .login-footer {
    background: #2d3136;
    color: #9ca3af;
    border-top-color: #3a3d42;
}
html[data-theme="dark"] .error-message {
    background: #3d1f1f;
    color: #f28b8b;
    border-right-color: #c62828;
}
/* كروت لوجن بوابة المناديب والعملاء */
html[data-theme="dark"] .login-card {
    background: #242628;
    border: 1px solid #3a3d42;
    box-shadow: 0 4px 6px rgba(0,0,0,0.4);
}
html[data-theme="dark"] .login-header h3,
html[data-theme="dark"] .login-header i {
    color: #7fc9a4;
}
html[data-theme="dark"] .login-header .text-muted {
    color: #9ca3af !important;
}
/* زر الثيم على صفحات اللوجن */
.btn-theme-toggle-login {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 1000;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background 0.2s;
}
.btn-theme-toggle-login:hover {
    background: rgba(255,255,255,0.35);
    color: white;
}
