/* ============================================ */
/* includes/theme-helper.css - كلاس الثيم الموحد */
/* ============================================ */

/* ===== متغيرات الثيم الأساسية ===== */
:root {
    /* ألوان النظام */
    --theme-primary: <?= Config::$thirdColor ?>;
    --theme-secondary: <?= Config::$secondaryColor ?>;
    --theme-dark: <?= Config::$primaryColor ?>;
    --theme-bg-light: <?= Config::$bodyBackgroundColor ?>;
    
    /* الوضع الفاتح */
    --theme-text: #2c3e50;
    --theme-text-muted: #6c757d;
    --theme-bg-card: #ffffff;
    --theme-bg-header: #ffffff;
    --theme-border: #e9ecef;
    --theme-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --theme-shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.08);
    --theme-input-bg: #ffffff;
    --theme-input-border: #ffc107;
    --theme-input-focus: #0d6efd;
    
    /* ألوان الجدول - الوضع الفاتح */
    --table-bg-odd: #ffffff;
    --table-bg-even: #e8f3fd;
    --table-bg-hover: #d6e9ff;
    --table-header-bg: #cfe2ff;
    --table-header-text: #0d47a1;
    --table-border: #dee2e6;
    --table-text: #212529;
    --table-label-color: #007bff;
    --table-mobile-bg: #ffffff;
    --table-mobile-border: #dee2e6;
    
    /* الألوان المساعدة */
    --theme-success: #28a745;
    --theme-danger: #dc3545;
    --theme-warning: #ffc107;
    --theme-info: #17a2b8;
}

/* ===== الوضع الليلي ===== */
[data-theme="dark"] {
    --theme-text: #e8e8ef;
    --theme-text-muted: #a0a0b0;
    --theme-bg-card: #1e1e2a;
    --theme-bg-header: #1a1a2e;
    --theme-border: #2a2a45;
    --theme-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    --theme-shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.3);
    --theme-input-bg: #2a2a35;
    --theme-input-border: #4a4a55;
    --theme-input-focus: #4e73df;
    
    /* ألوان الجدول - الوضع الليلي */
    --table-bg-odd: #1e1e2a;
    --table-bg-even: #252540;
    --table-bg-hover: #2d2d45;
    --table-header-bg: #0a0a15;
    --table-header-text: #5EEAD4;
    --table-border: #2a2a45;
    --table-text: #e8e8ef;
    --table-label-color: #5EEAD4;
    --table-mobile-bg: #1e1e2a;
    --table-mobile-border: #2a2a45;
    
    /* الألوان المساعدة */
    --theme-success: #1cc88a;
    --theme-danger: #e74c3c;
    --theme-warning: #f6c23e;
    --theme-info: #36b9cc;
}

/* ===== الجسم الرئيسي ===== */
body {
     background-color: var(--theme-bg-light) !important;
    font-family: 'Cairo', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== كلاس الثيم الرئيسي ===== */
.theme-wrapper {
    background-color: var(--theme-bg-light);
    color: var(--theme-text);
    transition: all 0.3s ease;
}

/* ===== خلفيات ===== */
.theme-bg-card {
    background-color: var(--theme-bg-card) !important;
}

.theme-bg-header {
    background-color: var(--theme-bg-header) !important;
}

/* ===== النصوص ===== */
.theme-text {
    color: var(--theme-text) !important;
}

.theme-text-muted {
    color: var(--theme-text-muted) !important;
}

.theme-text-primary {
    color: var(--theme-primary) !important;
}

.theme-text-secondary {
    color: var(--theme-secondary) !important;
}

/* ===== الحدود ===== */
.theme-border {
    border: 1px solid var(--theme-border) !important;
}

.theme-border-top {
    border-top: 1px solid var(--theme-border) !important;
}

.theme-border-bottom {
    border-bottom: 1px solid var(--theme-border) !important;
}

/* ===== الظلال ===== */
.theme-shadow {
    box-shadow: var(--theme-shadow) !important;
}

.theme-shadow-hover:hover {
    box-shadow: var(--theme-shadow-hover) !important;
}

/* ===== الحقول والإدخالات ===== */
.theme-input {
    background-color: var(--theme-input-bg) !important;
    border: 1px solid var(--theme-input-border) !important;
    color: var(--theme-text) !important;
    border-radius: 8px !important;
    padding: 8px 12px !important;
    transition: all 0.2s ease;
}

.theme-input:focus {
    border-color: var(--theme-input-focus) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(78, 115, 223, 0.15) !important;
}

.form-control,
.form-select {
    background-color: var(--theme-input-bg) !important;
    border-color: var(--theme-input-border) !important;
    color: var(--theme-text) !important;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--theme-input-focus) !important;
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25) !important;
}

.form-control::placeholder {
    color: var(--theme-text-muted) !important;
}

/* ===== الأزرار ===== */
.theme-btn-primary {
    background-color: var(--theme-secondary) !important;
    border-color: var(--theme-secondary) !important;
    color: white !important;
    border-radius: 8px !important;
    padding: 8px 16px !important;
    transition: all 0.2s ease;
}

