/*
 * الأنماط المخصصة لنظام TAERP - Custom Styles
 */

/* ===== الإعدادات العامة ===== */
body {
    font-family: 'Tajawal', sans-serif;
    background-color: #f8f9fa;
}

/* ===== الشريط الجانبي - Sidebar ===== */
.sidebar {
    width: 240px;
    height: 100vh;
    background-color: #14532d;
    color: #d1d5db;
    position: fixed;
    right: 0;
    top: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1030;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: #166534;
    border-radius: 4px;
}

.sidebar-brand {
    color: #fff;
}

.sidebar-brand:hover {
    color: #e2e8f0;
}

.sidebar-divider {
    border-color: #166534;
    opacity: 0.5;
}

.sidebar .nav-header {
    color: #86efac;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem 0.25rem;
    list-style: none;
}

.sidebar .nav-link {
    color: #cbd5e1;
    border-radius: 0.375rem;
    padding: 0.4rem 0.75rem;
    margin-bottom: 1px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
}

.sidebar .nav-link:hover {
    color: #fff;
    background-color: #166534;
}

.sidebar .nav-link.active {
    color: #fff;
    background-color: #15803d;
}

.sidebar .nav-link.disabled {
    color: #4b5563;
}

.sidebar .nav-link .badge {
    font-size: 0.6rem;
    font-weight: 400;
}

/* ===== المحتوى الرئيسي ===== */
.main-content {
    margin-right: 240px;
    min-height: 100vh;
    position: relative;
}

/* ===== زر فتح القائمة للموبايل ===== */
.sidebar-toggler {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1040;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #14532d;
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    font-size: 1.25rem;
    align-items: center;
    justify-content: center;
}

/* خلفية مظلمة عند فتح القائمة في الموبايل */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 1040;
}

.sidebar-overlay.show {
    display: block;
}

/* ===== بطاقات الإحصائيات ===== */
.stat-card {
    border: none;
    border-radius: 0.75rem;
    transition: transform 0.15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* ===== الجداول ===== */
.table th {
    font-weight: 600;
    white-space: nowrap;
}

/* ===== عنوان الصفحة ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0;
}

/* ===== التصميم المتجاوب ===== */

/* شاشات متوسطة: تصغير الشريط الجانبي */
@media (max-width: 1199.98px) {
    .sidebar {
        width: 200px;
    }
    .main-content {
        margin-right: 200px;
    }
    .sidebar .nav-link {
        font-size: 0.8rem;
        padding: 0.35rem 0.6rem;
    }
    .sidebar .nav-header {
        font-size: 0.65rem;
        padding: 0.6rem 0.6rem 0.2rem;
    }
}

/* شاشات صغيرة: إخفاء الشريط الجانبي */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed !important;
        right: 0 !important;
        top: 0 !important;
        left: auto !important;
        width: 280px !important;
        height: 100vh !important;
        height: 100dvh !important;
        z-index: 1050 !important;
        transform: translateX(100%) !important;
        transition: transform 0.3s ease !important;
        box-shadow: none !important;
    }

    .sidebar.show {
        transform: translateX(0) !important;
        box-shadow: -5px 0 15px rgba(0,0,0,0.2) !important;
    }

    .main-content {
        margin-right: 0 !important;
        margin-left: 0 !important;
        width: 100% !important;
    }

    .sidebar-toggler {
        display: flex !important;
        z-index: 1060 !important;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    /* بطاقات الإحصائيات */
    .stat-card .card-body {
        padding: 0.75rem !important;
    }
    .stat-card .stat-icon {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }
    .stat-card .fs-5 {
        font-size: 1rem !important;
    }

    /* الرسوم البيانية */
    .card-header h6 {
        font-size: 0.8rem;
    }

    /* الأزرار والفورمات */
    .btn {
        font-size: 0.85rem;
    }
    .form-select-sm, .form-control-sm {
        font-size: 0.8rem;
    }
}

/* شاشات صغيرة جداً - موبايل */
@media (max-width: 575.98px) {
    .container-fluid {
        padding: 0.75rem !important;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header h1 {
        font-size: 1.1rem;
    }

    /* الجداول */
    .table {
        font-size: 0.78rem;
    }
    .table th, .table td {
        padding: 0.4rem 0.5rem;
    }

    /* بطاقات الإحصائيات - عمودين */
    .stat-card .card-body {
        padding: 0.6rem !important;
        flex-direction: column;
        text-align: center;
    }
    .stat-card .stat-icon {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
        margin: 0 auto 0.3rem !important;
    }
    .stat-card .fs-5 {
        font-size: 0.9rem !important;
    }
    .stat-card .small {
        font-size: 0.7rem;
    }

    /* هدف المبيعات */
    .card-body.p-4 {
        padding: 1rem !important;
    }

    /* الأزرار */
    .btn-sm {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
    }

    /* النافبار */
    .navbar {
        padding: 0.3rem 0.75rem !important;
    }

    /* الفلاتر */
    .filter-form .form-select,
    .filter-form .form-control {
        font-size: 0.75rem;
    }

    /* كروت الرسوم */
    .card-header {
        padding: 0.5rem 0.75rem !important;
    }

    /* بادج الحالة */
    .badge {
        font-size: 0.65rem;
    }

    /* الفواتير - إنشاء/تعديل */
    .invoice-items-table {
        font-size: 0.75rem;
    }
    .invoice-items-table .form-control {
        font-size: 0.75rem;
        padding: 0.25rem 0.4rem;
    }
}

/* التأكد من أن الجداول قابلة للسكرول */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* تحسين الفورمات على الشاشات الصغيرة */
@media (max-width: 767.98px) {
    /* هدف المبيعات - صف واحد */
    .card-body .row .col-md-8,
    .card-body .row .col-md-4 {
        text-align: center;
    }

    /* فورم الفلتر */
    .page-header form {
        width: 100%;
    }
    .page-header form .form-select {
        flex: 1;
    }

    /* الرسوم البيانية أصغر */
    .card-body canvas {
        max-height: 180px;
    }

    /* أزرار الصفحة */
    .page-header .btn {
        width: 100%;
    }

    /* الفواتير - صف الأزرار */
    .d-flex.gap-2 {
        flex-wrap: wrap;
    }
}
