/**
 * ============================================
 * Sama Water - Unified Visual Identity v2.0
 * الهوية البصرية الموحدة لشركة مياه سما
 * ============================================
 */

/* استيراد خط Cairo */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700;900&display=swap');

:root {
    --primary-deep: #1e3a5f;
    --primary-light: #1e3a5f;
    --primary-gradient: #1e3a5f;
    --success-gradient: #059669;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-light: #f8fafc;
    --card-radius: 16px;
    --input-radius: 12px;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* الإعدادات العامة للخط */
body, h1, h2, h3, h4, h5, h6, p, span, a, button, input, select, textarea, .btn, .form-control {
    font-family: 'Cairo', sans-serif !important;
}

body {
    background-color: var(--bg-light) !important;
    color: #334155;
}

/* ============================================
   Sidebar - القائمة الجانبية الملكية
   ============================================ */
.sidebar {
    background: var(--primary-deep) !important;
    border: none !important;
    box-shadow: var(--shadow-lg) !important;
    width: 280px !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    z-index: 1030 !important; /* تقليل الـ z-index ليكون تحت النوافذ المنبثقة */
}

/* Responsive Sidebar */
@media (max-width: 991.98px) {
    .sidebar {
        margin-right: -280px !important; /* Hide off-screen by default on mobile */
        position: fixed !important;
        height: 100% !important;
    }
    
    body.sidebar-show .sidebar {
        margin-right: 0 !important; /* Show when body has sidebar-show class */
        z-index: 1050 !important; /* فوق الـ overlay حتى تكون الصفحات قابلة للضغط */
        overflow-y: auto !important;
    }
    body.sidebar-show .sidebar .sidebar-nav-wrapper,
    body.sidebar-show .sidebar .sidebar-nav {
        overflow-y: auto !important;
        max-height: calc(100vh - 120px) !important;
    }

    /* Overlay when sidebar is open on mobile (تحت السايدبار ليُغلق بالضغط عليه) */
    body.sidebar-show::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        backdrop-filter: blur(2px);
    }

    .app-body {
        margin-right: 0 !important;
    }
}

/* Ensure main content takes full width on mobile */
@media (max-width: 991.98px) {
    .main {
        margin-right: 0 !important;
        width: 100% !important;
    }
    
    [dir="rtl"] .app-body {
        margin-right: 0 !important;
    }
}

/* Hide Default Header completely as requested */
header.app-header, 
.app-header {
    display: none !important;
    visibility: hidden !important;
}

/* Custom Mobile Toggle Button - Floating */
.mobile-sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    background: var(--primary-deep);
    color: white !important;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 1100;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

@media (max-width: 991.98px) {
    .mobile-sidebar-toggle {
        display: flex;
    }
}

.mobile-sidebar-toggle:hover {
    transform: scale(1.1) rotate(90deg);
}

/* الترقيم (pagination) في كل النظام: اتجاه RTL وتخطيط موحد */
.pagination-modern {
    direction: rtl !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}
.pagination-modern .pagination-modern-inner {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 1rem !important;
}
.pagination-modern .pagination-modern-inner .pagination-info {
    flex-shrink: 0 !important;
}
.pagination-modern .pagination-modern-inner .pagination {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.25rem !important;
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}
.pagination-modern .pagination-modern-inner .pagination .page-item {
    display: inline-block !important;
}
.pagination-modern .page-link {
    border-radius: 10px !important;
    border: 2px solid #e2e8f0 !important;
    color: var(--primary-deep) !important;
    padding: 0.5rem 1rem !important;
    transition: all 0.3s ease !important;
}
.pagination-modern .page-link:hover {
    background: var(--primary-deep) !important;
    color: #fff !important;
    border-color: var(--primary-deep) !important;
}
.pagination-modern .page-item.active .page-link {
    background: var(--primary-deep) !important;
    border-color: var(--primary-deep) !important;
    color: #fff !important;
}

/* فلاتر البحث في كل الصفحات: RTL ومتجاوبة */
.filter-form-rtl {
    direction: rtl;
}
.filter-form-rtl .form-label-modern,
.filter-form-rtl .form-control-modern,
.filter-form-rtl .form-select-modern {
    text-align: right;
}
@media (max-width: 991.98px) {
    .filter-card-body {
        padding: 1.25rem !important;
    }
}
@media (max-width: 575.98px) {
    .filter-card-body {
        padding: 1rem !important;
    }
    .filter-form-rtl .btn-filter-submit,
    .filter-form-rtl .btn-add-client,
    .filter-form-rtl .btn-filter-reset {
        width: 100% !important;
    }
}

.sidebar .nav-link, 
.sidebar .nav-link span, 
.sidebar .nav-link i,
.sidebar .nav-item,
.sidebar .nav-title {
    color: #ffffff !important; /* خط أبيض ناصع لكل العناصر */
    opacity: 1 !important; /* إلغاء الشفافية ليكون اللون أبيض صريح */
}

