/* ========================================
   Behavior Monitoring Module - UI Enhancements
   تطوير واجهة موديول مراقبة السلوكيات
   (كروت النظرة العامة بنفس أسلوب قائمة المخالفات)
   ======================================== */

/* Cards */
.behavior-overview-card .card-header,
.behavior-form-card .card-header,
.behavior-filters-card .card-header {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(59, 130, 246, 0.06));
}

[data-theme="dark"] .behavior-overview-card .card-header,
[data-theme="dark"] .behavior-form-card .card-header,
[data-theme="dark"] .behavior-filters-card .card-header {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(59, 130, 246, 0.12));
}

/* Overview stats — صف واحد (5 كروت)، نفس تدرجات/حدود المخالفات */
.behavior-overview-stats-scroller {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
}

.behavior-overview-stats {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: stretch;
    gap: 1rem;
    width: 100%;
}

.behavior-overview-stats .behavior-stat {
    flex: 1 1 0;
    min-width: 11rem;
    border-radius: 12px;
    padding: 1.25rem 1.35rem;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.behavior-overview-stats .behavior-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.behavior-stat-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.behavior-stat-caption {
    margin-bottom: 0.35rem !important;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.behavior-stat-value {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.01em;
}

.behavior-stat-fa {
    flex-shrink: 0;
    font-size: 1.35rem;
    opacity: 0.95;
}

/* إجمالي — وردي/أحمر مثل «إجمالي المخالفات» */
.behavior-stat-total {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 1px solid #fca5a5;
}

.behavior-stat-total .behavior-stat-value {
    color: #b91c1c;
}

.behavior-stat-total .behavior-stat-fa {
    color: #dc2626;
}

/* موظفين — أزرق مثل «مخالفات الموظفين» */
.behavior-stat-employees {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border: 1px solid #93c5fd;
}

.behavior-stat-employees .behavior-stat-value {
    color: #1d4ed8;
}

.behavior-stat-employees .behavior-stat-fa {
    color: #2563eb;
}

/* مقاولين — خوخي مثل «مخالفات المقاولين» */
.behavior-stat-contractors {
    background: linear-gradient(135deg, #ffedd5 0%, #fed7aa 100%);
    border: 1px solid #fdba74;
}

.behavior-stat-contractors .behavior-stat-value {
    color: #c2410c;
}

.behavior-stat-contractors .behavior-stat-fa {
    color: #ea580c;
}

/* سلبي — أحمر أوضح من بطاقة الإجمالي */
.behavior-stat-negative {
    background: linear-gradient(135deg, #fecaca 0%, #fca5a5 100%);
    border: 1px solid #f87171;
}

.behavior-stat-negative .behavior-stat-value {
    color: #991b1b;
}

.behavior-stat-negative .behavior-stat-fa {
    color: #b91c1c;
}

/* إيجابي — أخضر مثل «إجمالي القيمة المالية» في المخالفات */
.behavior-stat-positive {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    border: 1px solid #86efac;
}

.behavior-stat-positive .behavior-stat-value {
    color: #15803d;
}

.behavior-stat-positive .behavior-stat-fa {
    color: #16a34a;
}

[data-theme="dark"] .behavior-overview-stats .behavior-stat {
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .behavior-stat-caption {
    color: rgba(226, 232, 240, 0.88);
}

.behavior-dynamic-filter-wrap {
    border-radius: 14px;
    border: 1px solid rgba(37, 99, 235, 0.16);
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(255, 255, 255, 0.98));
}

.behavior-filter-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.75rem 0.85rem;
    border: 1px dashed rgba(37, 99, 235, 0.26);
    border-radius: 12px;
    margin-bottom: 0.9rem;
    background: rgba(255, 255, 255, 0.72);
}

.behavior-filter-topbar-title {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #475569;
    font-size: 0.84rem;
    font-weight: 600;
}

/* شريط فلتر احترافي أعلى الجداول (موظفين / مقاولين) */
.behavior-filters-toolbar {
    background: #ffffff;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
    direction: rtl;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.behavior-filters-toolbar::-webkit-scrollbar {
    height: 4px;
}

.behavior-filters-toolbar::-webkit-scrollbar-track {
    background: transparent;
}

.behavior-filters-toolbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.behavior-filters-toolbar .bf-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: nowrap;
    width: 100%;
    min-width: max-content;
}

.behavior-filters-toolbar .bf-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.behavior-filters-toolbar .bf-field--search {
    flex: 2.2;
    min-width: 200px;
}

.behavior-filters-toolbar .bf-field--select {
    flex: 1;
    min-width: 118px;
}

.behavior-filters-toolbar .bf-field--date {
    flex: 0 0 138px;
    min-width: 130px;
}

.behavior-filters-toolbar .bf-field--sort {
    flex: 0 0 132px;
    min-width: 124px;
}

.behavior-filters-toolbar .bf-field--actions {
    flex: 0 0 auto;
    padding-bottom: 0;
}

.behavior-filters-toolbar .bf-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    white-space: nowrap;
    margin: 0;
}

.behavior-filters-toolbar .bf-label i {
color: #2563eb;
    font-size: 11px;
}

.behavior-filters-toolbar .bf-input {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    background: #f8fafc;
    color: #0f172a;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    text-overflow: ellipsis;
}

.behavior-filters-toolbar .bf-input:hover {
    background: #ffffff;
    border-color: #94a3b8;
}

.behavior-filters-toolbar .bf-input:focus {
    outline: none;
    background: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.behavior-filters-toolbar .bf-search-wrap {
    position: relative;
}

.behavior-filters-toolbar .bf-search-wrap .bf-input {
    padding-right: 34px;
}

.behavior-filters-toolbar .bf-search-icon {
    position: absolute;
    top: 50%;
    right: 11px;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 12px;
    pointer-events: none;
}

.behavior-filters-toolbar .bf-reset-btn {
    height: 36px;
    padding: 0 14px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.behavior-filters-toolbar .bf-reset-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #94a3b8;
    transform: translateY(-1px);
}

[data-theme="dark"] .behavior-filters-toolbar {
    background: rgba(15, 23, 42, 0.55);
    border-color: rgba(148, 163, 184, 0.22);
    box-shadow: none;
}

[data-theme="dark"] .behavior-filters-toolbar .bf-label {
    color: #cbd5e1;
}

[data-theme="dark"] .behavior-filters-toolbar .bf-input {
    background: rgba(30, 41, 59, 0.85);
    border-color: rgba(148, 163, 184, 0.28);
    color: #e2e8f0;
}

[data-theme="dark"] .behavior-filters-toolbar .bf-input:hover,
[data-theme="dark"] .behavior-filters-toolbar .bf-input:focus {
    background: rgba(30, 41, 59, 1);
    border-color: #93c5fd;
}

[data-theme="dark"] .behavior-filters-toolbar .bf-reset-btn {
    background: rgba(51, 65, 85, 0.9);
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.28);
}

.behavior-active-filter-chips {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 10px;
    min-height: 26px;
}

.behavior-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.28rem 0.62rem;
    border-radius: 999px;
    border: 1px solid rgba(37, 99, 235, 0.26);
    background: rgba(239, 246, 255, 0.8);
    color: #1d4ed8;
    font-size: 0.74rem;
    line-height: 1.2;
}

.behavior-filter-chip.behavior-filter-chip-muted {
    border-color: rgba(148, 163, 184, 0.28);
    background: rgba(248, 250, 252, 0.88);
    color: #64748b;
}

@media (max-width: 900px) {
    .behavior-filters-toolbar .bf-row {
        flex-wrap: wrap;
        min-width: 0;
    }

    .behavior-filters-toolbar .bf-field--search {
        flex: 1 1 100%;
        min-width: 0;
    }

    .behavior-filters-toolbar .bf-field--select,
    .behavior-filters-toolbar .bf-field--date,
    .behavior-filters-toolbar .bf-field--sort {
        flex: 1 1 calc(50% - 8px);
        min-width: 140px;
    }
}

/* Form wrapper color accents */
.behavior-form-wrapper {
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1rem;
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.05), rgba(255, 255, 255, 0));
}

[data-theme="dark"] .behavior-form-wrapper {
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.12), rgba(0, 0, 0, 0));
}

.behavior-form-wrapper[data-behavior-type="إيجابي"] {
    border-color: rgba(16, 185, 129, 0.35);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.06);
}

.behavior-form-wrapper[data-behavior-type="سلبي"] {
    border-color: rgba(239, 68, 68, 0.35);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.06);
}

/* Modal header theming */
.behavior-modal .modal-header {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(59, 130, 246, 0.06));
}

.behavior-modal[data-behavior-type="إيجابي"] .modal-header {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.14), rgba(59, 130, 246, 0.08));
}

.behavior-modal[data-behavior-type="سلبي"] .modal-header {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.14), rgba(245, 158, 11, 0.08));
}

[data-theme="dark"] .behavior-modal .modal-header {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(59, 130, 246, 0.12));
}

[data-theme="dark"] .behavior-modal[data-behavior-type="إيجابي"] .modal-header {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(59, 130, 246, 0.14));
}

[data-theme="dark"] .behavior-modal[data-behavior-type="سلبي"] .modal-header {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.22), rgba(245, 158, 11, 0.14));
}