.theme-btn-primary:hover {
    background-color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
    transform: translateY(-2px);
}

.theme-btn-secondary {
    background-color: var(--theme-text-muted) !important;
    border-color: var(--theme-text-muted) !important;
    color: white !important;
    border-radius: 8px !important;
    padding: 8px 16px !important;
}

.theme-btn-secondary:hover {
    background-color: #5a6268 !important;
    transform: translateY(-2px);
}

.btn-outline-secondary {
    color: var(--theme-text-muted) !important;
    border-color: var(--theme-border) !important;
}

.btn-outline-secondary:hover {
    background-color: var(--table-bg-even) !important;
    color: var(--theme-text) !important;
}

.btn-primary {
    background-color: var(--theme-success) !important;
    border-color: var(--theme-success) !important;
}

/* ===== البطاقات ===== */
.theme-card {
    background-color: var(--theme-bg-card) !important;
    border: 1px solid var(--theme-border) !important;
    border-radius: 16px !important;
    box-shadow: var(--theme-shadow) !important;
    overflow: hidden;
}

.theme-card-header {
    background-color: var(--theme-bg-header) !important;
    border-bottom: 1px solid var(--theme-border) !important;
    padding: 15px 20px !important;
}

.theme-card-body {
    padding: 20px !important;
}

.theme-card-footer {
    background-color: var(--theme-bg-header) !important;
    border-top: 1px solid var(--theme-border) !important;
    padding: 12px 20px !important;
}

/* ===== التبويبات (Tabs) ===== */
.theme-tabs {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--theme-border) !important;
    margin-bottom: 20px;
    list-style: none;
    padding: 0;
}

.theme-tab {
    color: var(--theme-text-muted) !important;
    background: transparent !important;
    border: none !important;
    padding: 10px 20px !important;
    font-weight: 500 !important;
    font-size: 0.95rem !important;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.theme-tab i {
    margin-left: 8px;
    font-size: 0.9rem;
}

.theme-tab:hover {
    color: var(--theme-secondary) !important;
    background-color: rgba(0, 168, 168, 0.05) !important;
}

.theme-tab.active {
    color: var(--theme-secondary) !important;
    background-color: transparent !important;
}

.theme-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: 0;
    width: 100%;
    height: 2px;
    background-color: var(--theme-secondary);
}

/* ===== محتوى التبويبات ===== */
.theme-tab-content {
    display: none;
    animation: themeFadeIn 0.3s ease;
}

.theme-tab-content.active {
    display: block;
}

@keyframes themeFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== مربعات المعلومات ===== */
.theme-info-box {
    background: var(--theme-bg-card) !important;
    border: 1px solid var(--theme-border) !important;
    border-radius: 14px !important;
    padding: 16px 18px !important;
    color: var(--theme-text) !important;
    font-weight: 600 !important;
    transition: all 0.2s ease;
}

.theme-info-box:hover {
    border-color: var(--theme-secondary) !important;
    box-shadow: var(--theme-shadow-hover) !important;
}

/* ===== شبكة المعلومات ===== */
.theme-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