.sidebar .nav-link {
    border-radius: 12px !important;
    margin: 4px 12px !important;
    padding: 10px 15px !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    font-weight: 500 !important;
    font-size: 14px !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

.sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    transform: translateX(-5px) !important;
}

.sidebar .nav-link.active {
    background: rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
    font-weight: 700 !important;
}

.sidebar .nav-title,
.sidebar .menu-section-label {
    color: #ffffff !important;
    font-weight: 900 !important;
    text-transform: uppercase !important;
    letter-spacing: 1.5px !important;
    padding: 25px 25px 10px !important;
    font-size: 14px !important;
    opacity: 1 !important;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
}

.sidebar-header {
    padding: 30px 20px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    margin-bottom: 15px !important;
}

/* تحسين شكل السكرول بار في المنيو */
.sidebar::-webkit-scrollbar {
    width: 5px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* ============================================
   Page Headers - رؤوس الصفحات الموحدة
   ============================================ */
section.header-operation,
section.header-operation.container-fluid,
.page-header {
    background: var(--primary-deep) !important; /* لون سادة ملكي */
    border-radius: 20px !important;
    padding: 1.5rem 2rem !important;
    margin-bottom: 2rem !important;
    box-shadow: var(--shadow-md) !important;
    position: relative !important;
    overflow: visible !important; /* مهم جداً للـ dropdown */
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
}

/* إزالة أي تأثيرات نبض أو تدرجات خلفية */
section.header-operation::before,
.page-header::before {
    display: none !important;
}

section.header-operation h1,
.page-header-title {
    color: #ffffff !important;
    font-weight: 800 !important;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
}

section.header-operation i,
.page-header-icon {
    color: #ffffff !important;
    opacity: 0.9;
}

/* تحسين الأزرار داخل الهيدر لتكون متناسقة */
section.header-operation .btn-primary,
section.header-operation .btn-success,
.page-header-actions .btn {
    border-radius: 12px !important;
    font-weight: 700 !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

/* ============================================
   Main Content Area - مساحة المحتوى الرئيسية
   ============================================ */
.main {
    background-color: var(--bg-light) !important;
    padding: 20px !important;
    overflow: visible !important;
}

.container-fluid {
    max-width: 100% !important;
    overflow: visible !important; 
}

/* تحسين شكل الفلاتر لتكون متناسقة مع الهوية */
.filter-card, 
.navbar-filters {
    background: #ffffff !important;
    border-radius: var(--card-radius) !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: var(--shadow-sm) !important;
    margin-bottom: 25px !important;
    overflow: visible !important; 
}

/* تحسين شكل الجداول لتكون عائمة */
.table-container, 
.dataTables_wrapper,
.clients-table-wrapper {
    background: #ffffff !important;
    border-radius: var(--card-radius) !important;
    padding: 25px !important;
    box-shadow: var(--shadow-md) !important;
    border: 1px solid #f1f5f9 !important;
    overflow: visible !important; 
}

/* توحيد لون خلفية رؤوس الجداول */
table.dataTable thead tr,
table.clients-table thead tr {
    background: var(--primary-deep) !important; /* اللون الموحد */
}

table.dataTable thead th,
table.clients-table thead th {
    background: var(--primary-deep) !important; /* اللون الموحد */
    color: #ffffff !important;
    font-weight: 700 !important;
    border: none !important;
    padding: 15px !important;
}

/* ============================================
   Cards & Tables - البطاقات والجداول العائمة
   ============================================ */
.card {
    border: none !important;
    border-radius: var(--card-radius) !important;
    box-shadow: var(--shadow-sm) !important;
    transition: box-shadow 0.3s ease;
    overflow: visible !important; 
}

.card:hover {
    box-shadow: var(--shadow-md) !important;
}

.table-wrapper {
    background: #fff;
    border-radius: var(--card-radius);
    padding: 20px;
    box-shadow: var(--shadow-md);
    overflow: visible !important;
}

table.dataTable tbody td {
    padding: 12px 15px !important;
    border-bottom: 1px solid #f1f5f9 !important;
    vertical-align: middle !important;
    overflow: visible !important; 
}

/* ============================================
   Forms & Inputs - النماذج وحقول الإدخال
   ============================================ */
.form-control, .form-select, .select2-container--bootstrap .select2-selection {
    border-radius: var(--input-radius) !important;
    border: 1.5px solid #e2e8f0 !important;
    padding: 10px 15px !important;
    height: auto !important;
    background-color: #fff !important;
    transition: all 0.2s ease !important;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-deep) !important;
    box-shadow: 0 0 0 4px rgba(30, 58, 95, 0.1) !important;
}

label {
    font-weight: 700 !important;
    color: var(--primary-deep) !important;
    margin-bottom: 8px !important;
}

/* ============================================
   Buttons - الأزرار العصرية
   ============================================ */
.btn {
    border-radius: 10px !important;
    padding: 10px 20px !important;
    font-weight: 700 !important;
    transition: all 0.3s ease !important;
}

.btn-primary {
    background: var(--primary-deep) !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(30, 58, 95, 0.3) !important;
}

.btn-primary:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(30, 58, 95, 0.4) !important;
    background: #254a7a !important;
}

