/* ═══════════════════════════════════════════════════════════
   تحسينات لوحة التحكم - خط آمن (بدون تعديل Views)
   ═══════════════════════════════════════════════════════════ */

/* 1) الخط العربي */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

body, .content-wrapper, .main-sidebar, .main-header .logo,
.main-header .navbar, .box, .table, .form-control, .btn,
h1, h2, h3, h4, h5, h6 {
    font-family: 'Tajawal', 'Segoe UI', Tahoma, Arial, sans-serif !important;
}

/* 2) الجداول */
.table { font-size: 14px; background: #fff; }
.table > thead > tr > th {
    background: #f4f6f9; font-weight: 700; color: #2c3e50;
    border-bottom: 2px solid #3c8dbc !important; white-space: nowrap;
}
.table > tbody > tr:hover { background: #f9fbfd; }

/* 3) البطاقات (Boxes) */
.box {
    border-radius: 8px; border-top-width: 3px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s ease;
}
.box:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.box-header { padding: 12px 15px; border-bottom: 1px solid #eee; }
.box-header .box-title { font-size: 16px; font-weight: 700; color: #2c3e50; }

/* 4) الأزرار */
.btn { border-radius: 6px; padding: 8px 16px; font-weight: 500; transition: all 0.2s ease; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 8px rgba(0,0,0,0.12); }
.btn-primary { background: #3c8dbc; border-color: #357ca5; }
.btn-primary:hover { background: #357ca5; }

/* 5) النماذج */
.form-control { border-radius: 6px; border: 1px solid #d2d6de; height: 38px; transition: border-color 0.2s, box-shadow 0.2s; }
.form-control:focus { border-color: #3c8dbc; box-shadow: 0 0 0 3px rgba(60,141,188,0.15); }
textarea.form-control { height: auto; min-height: 100px; }
label { font-weight: 600; color: #333; margin-bottom: 4px; }

/* 6) الشريط الجانبي */
.sidebar-menu > li > a { padding: 11px 15px; border-radius: 4px; margin: 2px 6px; transition: background 0.2s, color 0.2s; }
.sidebar-menu > li > a:hover { background: rgba(255,255,255,0.1); }

/* 7) العناوين */
.content-header > h1 { font-size: 24px; font-weight: 700; color: #2c3e50; margin-bottom: 15px; }

/* 8) الموبايل والتابلت (< 768px) */
@media (max-width: 768px) {
    .table-responsive { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
    .form-control, input, select, textarea { font-size: 16px !important; }
    .btn { padding: 10px 16px; font-size: 15px; }
    .content-header > h1 { font-size: 20px; }
    .box-header .box-title { font-size: 15px; }
    .content { padding: 10px !important; }
    .main-sidebar { width: 230px; }
    .table { font-size: 13px; }
}

/* 9) الموبايل جداً صغير (< 480px) */
@media (max-width: 480px) {
    .main-header .logo { width: 90px; font-size: 13px; padding: 10px 5px; }
    .content-header > h1 { font-size: 18px; }
    .btn { padding: 8px 12px; font-size: 14px; }
    .box { border-radius: 6px; }
}

/* 10) RTL Fixes */
.pull-right { float: left !important; }
.pull-left  { float: right !important; }

/* 11) Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #bdc3c7; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #95a5a6; }

/* 12) الطباعة */
@media print {
    .main-sidebar, .main-header, .main-footer, .no-print { display: none !important; }
    .content-wrapper { margin-right: 0 !important; }
}

/* ═══════════════════════════════════════════════════════════
   تحسينات GridView (جداول Yii2) — تُستخدم في كل الشاشات
   ═══════════════════════════════════════════════════════════ */

/* الحاوية الرئيسية */
.grid-view {
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* شريط الأدوات العلوي (فلاتر البحث) */
.grid-view .filters {
    background: #f8f9fc;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border: 1px solid #e9ecef;
}

.grid-view .filters input,
.grid-view .filters select {
    height: 34px;
    font-size: 13px;
}

/* جدول GridView */
.grid-view table {
    margin-bottom: 0;
}

.grid-view table > thead > tr > th {
    background: linear-gradient(135deg, #3c8dbc, #2c6a9e) !important;
    color: #fff !important;
    font-weight: 600;
    padding: 12px 10px;
    border: none !important;
    white-space: nowrap;
    position: relative;
}

.grid-view table > thead > tr > th a {
    color: #fff !important;
    text-decoration: none;
    font-weight: 600;
}

.grid-view table > thead > tr > th a:hover {
    text-decoration: underline;
}

.grid-view table > tbody > tr > td {
    padding: 10px;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f0;
}

.grid-view table > tbody > tr:hover {
    background: #f5f9fc !important;
}

/* أزرار الإجراءات (Action Column) */
.grid-view table > tbody > tr > td a.btn,
.grid-view table > tbody > tr > td .action-buttons a {
    padding: 4px 8px;
    font-size: 12px;
    margin: 1px;
    border-radius: 4px;
}

/* Summary "عرض 1-20 من 350" */
.grid-view .summary {
    padding: 8px 0;
    color: #666;
    font-size: 13px;
    font-weight: 500;
}

/* Pagination */
.grid-view .pagination {
    margin: 15px 0 0 0;
    justify-content: center;
}

.grid-view .pagination > li > a,
.grid-view .pagination > li > span {
    color: #3c8dbc;
    border-color: #e0e0e0;
    padding: 8px 12px;
    margin: 0 2px;
    border-radius: 6px !important;
}

.grid-view .pagination > li > a:hover {
    background: #3c8dbc;
    color: #fff;
    border-color: #3c8dbc;
}

.grid-view .pagination > .active > a,
.grid-view .pagination > .active > span {
    background: #3c8dbc !important;
    border-color: #3c8dbc !important;
    color: #fff !important;
}

/* لا توجد بيانات */
.grid-view .empty {
    padding: 40px 20px;
    text-align: center;
    color: #999;
    font-size: 16px;
}

/* الموبايل */
@media (max-width: 768px) {
    .grid-view {
        padding: 10px;
    }

    .grid-view .filters {
        padding: 10px;
    }

    .grid-view table {
        font-size: 13px;
    }

    .grid-view table > thead > tr > th {
        padding: 8px 5px;
        font-size: 12px;
    }

    .grid-view table > tbody > tr > td {
        padding: 8px 5px;
    }

    .grid-view .pagination > li > a,
    .grid-view .pagination > li > span {
        padding: 6px 8px;
        font-size: 13px;
    }
}

/* ═══════════════════════════════════════════════════════════
   تحسينات التنبيهات والأزرار والـ Modals
   ═══════════════════════════════════════════════════════════ */

/* التنبيهات */
.alert {
    border-radius: 8px;
    border-width: 0 0 0 4px;
    padding: 12px 18px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    font-weight: 500;
}

.alert-success {
    background: #d4edda;
    border-left-color: #28a745;
    color: #155724;
}

.alert-danger {
    background: #f8d7da;
    border-left-color: #dc3545;
    color: #721c24;
}

.alert-warning {
    background: #fff3cd;
    border-left-color: #ffc107;
    color: #856404;
}

.alert-info {
    background: #d1ecf1;
    border-left-color: #17a2b8;
    color: #0c5460;
}

/* أزرار الإجراءات السريعة */
.btn-group > .btn {
    border-radius: 6px !important;
    margin: 0 2px;
}

/* أزرار الحذف - لون أحمر */
.btn-danger {
    background: #dc3545;
    border-color: #c82333;
}

.btn-danger:hover {
    background: #c82333;
    border-color: #bd2130;
}

/* أزرار النجاح - لون أخضر */
.btn-success {
    background: #28a745;
    border-color: #1e7e34;
}

.btn-success:hover {
    background: #218838;
    border-color: #1e7e34;
}

/* Modals (النوافذ المنبثقة) */
.modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
    background: linear-gradient(135deg, #3c8dbc, #2c6a9e);
    color: #fff;
    border-radius: 12px 12px 0 0;
    padding: 15px 20px;
}

.modal-header .close {
    color: #fff;
    opacity: 0.8;
}

.modal-header .close:hover {
    opacity: 1;
}

.modal-footer {
    background: #f8f9fc;
    border-radius: 0 0 12px 12px;
    border-top: 1px solid #e9ecef;
    padding: 12px 20px;
}

/* تنبيهات فلاش (Flash Messages) */
.alert-dismissible .close {
    padding: 12px 18px;
    opacity: 0.7;
}

/* Dropdowns */
.dropdown-menu {
    border-radius: 8px;
    border: 1px solid #e9ecef;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 8px 0;
}

.dropdown-menu > li > a {
    padding: 8px 20px;
    transition: background 0.15s;
}

.dropdown-menu > li > a:hover {
    background: #f5f9fc;
    color: #3c8dbc;
}

/* Breadcrumb */
.breadcrumb {
    background: #fff;
    border-radius: 8px;
    padding: 10px 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    margin-bottom: 15px;
}

.breadcrumb > li + li:before {
    content: "›";
    color: #999;
    padding: 0 8px;
}

.breadcrumb > .active {
    color: #3c8dbc;
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════
   تحسينات النماذج (Forms) — لشاشات الإضافة والتعديل
   ═══════════════════════════════════════════════════════════ */

/* حاوية النموذج */
.form-group {
    margin-bottom: 18px;
}

/* الحقول المطلوبة - علامة النجمة */
.form-group.required > label:after {
    content: " *";
    color: #dc3545;
    font-weight: bold;
}

/* رسائل الخطأ */
.help-block.help-block-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
    font-weight: 500;
}

/* الحقل عند وجود خطأ */
.has-error .form-control {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.has-success .form-control {
    border-color: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

/* Select و multiselect */
select.form-control,
.form-control[multiple] {
    height: auto;
    min-height: 38px;
    padding: 6px 12px;
}

/* Checkboxes و Radio */
.checkbox, .radio {
    margin: 8px 0;
}

.checkbox label,
.radio label {
    font-weight: 500;
    padding-right: 25px;
}

/* File upload */
input[type="file"].form-control {
    height: auto;
    padding: 8px;
}

/* Date/Time pickers */
.datepicker,
.daterangepicker {
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

/* أزرار النموذج (حفظ، إلغاء) */
.form-group .btn {
    min-width: 120px;
    padding: 10px 24px;
}

/* حقول بصيغة أفقي */
.form-horizontal .control-label {
    text-align: right;
    padding-top: 8px;
    font-weight: 600;
    color: #333;
}

/* ═══════════════════════════════════════════════════════════
   1) إصلاح جدول المستخدمين (وأي جدول GridView آخر)
   ═══════════════════════════════════════════════════════════ */

/* جعل الفلاتر (البحث) تأخذ عرض الخلية بالكامل */
.grid-view .filters input,
.grid-view .filters select {
    width: 100% !important;
    border-radius: 4px;
}

/* ترتيب أزرار الإجراءات (العين، القلم، السلة) أفقياً بدلاً من عمودي */
.grid-view table > tbody > tr > td.action-column {
    white-space: nowrap;
}
.grid-view table > tbody > tr > td.action-column a {
    display: inline-block;
    margin: 0 3px;
    padding: 5px 8px;
    border-radius: 4px;
    background: #f4f6f9;
    color: #333;
    transition: all 0.2s;
}
.grid-view table > tbody > tr > td.action-column a:hover {
    background: #3c8dbc;
    color: #fff;
    transform: translateY(-1px);
}

/* تحسين شكل زر "تغيير كلمة المرور" و "طباعة" ليكون أنيقاً */
.grid-view table .btn {
    margin-bottom: 5px;
    border-radius: 20px; /* حواف دائرية */
    font-size: 12px;
    padding: 4px 12px;
}

/* ═══════════════════════════════════════════════════════════
   2) إصلاح لوحة التحكم (Dashboard Cards)
   ═══════════════════════════════════════════════════════════ */

/* المربعات الصغيرة العلوية (الأخبار، الصور...) */
.small-box {
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    transition: transform 0.2s;
}
.small-box:hover {
    transform: translateY(-3px);
}
.small-box .inner h3 {
    font-size: 32px;
    font-weight: 800;
}
.small-box .icon {
    opacity: 0.3;
    font-size: 80px;
}

/* المربع الأحمر الكبير (طلبات البريد) - سنجعله أقل ضخامة */
.info-box {
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    min-height: 80px;
}
.info-box .info-box-icon {
    border-radius: 12px 0 0 12px;
}
.info-box .info-box-content {
    padding: 15px;
}

/* إحصائيات الزوار (اليوم، الشهر، السنة) - سنجعلها بطاقات بيضاء أنيقة */
.bg-white {
    border: 1px solid #eef2f6 !important;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    padding: 15px !important;
    transition: all 0.2s;
}
.bg-white:hover {
    box-shadow: 0 6px 15px rgba(0,0,0,0.08);
    border-color: #d1e3f8 !important;
}

/* تحسين شكل الشريط الجانبي */
.main-sidebar {
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
}
.sidebar-menu li.header {
    font-weight: bold;
    color: #aeb9c2;
    padding: 15px 15px 5px 15px;
}

/* ═══════════════════════════════════════════════════════════
   3) تحسينات استجابة للموبايل (شاشات صغيرة)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .small-box h3 { font-size: 24px; }
    .small-box .icon { font-size: 50px; }
    .grid-view table { font-size: 12px; }
    .grid-view .btn { font-size: 11px; padding: 3px 8px; }
}

/* ═══════════════════════════════════════════════════════════
   تحسينات إضافية لنموذج الأخبار (CKEditor + FileInput)
   ═══════════════════════════════════════════════════════════ */

/* 1) فصل الصفوف (Rows) بمسافات مريحة */
.news-form .row {
    margin-bottom: 20px;
}
.news-form .row:last-child {
    margin-bottom: 0;
}

/* 2) تحسين محرر النصوص CKEditor */
.news-form .cke_chrome {
    border-radius: 8px !important;
    border: 1px solid #e0e0e0 !important;
    overflow: hidden;
    box-shadow: none !important;
}
.news-form .cke_top {
    background: #f8f9fc !important;
    border-bottom: 1px solid #e0e0e0 !important;
    padding: 8px 10px !important;
}
.news-form .cke_bottom {
    background: #f8f9fc !important;
    border-top: 1px solid #e0e0e0 !important;
}

/* 3) تحسين حقل رفع الصور (Kartik FileInput) */
.news-form .file-drop-zone {
    border: 2px dashed #3c8dbc !important;
    border-radius: 8px !important;
    background: #f8fbfe !important;
    transition: all 0.3s ease;
}
.news-form .file-drop-zone:hover {
    background: #f0f7ff !important;
    border-color: #2c6a9e !important;
}
.news-form .file-preview {
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    padding: 10px;
}

/* 4) تحسين حقل التاريخ (DatePicker) */
.news-form .datepicker {
    border-radius: 8px !important;
    background: #fafbfc;
    cursor: pointer;
}

/* 5) زر الحفظ (تأكيد إضافي) */
.news-form .btn-success, 
.news-form .btn-primary {
    font-size: 16px;
    padding: 12px 30px;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* ═══════════════════════════════════════════════════════════
   تحسينات البطاقات الإحصائية (Small Boxes) للوحة التحكم
   ═══════════════════════════════════════════════════════════ */

/* 1) الحاوية الرئيسية للبطاقة */
.small-box {
    border-radius: 12px !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08) !important;
    overflow: hidden;
    transition: all 0.3s ease;
    margin-bottom: 20px;
    border: none !important;
    position: relative;
}

.small-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15) !important;
}

/* 2) محتوى البطاقة (الرقم والنص) */
.small-box .inner {
    padding: 20px;
}
.small-box .inner h3 {
    font-size: 38px !important;
    font-weight: 800 !important;
    margin: 0 0 5px 0 !important;
    letter-spacing: -1px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.small-box .inner p {
    font-size: 16px !important;
    font-weight: 600 !important;
    margin: 0;
}

/* 3) الأيقونة في الخلفية */
.small-box .icon {
    position: absolute;
    top: 15px;
    left: 15px; /* بسبب RTL */
    font-size: 80px !important;
    opacity: 0.15 !important;
    transition: all 0.3s ease;
    color: #fff !important;
    pointer-events: none;
}
.small-box:hover .icon {
    opacity: 0.3 !important;
    transform: scale(1.1) rotate(-5deg);
}

/* 4) الشريط السفلي (زر "المزيد") */
.small-box .small-box-footer {
    display: block;
    padding: 10px 0;
    text-align: center;
    color: rgba(255,255,255,0.9) !important;
    background: rgba(0,0,0,0.1) !important;
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 600;
    font-size: 13px;
}
.small-box .small-box-footer:hover {
    background: rgba(0,0,0,0.2) !important;
    color: #fff !important;
}

/* 5) تحسين الألوان الافتراضية لتكون متدرجة (Gradients) */
.bg-aqua { background: linear-gradient(135deg, #00c6ff, #0072ff) !important; color: #fff !important; }
.bg-green { background: linear-gradient(135deg, #28a745, #1e7e34) !important; color: #fff !important; }
.bg-yellow { background: linear-gradient(135deg, #ffc107, #d39e00) !important; color: #fff !important; }
.bg-red { background: linear-gradient(135deg, #dc3545, #bd2130) !important; color: #fff !important; }

/* 6) إصلاح صناديق إحصائيات الزوار في شاشة المدير */
.box-warning {
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border: 1px solid #eee;
    background: #fff;
}
.box-warning .box-header {
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    border-radius: 10px 10px 0 0;
    padding: 10px 15px;
}
.box-warning .box-title {
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

/* ═══════════════════════════════════════════════════════════
   تحسينات القائمة الجانبية (Sidebar)
   ═══════════════════════════════════════════════════════════ */

/* الخلفية العامة للقائمة */
.main-sidebar {
    background-color: #1e282c !important;
}

/* عناصر القائمة */
.sidebar-menu > li > a {
    color: #b8c7ce !important;
    padding: 12px 15px 12px 15px;
    border-right: 3px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
}

/* عند مرور الماوس على عنصر */
.sidebar-menu > li > a:hover {
    background-color: #1e282c !important;
    color: #fff !important;
    border-right-color: #3c8dbc;
}

/* العنصر النشط (الصفحة الحالية) */
.sidebar-menu > li.active > a {
    background-color: #2c3b41 !important;
    color: #fff !important;
    border-right-color: #3c8dbc !important;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

/* أيقونات القائمة */
.sidebar-menu > li > a > .fa,
.sidebar-menu > li > a > .glyphicon,
.sidebar-menu > li > a > .ion {
    color: #8aa4af;
    transition: all 0.3s;
}

.sidebar-menu > li.active > a > .fa,
.sidebar-menu > li.active > a > .glyphicon,
.sidebar-menu > li.active > a > .ion {
    color: #3c8dbc;
}

/* عناوين المجموعات (مثل: صفحات الموقع) */
.sidebar-menu > li.header {
    background-color: #1a2226 !important;
    color: #4b646f !important;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 10px 15px;
    text-transform: uppercase;
}

/* ═══════════════════════════════════════════════════════════
   تحسينات أزرار الإجراءات في جداول GridView
   ═══════════════════════════════════════════════════════════ */

/* أزرار الإجراءات (عرض، تعديل، حذف) */
.grid-view table td .btn-xs {
    padding: 5px 8px;
    font-size: 12px;
    border-radius: 6px;
    margin: 0 2px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

/* زر العرض (العين) - أزرق */
.grid-view table td .btn-info {
    background-color: #17a2b8;
    border-color: #17a2b8;
    color: #fff;
}
.grid-view table td .btn-info:hover {
    background-color: #138496;
    border-color: #117a8b;
    transform: translateY(-2px);
}

/* زر التعديل (القلم) - أخضر */
.grid-view table td .btn-primary {
    background-color: #007bff;
    border-color: #007bff;
    color: #fff;
}
.grid-view table td .btn-primary:hover {
    background-color: #0069d9;
    border-color: #0062cc;
    transform: translateY(-2px);
}

/* زر الحذف (السلة) - أحمر */
.grid-view table td .btn-danger {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #fff;
}
.grid-view table td .btn-danger:hover {
    background-color: #c82333;
    border-color: #bd2130;
    transform: translateY(-2px);
}

/* تكبير الأيقونة داخل الزر قليلاً */
.grid-view table td .btn-xs .fa,
.grid-view table td .btn-xs .glyphicon {
    font-size: 14px;
}

/* تلوين حالة "نشط" في الجدول */
.grid-view table td .label-success {
    background-color: #28a745 !important;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
}
