@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;900&display=swap');

:root {
    --primary-color: #4361ee;
    --primary-light: #4895ef;
    --secondary-color: #3f37c9;
    --success-color: #4cc9f0;
    --danger-color: #f72585;
    --warning-color: #f8961e;
    --dark-color: #212529;
    --light-color: #f8f9fa;
    --body-bg: #f4f6f9;
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    --border-radius: 12px;
    --sidebar-width: 260px;
    --transition-speed: 0.3s;
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--body-bg);
    color: var(--dark-color);
    overflow-x: hidden;
}

/* تخطيط لوحة التحكم الجانبية */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

#sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    transition: all var(--transition-speed);
    min-height: 100vh;
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
    z-index: 1000;
}

#sidebar .sidebar-header {
    padding: 24px;
    background: rgba(0,0,0,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

#sidebar .sidebar-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(to left, #4cc9f0, #4361ee);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#sidebar ul.components {
    padding: 20px 0;
}

#sidebar ul li {
    padding: 2px 15px;
}

#sidebar ul li a {
    padding: 12px 15px;
    font-size: 1rem;
    display: block;
    color: rgba(255,255,255,0.7);
    border-radius: var(--border-radius);
    text-decoration: none;
    transition: all var(--transition-speed);
    font-weight: 500;
    margin-bottom: 5px;
}

#sidebar ul li a i {
    margin-left: 10px;
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

#sidebar ul li a:hover, #sidebar ul li.active > a {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

#sidebar ul li.active > a {
    background: var(--primary-color);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

/* محتوى الصفحة الرئيسي */
#content {
    width: 100%;
    padding: 30px;
    min-height: 100vh;
    transition: all var(--transition-speed);
}

/* تنسيقات البطاقات */
.card-stat {
    border: none;
    border-radius: var(--border-radius);
    background: #fff;
    box-shadow: var(--card-shadow);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    overflow: hidden;
    position: relative;
}

.card-stat:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.card-stat .card-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
    opacity: 0.15;
    color: var(--primary-color);
}