.btn-success {
    background: var(--success-gradient) !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(5, 150, 105, 0.3) !important;
}

/* ============================================
   Login Page - صفحة تسجيل الدخول
   ============================================ */
.login-page {
    background: var(--primary-deep) !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    width: 450px !important;
}

.login-box .card {
    padding: 20px !important;
    box-shadow: var(--shadow-lg) !important;
    overflow: hidden !important;
}

/* ============================================
   Modal Fixes - إصلاحات النوافذ المنبثقة
   ============================================ */
.modal-backdrop {
    z-index: 2040 !important;
}

.modal {
    z-index: 2050 !important;
}

.modal-content {
    z-index: 2060 !important;
}

/* ضمان أن النوافذ المنبثقة تعمل بشكل صحيح حتى لو كانت داخل عناصر أخرى */
body.modal-open .main,
body.modal-open .app-body {
    z-index: auto !important;
}

/* ============================================
   Dropdown Fixes - إصلاحات القوائم المنسدلة
   ============================================ */
/* إصلاح القوائم المنسدلة: عدم القص — مع استثناء غلاف التمرير الأفقي للجداول */
.table-responsive:not(.table-scroll-wrapper) {
    overflow: visible !important;
}
.table-responsive.table-scroll-wrapper {
    overflow-x: auto !important;
    overflow-y: visible !important;
    max-width: 100% !important;
}

.dropdown-menu {
    z-index: 1060 !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid #f1f5f9 !important;
    border-radius: 12px !important;
    position: absolute !important;
}

/* ضمان عدم اختفاء القائمة خلف الصفوف الأخرى */
tr:hover {
    z-index: 50 !important;
    position: relative !important;
}

.btn-group.show {
    z-index: 1000 !important;
    position: relative !important;
}

/* قائمة الإجراءات في الجداول تظهر فوق العناصر (لا تُقص بالـ overflow) */
.table-card-modern {
    overflow: visible !important;
}
.table-responsive.table-scroll-wrapper {
    overflow-y: visible !important;
}

/* ============================================
   Footer - تذييل الصفحة الموحد
   ============================================ */
footer.app-footer,
.app-footer,
footer.sticky-footer,
.sticky-footer {
    background: linear-gradient(135deg, var(--primary-deep) 0%, #2d4a6b 100%) !important;
    border-top: none !important;
    padding: 1.25rem 2rem !important;
    margin-top: auto !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1) !important;
    position: relative !important;
    overflow: hidden !important;
}

footer.app-footer::before,
.app-footer::before {
    content: '' !important;
    position: absolute !important;
    top: -50% !important;
    right: -10% !important;
    width: 300px !important;
    height: 300px !important;
    background: rgba(255, 255, 255, 0.03) !important;
    border-radius: 50% !important;
    z-index: 0 !important;
}

footer.app-footer::after,
.app-footer::after {
    content: '' !important;
    position: absolute !important;
    bottom: -30% !important;
    left: -5% !important;
    width: 200px !important;
    height: 200px !important;
    background: rgba(255, 255, 255, 0.02) !important;
    border-radius: 50% !important;
    z-index: 0 !important;
}

footer.app-footer .container,
.app-footer .container,
footer.app-footer .container-fluid,
.app-footer .container-fluid {
    position: relative !important;
    z-index: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
}

footer.app-footer p,
.app-footer p,
footer.app-footer span,
.app-footer span,
footer.app-footer div,
.app-footer div {
    color: rgba(255, 255, 255, 0.95) !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    margin: 0 !important;
    font-family: 'Cairo', sans-serif !important;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

footer.app-footer a,
.app-footer a {
    color: rgba(255, 255, 255, 0.95) !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    padding: 0 4px !important;
}

footer.app-footer a::after,
.app-footer a::after {
    content: '' !important;
    position: absolute !important;
    bottom: -2px !important;
    left: 0 !important;
    width: 0 !important;
    height: 2px !important;
    background: rgba(255, 255, 255, 0.8) !important;
    transition: width 0.3s ease !important;
}

footer.app-footer a:hover,
.app-footer a:hover {
    color: #fff !important;
    transform: translateY(-1px) !important;
}

footer.app-footer a:hover::after,
.app-footer a:hover::after {
    width: 100% !important;
}

/* Responsive Footer */
@media (max-width: 768px) {
    footer.app-footer,
    .app-footer {
        padding: 1rem 1.5rem !important;
    }
    
    footer.app-footer p,
    .app-footer p,
    footer.app-footer span,
    .app-footer span {
        font-size: 13px !important;
    }
}