@media (max-width: 768px) {
    .theme-info-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* ===== الروابط ===== */
.theme-link {
    color: var(--theme-secondary) !important;
    text-decoration: none;
    transition: all 0.2s ease;
}

.theme-link:hover {
    color: var(--theme-primary) !important;
    text-decoration: underline;
}

/* ===== الفواصل ===== */
.theme-hr {
    background-color: var(--theme-border) !important;
    height: 1px !important;
    border: none !important;
    margin: 20px 0 !important;
}

/* ===== الجدول الرئيسي (مثل responsive-table.css) ===== */
.table,
.responsive-table {
    background-color: transparent !important;
    width: 100%;
    border-collapse: collapse;
}

/* خلايا رأس الجدول */
.responsive-table thead tr th,
.responsive-table thead th,
.table thead th,
.table-primary th,
.thead-light th,
.table-primary {
    background-color: var(--table-header-bg) !important;
    color: var(--table-header-text) !important;
    border-bottom: 2px solid var(--table-border) !important;
}

/* جميع خلايا الجسم */
.responsive-table tbody tr td,
.table tbody tr td,
.table tbody td {
    color: var(--table-text) !important;
    border-bottom: 1px solid var(--table-border) !important;
}

/* الصفوف الفردية */
.responsive-table tbody tr:nth-child(odd) td,
.table tbody tr:nth-child(odd) td {
    background-color: var(--table-bg-odd) !important;
}

/* الصفوف الزوجية */
.responsive-table tbody tr:nth-child(even) td,
.table tbody tr:nth-child(even) td {
    background-color: var(--table-bg-even) !important;
}

/* تمرير الماوس */
.responsive-table tbody tr:hover td,
.table tbody tr:hover td {
    background-color: var(--table-bg-hover) !important;
}
/* ===== النص في حالة عدم وجود بيانات ===== */
.text-center.py-4,
.text-center.py-5 {
    color: var(--table-text) !important;
}

/* ===== البادجات ===== */
.badge.bg-success {
    background-color: var(--theme-success) !important;
    color: white !important;
}

.badge.bg-danger {
    background-color: var(--theme-danger) !important;
    color: white !important;
}

.badge.bg-primary {
    background-color: var(--theme-info) !important;
    color: white !important;
}

/* ===== الترقيم ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    flex-wrap: wrap;
}

.pagination .page-link {
    background-color: var(--theme-bg-card) !important;
    border: 1px solid var(--theme-border) !important;
    color: var(--theme-text) !important;
    border-radius: 8px !important;
    padding: 6px 12px !important;
    transition: all 0.2s ease;
}

.pagination .page-link:hover {
    background-color: var(--table-bg-even) !important;
    transform: translateY(-2px);
}

.pagination .page-item.active .page-link {
    background-color: var(--theme-secondary) !important;
    border-color: var(--theme-secondary) !important;
    color: white !important;
}

/* ===== عناصر أخرى ===== */
hr {
    background-color: var(--table-border) !important;
    opacity: 1;
}

.text-muted {
    color: #6c757d !important;
}

[data-theme="dark"] .text-muted {
    color: #a0a0b0 !important;
}

/* ===== تصميم الجوال ===== */
@media (max-width: 768px) {
    .responsive-table thead {
        display: none;
    }

    .responsive-table tbody tr {
        display: block;
        border: 1px solid var(--table-border);
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 10px;
        background-color: var(--table-mobile-bg) !important;
    }

    .responsive-table tbody tr td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 10px;
        border-bottom: 1px solid var(--table-mobile-border);
        text-align: left;
        background-color: transparent !important;
    }

    .responsive-table tbody tr td:last-child {
        border-bottom: none;
    }

    .responsive-table tbody tr td::before {
        content: attr(data-label);
        font-weight: bold;
        color: var(--table-label-color) !important;
        font-size: 0.85rem;
        min-width: 120px;
        text-align: right;
    }

    .responsive-table tbody tr:nth-child(odd) td,
    .responsive-table tbody tr:nth-child(even) td {
        background-color: transparent !important;
    }

    .responsive-table tbody tr:hover td {
        background-color: transparent !important;
    }

    .responsive-table input[type="checkbox"] {
        accent-color: var(--table-label-color);
    }

    .theme-actions {
        justify-content: center;
    }
}

/* ===== شريط التمرير ===== */
.table-responsive-wrapper::-webkit-scrollbar {
    height: 8px;
}

.table-responsive-wrapper::-webkit-scrollbar-track {
    background: var(--table-border);
    border-radius: 10px;
}

.table-responsive-wrapper::-webkit-scrollbar-thumb {
    background: var(--table-label-color);
    border-radius: 10px;
}

.theme-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.theme-scrollbar::-webkit-scrollbar-track {
    background: var(--theme-border);
    border-radius: 10px;
}

.theme-scrollbar::-webkit-scrollbar-thumb {
    background: var(--theme-secondary);
    border-radius: 10px;
}

.theme-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--theme-primary);
}

/* ===== تجاوز ألوان Bootstrap في الوضع الليلي ===== */
[data-theme="dark"] .table,
[data-theme="dark"] .table tbody,
[data-theme="dark"] .table tbody tr,
[data-theme="dark"] .table tbody td {
    background-color: transparent !important;
}

[data-theme="dark"] .table thead th,
[data-theme="dark"] .table-primary th {
    background-color: var(--table-header-bg) !important;
    color: var(--table-header-text) !important;
    border-bottom-color: var(--table-border) !important;
}

[data-theme="dark"] .table tbody td {
    color: var(--table-text) !important;
    border-bottom-color: var(--table-border) !important;
}

[data-theme="dark"] .card,
[data-theme="dark"] .card-header,
[data-theme="dark"] .card-body {
    background-color: var(--theme-bg-card) !important;
    border-color: var(--theme-border) !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: var(--theme-input-bg) !important;
    border-color: var(--theme-input-border) !important;
    color: var(--theme-text) !important;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    border-color: var(--theme-input-focus) !important;
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25) !important;
}

[data-theme="dark"] .btn-outline-secondary {
    color: #a0a0b0 !important;
    border-color: #2a2a45 !important;
}

[data-theme="dark"] .btn-outline-secondary:hover {
    background-color: #2a2a45 !important;
    color: #e8e8ef !important;
}

[data-theme="dark"] .page-link {
    background-color: var(--theme-bg-card) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}

[data-theme="dark"] .page-item.active .page-link {
    background-color: var(--theme-secondary) !important;
    border-color: var(--theme-secondary) !important;
    color: white !important;
}

[data-theme="dark"] .badge.bg-primary {
    background-color: var(--theme-info) !important;
}

[data-theme="dark"] hr {
    background-color: var(--table-border) !important;
}

[data-theme="dark"] .text-center.py-4 {
    color: var(--table-text) !important;
}

[data-theme="dark"] body {
    background-color: #121212 !important;
}