.card-stat.card-rented .card-icon { color: #2ec4b6; }
.card-stat.card-vacant .card-icon { color: #e71d36; }
.card-stat.card-maintenance .card-icon { color: var(--warning-color); }
.card-stat.card-income .card-icon { color: #2ec4b6; }
.card-stat.card-arrears .card-icon { color: var(--danger-color); }

.card-stat .card-body {
    padding: 24px;
    z-index: 2;
    position: relative;
}

.card-stat .card-title {
    font-size: 0.9rem;
    color: #8898aa;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 8px;
}

.card-stat .card-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #32325d;
}

/* تصميم الجداول الحديثة */
.table-responsive {
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 15px;
    border: none;
}

.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 700;
    color: #8898aa;
    text-transform: uppercase;
    border-top: none;
    padding: 16px;
    font-size: 0.85rem;
}

.table td {
    padding: 16px;
    vertical-align: middle;
    color: #525f7f;
    border-bottom: 1px solid #e9ecef;
}

.table tr:last-child td {
    border-bottom: none;
}

/* أزرار وحالات */
.badge-custom {
    padding: 6px 12px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-available { background-color: rgba(76, 201, 240, 0.15); color: #0077b6; }
.badge-rented { background-color: rgba(46, 196, 182, 0.15); color: #0f9f90; }
.badge-maintenance { background-color: rgba(248, 150, 30, 0.15); color: #d07000; }

.badge-active { background-color: rgba(46, 196, 182, 0.15); color: #0f9f90; }
.badge-expired { background-color: rgba(247, 37, 133, 0.15); color: #c91862; }
.badge-terminated { background-color: rgba(108, 117, 125, 0.15); color: #495057; }

.badge-open { background-color: rgba(247, 37, 133, 0.15); color: #c91862; }
.badge-in_progress { background-color: rgba(248, 150, 30, 0.15); color: #d07000; }
.badge-completed { background-color: rgba(46, 196, 182, 0.15); color: #0f9f90; }

.badge-high { background-color: rgba(247, 37, 133, 0.2); color: #c91862; }
.badge-medium { background-color: rgba(248, 150, 30, 0.2); color: #d07000; }
.badge-low { background-color: rgba(67, 97, 238, 0.2); color: #3f37c9; }

/* أزرار مخصصة */
.btn-primary-custom {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    font-weight: 600;
    border-radius: 8px;
    padding: 10px 20px;
    transition: all 0.2s;
}

.btn-primary-custom:hover {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(67, 97, 238, 0.3);
}

/* شاشة تسجيل الدخول */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4361ee 0%, #3f37c9 100%);
}

.login-card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    width: 100%;
    max-width: 450px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.login-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    padding: 30px;
    color: white;
    text-align: center;
}

.login-body {
    padding: 40px 30px;
}

/* تحسينات المدخلات */
.form-control, .form-select {
    border-radius: 8px;
    padding: 12px 15px;
    border: 1px solid #dee2e6;
    font-size: 0.95rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 0.25rem rgba(67, 97, 238, 0.15);
}

/* الميزات الإضافية */
.alert-card {
    border-left: 4px solid var(--danger-color);
    background-color: rgba(247, 37, 133, 0.05);
}

/* إخفاء عناصر الطباعة الرسمية على الشاشة افتراضياً */
.print-header-block,
.print-footer-block,
.print-only {
    display: none;
}

/* تصميم الفواتير والطباعة الرسمية */
@media print {
    #sidebar, 
    .navbar, 
    .btn, 
    .btn-sm,
    .no-print, 
    form.no-print, 
    .alert, 
    .modal, 
    .modal-backdrop,
    .badge-custom + a,
    td.no-print,
    th.no-print {
        display: none !important;
    }
    
    #content {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        min-height: auto !important;
    }
    
    body {
        background-color: #fff !important;
        color: #000 !important;
        font-size: 11pt !important;
        line-height: 1.4;
    }
    
    /* تفعيل الترويسة والتذييل في الطباعة */
    .print-header-block {
        display: block !important;
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 2px solid #2d3748;
    }
    
    .print-footer-block {
        display: block !important;
        margin-top: 50px;
        page-break-inside: avoid;
    }
    
    .print-only {
        display: block !important;
    }
    
    /* الجداول الصديقة للطباعة */
    .table-responsive {
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        overflow: visible !important;
        border: none !important;
    }
    
    .table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin-top: 15px;
    }
    
    .table th, .table td {
        border: 1px solid #a0aec0 !important;
        padding: 8px 10px !important;
        color: #000 !important;
        font-size: 10pt !important;
    }
    
    .table th {
        background-color: #edf2f7 !important;
        color: #000 !important;
        font-weight: bold !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    /* بطاقات الإحصاءات الرسمية للطباعة */
    .card-stat {
        border: 1px solid #cbd5e0 !important;
        box-shadow: none !important;
        background: #fff !important;
        transform: none !important;
        page-break-inside: avoid;
        margin-bottom: 15px !important;
    }
    
    .card-stat .card-icon {
        display: none !important;
    }
    
    .card-stat .card-value {
        color: #000 !important;
        font-size: 1.6rem !important;
    }
    
    .card-stat .card-title {
        color: #4a5568 !important;
    }
    
    .alert-card {
        border: 1px solid #feb2b2 !important;
        background-color: #fffaf0 !important;
        color: #9b2c2c !important;
        page-break-inside: avoid;
    }
    
    /* الحفاظ على عدم انقسام الصفوف */
    tr {
        page-break-inside: avoid !important;
    }
    
    .badge {
        border: 1px solid #a0aec0 !important;
        color: #000 !important;
        background-color: transparent !important;
        padding: 4px 8px !important;
        font-size: 8pt !important;
    }
    
    @page {
        size: A4;
        margin: 15mm;
    }
}

