/**
 * OPT Global Style - IBM Plex Sans Arabic
 * Modern Arabic UI for the entire system
 */

/* Import IBM Plex Sans Arabic Font */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&display=swap');

/* ===== GLOBAL FONT OVERRIDE ===== */
html,
body,
* {
    font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, Arial, sans-serif !important;
}

body {
    font-size: 15px;
    line-height: 1.6;
    color: #1a1a2e;
    background-color: #f8f9fc;
}

/* ===== HEADINGS ===== */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    font-weight: 600;
    color: #1a1a2e;
}

h1, .h1 { font-size: 28px; }
h2, .h2 { font-size: 24px; }
h3, .h3 { font-size: 20px; }
h4, .h4 { font-size: 18px; }
h5, .h5 { font-size: 16px; }
h6, .h6 { font-size: 14px; }

/* ===== CARDS ===== */
.card {
    background: #fff;
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 16px 24px;
    font-weight: 600;
    font-size: 16px;
}

.card-body {
    padding: 24px;
}

.card-footer {
    background: #f8f9fc;
    border-top: 1px solid #e9ecef;
    padding: 16px 24px;
}

/* ===== BUTTONS ===== */
.btn {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    font-weight: 500;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, #5b4cdb 0%, #4a3cc9 100%);
    color: #fff;
    box-shadow: 0 2px 6px rgba(91, 76, 219, 0.3);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, #4a3cc9 0%, #3a2db9 100%);
    box-shadow: 0 4px 12px rgba(91, 76, 219, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f1f3f4;
    color: #1a1a2e;
}

.btn-secondary:hover {
    background: #e2e6ea;
}

.btn-success {
    background: linear-gradient(135deg, #00a854 0%, #00914a 100%);
    box-shadow: 0 2px 6px rgba(0, 168, 84, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #f5222d 0%, #d91a25 100%);
    box-shadow: 0 2px 6px rgba(245, 34, 45, 0.3);
}

.btn-warning {
    background: linear-gradient(135deg, #faad14 0%, #e8a012 100%);
    color: #1a1a2e;
}

.btn-info {
    background: linear-gradient(135deg, #1890ff 0%, #0d7ee8 100%);
}

.btn-outline-primary {
    border: 2px solid #5b4cdb;
    color: #5b4cdb;
    background: transparent;
}

.btn-outline-primary:hover {
    background: #5b4cdb;
    color: #fff;
}

.btn-lg {
    padding: 12px 28px;
    font-size: 16px;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* ===== FORM CONTROLS ===== */
.form-control,
.form-select,
select.form-control,
input.form-control,
textarea.form-control {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    color: #1a1a2e;
    background-color: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus,
.form-select:focus {
    border-color: #5b4cdb;
    box-shadow: 0 0 0 3px rgba(91, 76, 219, 0.15);
    outline: none;
}

.form-control::placeholder {
    color: #adb5bd;
}

.form-label,
label {
    font-weight: 500;
    color: #666;
    margin-bottom: 8px;
    font-size: 13px;
}

.form-group {
    margin-bottom: 20px;
}

/* Select2 Override */
.select2-container--default .select2-selection--single {
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    height: 42px !important;
    padding: 6px 10px !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    color: #1a1a2e !important;
    line-height: 28px !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 40px !important;
}

.select2-dropdown {
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.select2-results__option {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    padding: 10px 14px !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #5b4cdb !important;
}

/* ===== TABLES ===== */
.table {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    background: #f8f9fc;
    border-bottom: 2px solid #e9ecef;
    font-weight: 600;
    color: #666;
    padding: 14px 16px;
    font-size: 13px;
    text-transform: none;
}

.table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f3f4;
    vertical-align: middle;
}

.table tbody tr:hover {
    background: #fafbfc;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: #fafbfc;
}

/* DataTables Override */
.dataTables_wrapper {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    padding: 16px 0;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    margin: 0 3px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #5b4cdb !important;
    border-color: #5b4cdb !important;
    color: #fff !important;
}

/* ===== SIDEBAR ===== */
.sidebar,
#sidebar,
.left-menu,
.sidebar-menu {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
}

.sidebar-menu li a {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    font-size: 14px;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 8px;
    margin: 2px 8px;
    transition: all 0.2s;
}

.sidebar-menu li a:hover {
    background: rgba(91, 76, 219, 0.1);
}

.sidebar-menu li.active > a {
    background: linear-gradient(135deg, #5b4cdb 0%, #4a3cc9 100%);
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(91, 76, 219, 0.3);
}

.sidebar-menu li a i,
.sidebar-menu li a svg {
    margin-left: 10px;
}

/* ===== NAVBAR / HEADER ===== */
.navbar,
.top-header,
.header,
#header {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* ===== MODALS ===== */
.modal-content {
    border: none;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid #e9ecef;
    padding: 20px 24px;
}

.modal-title {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    font-weight: 600;
    font-size: 18px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid #e9ecef;
    padding: 16px 24px;
}

.modal-backdrop.show {
    opacity: 0.5;
}

/* ===== BADGES ===== */
.badge {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
}

.badge-primary, .bg-primary {
    background: #5b4cdb !important;
}

.badge-success, .bg-success {
    background: #00a854 !important;
}

.badge-danger, .bg-danger {
    background: #f5222d !important;
}

.badge-warning, .bg-warning {
    background: #faad14 !important;
    color: #1a1a2e !important;
}

.badge-info, .bg-info {
    background: #1890ff !important;
}

.badge-secondary, .bg-secondary {
    background: #6c757d !important;
}

/* ===== ALERTS ===== */
.alert {
    border: none;
    border-radius: 10px;
    padding: 16px 20px;
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
}

.alert-success {
    background: #f6ffed;
    border-right: 4px solid #00a854;
    color: #00a854;
}

.alert-danger {
    background: #fff2f0;
    border-right: 4px solid #f5222d;
    color: #f5222d;
}

.alert-warning {
    background: #fffbe6;
    border-right: 4px solid #faad14;
    color: #d48806;
}

.alert-info {
    background: #e6f7ff;
    border-right: 4px solid #1890ff;
    color: #1890ff;
}

/* ===== DROPDOWN ===== */
.dropdown-menu {
    border: none;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    padding: 8px;
}

.dropdown-item {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    padding: 10px 16px;
    border-radius: 6px;
    transition: background 0.15s;
}

.dropdown-item:hover {
    background: #f8f9fc;
}

.dropdown-item.active,
.dropdown-item:active {
    background: #5b4cdb;
    color: #fff;
}

/* ===== PAGINATION ===== */
.pagination {
    gap: 4px;
}

.page-link {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    color: #1a1a2e;
    background: #f1f3f4;
}

.page-link:hover {
    background: #e2e6ea;
    color: #1a1a2e;
}

.page-item.active .page-link {
    background: #5b4cdb;
    color: #fff;
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 20px;
}

.breadcrumb-item {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    font-size: 14px;
}

.breadcrumb-item a {
    color: #5b4cdb;
}

.breadcrumb-item.active {
    color: #666;
}

/* ===== TABS / NAV PILLS ===== */
.nav-tabs {
    border-bottom: 2px solid #e9ecef;
}

.nav-tabs .nav-link {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    border: none;
    padding: 12px 20px;
    color: #666;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.nav-tabs .nav-link:hover {
    border-color: transparent;
    color: #5b4cdb;
}

.nav-tabs .nav-link.active {
    color: #5b4cdb;
    border-bottom-color: #5b4cdb;
    background: transparent;
}

.nav-pills .nav-link {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    border-radius: 8px;
    padding: 10px 20px;
    color: #666;
}

.nav-pills .nav-link.active {
    background: #5b4cdb;
    color: #fff;
}

/* ===== PROGRESS BAR ===== */
.progress {
    height: 8px;
    border-radius: 10px;
    background: #e9ecef;
}

.progress-bar {
    background: linear-gradient(135deg, #5b4cdb 0%, #4a3cc9 100%);
    border-radius: 10px;
}

/* ===== TOOLTIPS ===== */
.tooltip-inner {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    background: #1a1a2e;
    border-radius: 6px;
    padding: 8px 12px;
}

/* ===== LIST GROUP ===== */
.list-group-item {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    border: none;
    border-bottom: 1px solid #f1f3f4;
    padding: 14px 20px;
}

.list-group-item:last-child {
    border-bottom: none;
}

.list-group-item.active {
    background: #5b4cdb;
    border-color: #5b4cdb;
}

/* ===== PAGE TITLE ===== */
.page-title,
.page-header {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    margin-bottom: 24px;
}

.page-title h1,
.page-title h2,
.page-title h3,
.page-title h4 {
    font-weight: 600;
    margin: 0;
}

/* ===== WIDGET / STATS CARDS ===== */
.widget,
.stat-card,
.info-box {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.widget-title,
.stat-title {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
}

.widget-value,
.stat-value {
    font-size: 28px;
    font-weight: 600;
    color: #1a1a2e;
}

/* ===== CHARTS ===== */
.chart-container {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
}

/* ===== CUSTOM SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f3f4;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.card,
.modal-content {
    animation: fadeIn 0.3s ease-out;
}

/* ===== UTILITY CLASSES ===== */
.text-primary { color: #5b4cdb !important; }
.text-success { color: #00a854 !important; }
.text-danger { color: #f5222d !important; }
.text-warning { color: #faad14 !important; }
.text-info { color: #1890ff !important; }
.text-muted { color: #999 !important; }

.border-primary { border-color: #5b4cdb !important; }
.border-radius-lg { border-radius: 12px !important; }
.border-radius-xl { border-radius: 16px !important; }

.shadow-sm { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important; }
.shadow-md { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important; }
.shadow-lg { box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15) !important; }

/* ===== RTL SPECIFIC ===== */
[dir="rtl"] .dropdown-menu {
    text-align: right;
}

[dir="rtl"] .alert {
    border-right: none;
    border-left: 4px solid;
}

[dir="rtl"] .alert-success { border-left-color: #00a854; }
[dir="rtl"] .alert-danger { border-left-color: #f5222d; }
[dir="rtl"] .alert-warning { border-left-color: #faad14; }
[dir="rtl"] .alert-info { border-left-color: #1890ff; }

/* ===== HANDSONTABLE OVERRIDE ===== */
.handsontable {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
}

.handsontable th,
.handsontable td {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
}

/* ===== SUMMERNOTE OVERRIDE ===== */
.note-editor {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    border-radius: 8px !important;
    border: 1px solid #e0e0e0 !important;
}

.note-editor .note-editing-area .note-editable {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 768px) {
    .card-body {
        padding: 16px;
    }
    
    .btn {
        padding: 8px 16px;
    }
    
    h1, .h1 { font-size: 24px; }
    h2, .h2 { font-size: 20px; }
    h3, .h3 { font-size: 18px; }
}

/* ===== LOADING SPINNER OPTIMIZATION ===== */
/* تحسين سرعة ظهور واختفاء علامة التحميل */

.app-loader,
.circle-notch,
[class*="loading"] {
    transition: opacity 0.1s ease-out !important;
}

/* إخفاء spinner بسرعة عند وجود محتوى */
.modal-body:not(:empty) .app-loader,
.modal-body:not(:empty) .circle-notch {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* تحسين أداء الـ pre-loader */
#pre-loader {
    transition: opacity 0.2s ease-out !important;
}

#pre-loader.fade-out {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* تقليل حجم الـ spinner */
.modal .app-loader {
    transform: scale(0.8);
}

/* تسريع الـ animation */
.fa-spin {
    animation-duration: 0.8s !important;
}

@keyframes optimized-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.circle-notch svg,
.app-loader svg {
    animation: optimized-spin 0.8s linear infinite !important;
}
