/**
 * financial_system_app/app/static/css/custom.css
 * التنسيقات العربية المتكاملة والهوية المالية الرسمية (RTL Financial Theme)
 */

/* 1. إعداد الخط العربي مع بدائل ويندوز القياسية */
@font-face {
    font-family: 'Cairo';
    src: local('Cairo'), local('Cairo-Regular'), local('Segoe UI'), local('Tahoma');
    font-weight: normal;
    font-style: normal;
}

body {
    direction: rtl;
    text-align: right;
    font-family: 'Cairo', 'Tajawal', 'Segoe UI', Tahoma, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    color: #2d3748;
    background-color: #f7fafc;
}

/* 2. لوحة الألوان المحاسبية والهندسية المعتمدة (Brand Colors 547efe5f) */
:root {
    /* الألوان القيادية */
    --color-navy-deep: #082849;    /* الكحلي الليلي العميق */
    --color-navy: #0358a1;         /* الكحلي القيادي المعتمد */
    --color-navy-dark: #074b85;    /* كحلي التفاعل */
    --color-cyan-glow: #0284c7;    /* السماوي الهندسي */
    --color-sky-light: #e0effe;    /* خلفيات التمييز الهادئة */
    
    /* الألوان الوظيفية والمالية */
    --color-gold: #ecc94b;         /* الكهرماني والذهبي */
    --color-amber-gold: #f59e0b;
    --color-debit: #ef4444;        /* الأحمر الوردي المالي (المدين والتنبيه) */
    --color-credit: #10b981;       /* الأخضر الزمردي المالي (الدائن والتحصيل) */
    --color-balanced: #10b981;     /* حالة الاتزان */
    
    /* المتغيرات المتناسقة */
    --brand-border: #cbd5e1;
    --brand-card-bg: #ffffff;
    --brand-shadow: 0 10px 25px -5px rgba(8, 40, 73, 0.08);
}

.bg-navy { 
    background: linear-gradient(135deg, #082849 0%, #0358a1 60%, #0284c7 100%) !important; 
}
.bg-gold { background-color: var(--color-gold) !important; }
.btn-navy {
    background: linear-gradient(135deg, #082849 0%, #0358a1 100%);
    border-color: #0358a1;
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(3, 88, 161, 0.2);
}
.btn-navy:hover {
    background: linear-gradient(135deg, #074b85 0%, #026fc7 100%);
    border-color: #026fc7;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
}

.bg-login {
    background: linear-gradient(135deg, #082849 0%, #0358a1 50%, #0284c7 100%);
}

/* ==========================================================================
   3. الحاويات المستطيلة بحواف دائرية وشريط الرأس (Header Boxes & Navbar)
   ========================================================================== */
.header-box {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 12px !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}
.header-box:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}
.header-box:active {
    transform: scale(0.97);
}
.text-gold {
    color: #ffd166 !important;
}

/* ==========================================================================
   4. التخطيط المتكامل والشريط الجانبي القابل للطي (App Layout & Collapsible Sidebar)
   ========================================================================== */
.app-wrapper {
    display: flex;
    min-height: calc(100vh - 58px);
    width: 100%;
    position: relative;
    overflow-x: hidden;
}

.app-sidebar {
    width: 260px;
    flex-shrink: 0;
    background-color: #ffffff;
    border-left: 1px solid #e2e8f0;
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1020;
    display: flex;
    flex-direction: column;
}

.app-sidebar .sidebar-inner {
    position: sticky;
    top: 58px;
    height: calc(100vh - 58px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 2rem;
}

.app-main {
    flex-grow: 1;
    min-width: 0;
    background-color: #f8fafc;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-nav .nav-link {
    color: #4a5568;
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 10px;
    margin: 0.2rem 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.sidebar-nav .nav-link:hover {
    color: var(--color-navy);
    background-color: #edf2f7;
    transform: translateX(-3px);
}
.sidebar-nav .nav-link.active {
    color: #ffffff;
    background: linear-gradient(135deg, #082849 0%, #0358a1 60%, #0284c7 100%);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.28);
}
.sidebar-nav .nav-icon {
    font-size: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    text-align: center;
}
.sidebar-nav .nav-label {
    opacity: 1;
    transition: opacity 0.2s ease;
}

/* حالة القائمة المطوية (Collapsed Sidebar Mode) */
body.sidebar-collapsed .app-sidebar {
    width: 72px;
}
body.sidebar-collapsed .app-sidebar .nav-label,
body.sidebar-collapsed .app-sidebar .sidebar-section-text {
    display: none !important;
}
body.sidebar-collapsed .app-sidebar .sidebar-section-header {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    text-align: center;
}
body.sidebar-collapsed .app-sidebar .nav-link {
    justify-content: center;
    padding: 0.7rem 0.5rem;
    margin: 0.2rem 0.4rem;
}
body.sidebar-collapsed .app-sidebar .nav-link:hover {
    transform: none;
}

/* الاستجابة للشاشات الصغيرة */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        top: 58px;
        right: 0;
        bottom: 0;
        transform: translateX(100%);
        box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
    }
    body.sidebar-collapsed .app-sidebar {
        transform: translateX(0);
        width: 260px;
    }
    body.sidebar-collapsed .app-sidebar .nav-label,
    body.sidebar-collapsed .app-sidebar .sidebar-section-text {
        display: inline !important;
    }
    body.sidebar-collapsed .app-sidebar .nav-link {
        justify-content: flex-start;
        padding: 0.65rem 1rem;
        margin: 0.2rem 0.6rem;
    }
}

/* ==========================================================================
   5. انميشن وحركات الانتقال الاحترافية (Page Transitions & Micro-Animations)
   ========================================================================== */
@keyframes pageEntrance {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.995);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.page-transition-enter {
    animation: pageEntrance 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* تعميم الحواف الدائرية الأنيقة (12px - 16px) لجميع الصناديق والبطاقات */
.card, .alert, .modal-content, .dropdown-menu {
    border-radius: 16px !important;
}
.btn {
    border-radius: 12px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn:active {
    transform: scale(0.97);
}

/* تأثيرات التوهج الهندسي الدقيق (Spec Glows from 547efe5f) */
.spec-glow {
    box-shadow: 0 0 25px -5px rgba(2, 132, 199, 0.15) !important;
}
.spec-glow-lg {
    box-shadow: 0 20px 40px -15px rgba(8, 40, 73, 0.12) !important;
}

/* الشريط اللوني التدرجي المميز (Brand Accent Line) */
.brand-accent-line {
    height: 3px;
    background: linear-gradient(90deg, #082849 0%, #0284c7 50%, #0358a1 100%);
    border-radius: 2px;
    width: 100%;
}

/* النمط الهندسي الشفاف للعلامة المعتمدة */
.telecom-grid-pattern {
    background-image: radial-gradient(rgba(3, 88, 161, 0.08) 1px, transparent 1px);
    background-size: 24px 24px;
}

@media (prefers-reduced-motion: reduce) {
    .page-transition-enter {
        animation: none !important;
    }
    .app-sidebar, .sidebar-nav .nav-link, .header-box, .btn {
        transition: none !important;
    }
}

/* 4. بطاقات المؤشرات (KPI Cards) */
.kpi-card {
    border-radius: 16px !important;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 15px -3px rgba(8, 40, 73, 0.06) !important;
}
.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 25px -5px rgba(2, 132, 199, 0.15) !important;
}
.border-end-primary { border-right: 4px solid #0284c7 !important; }
.border-end-success { border-right: 4px solid #10b981 !important; }
.border-end-info    { border-right: 4px solid #06b6d4 !important; }
.border-end-warning { border-right: 4px solid #f59e0b !important; }

.kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* 5. الجداول والأرقام المالية */
.table th {
    font-weight: 600;
    background-color: #f8fafc;
    color: #4a5568;
}
.amount-cell, .table td:has(.currency) {
    font-variant-numeric: tabular-nums;
}
.text-debit { color: var(--color-debit); }
.text-credit { color: var(--color-credit); }

/* 6. مؤشرات الحالة ونبض التنبيه */
.indicator-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}
.animate-pulse {
    animation: pulse 1.5s infinite;
}

/* مقاسات خطوط مساعدة */
.fs-7 { font-size: 0.85rem; }
.fs-8 { font-size: 0.75rem; }

/* ==========================================================================
   7. الوضع الليلي الاحترافي (Dark Mode)
   ========================================================================== */

[data-bs-theme="dark"] body {
    background-color: #0b1120 !important;
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .bg-light {
    background-color: #0b1120 !important;
}

[data-bs-theme="dark"] .bg-white {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .card-header {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .card-footer {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .sidebar,
[data-bs-theme="dark"] .app-sidebar {
    background-color: #131d31 !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .app-main {
    background-color: #0b1120 !important;
}

[data-bs-theme="dark"] .sidebar-nav .nav-link {
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .sidebar-nav .nav-link:hover {
    color: #ffffff !important;
    background-color: #334155 !important;
}

[data-bs-theme="dark"] .sidebar-nav .nav-link.active {
    color: #ffffff !important;
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%) !important;
}

[data-bs-theme="dark"] .table {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .table th {
    background-color: #1e293b !important;
    color: #cbd5e1 !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .table-light {
    background-color: #1e293b !important;
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .table-light th,
[data-bs-theme="dark"] .table-light td {
    background-color: #1e293b !important;
    color: #cbd5e1 !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .table-hover tbody tr:hover td {
    background-color: #334155 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #0b1120 !important;
    border-color: #475569 !important;
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #0b1120 !important;
    border-color: #3b82f6 !important;
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #64748b !important;
}

[data-bs-theme="dark"] .list-group-item {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .text-dark {
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .text-navy {
    color: #60a5fa !important;
}

[data-bs-theme="dark"] .dropdown-menu {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: #334155 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .border-bottom,
[data-bs-theme="dark"] .border-top {
    border-color: #334155 !important;
}

.theme-toggle-btn {
    cursor: pointer;
    border-radius: 50rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.25s ease;
}

/* ==========================================================================
   8. تحسينات التمرير وعرض البيانات (Scrollbars & Data Facilitation)
   ========================================================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-track {
    background: #0f172a;
}
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #334155;
}
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* شريط التصفية والبحث السريع المدمج (Filter Toolbar) */
.filter-toolbar {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
[data-bs-theme="dark"] .filter-toolbar {
    background: #1e293b;
    border-color: #334155;
}

/* أشرطة التعتيق البيانية (Aging Visual Bars) */
.progress-aging {
    height: 8px;
    border-radius: 6px;
    overflow: hidden;
    background-color: #e2e8f0;
    display: flex;
}
[data-bs-theme="dark"] .progress-aging {
    background-color: #334155;
}
.progress-aging-bar {
    height: 100%;
    transition: width 0.4s ease;
}
.aging-bar-0-30   { background-color: #10b981; }
.aging-bar-31-60  { background-color: #3b82f6; }
.aging-bar-61-90  { background-color: #f59e0b; }
.aging-bar-90-plus{ background-color: #ef4444; }

/* أزرار الانتقال السريع لقطاعات اليومية الأمريكية */
.sector-chip {
    font-size: 0.78rem;
    padding: 0.25rem 0.65rem;
    border-radius: 50rem;
    border: 1px solid #cbd5e1;
    cursor: pointer;
    font-weight: 600;
    background: #ffffff;
    color: #334155;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.sector-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}
[data-bs-theme="dark"] .sector-chip {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}
.sector-chip.active {
    background: var(--color-navy);
    color: #ffffff;
    border-color: var(--color-navy);
}
[data-bs-theme="dark"] .sector-chip.active {
    background: #2563eb;
    border-color: #2563eb;
}

/* جدول الحسابات المحسن (Table Accounting Enhanced) */
.table-accounting tbody tr {
    transition: background-color 0.15s ease;
}
.table-accounting tbody tr:hover {
    background-color: #f8fafc;
}
[data-bs-theme="dark"] .table-accounting tbody tr:hover {
    background-color: #283548 !important;
}
.table-accounting td {
    vertical-align: middle;
}

/* ==========================================================================
   9. مؤشرات القوائم المنسدلة المحسنة والهوية البصرية (Dropdown Select Indicators - RTL)
   ========================================================================== */
select,
.form-select,
select.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem 0.375rem 2.25rem !important; /* مسافة كافية لرمز السهم على اليسار في الواجهة العربية RTL */
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%230284c7' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.2' d='m3 6 5 5 5-5'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: left 0.75rem center !important;
    background-size: 16px 12px !important;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    cursor: pointer;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

select:focus,
.form-select:focus,
select.form-control:focus {
    border-color: #0284c7;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(2, 132, 199, 0.25);
}

select.form-select-sm,
.form-select-sm {
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
    padding-left: 2rem !important;
    padding-right: 0.5rem !important;
    font-size: 0.85rem;
    background-position: left 0.5rem center !important;
    background-size: 13px 10px !important;
    border-radius: 0.25rem;
}

select.form-select-lg,
.form-select-lg {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
    padding-left: 2.75rem !important;
    padding-right: 1rem !important;
    font-size: 1.15rem;
    background-position: left 1rem center !important;
    background-size: 18px 14px !important;
    border-radius: 0.5rem;
}

/* مؤشر القوائم المنسدلة في الوضع الليلي */
[data-bs-theme="dark"] select,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] select.form-control {
    background-color: #0b1120 !important;
    border-color: #475569 !important;
    color: #f8fafc !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2338bdf8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.2' d='m3 6 5 5 5-5'/%3e%3c/svg%3e") !important;
}

[data-bs-theme="dark"] select:focus,
[data-bs-theme="dark"] .form-select:focus,
[data-bs-theme="dark"] select.form-control:focus {
    border-color: #38bdf8 !important;
    box-shadow: 0 0 0 0.25rem rgba(56, 189, 248, 0.25) !important;
}

select:disabled,
.form-select:disabled,
select.form-control:disabled {
    background-color: #f1f5f9 !important;
    opacity: 0.7;
    cursor: not-allowed;
}

[data-bs-theme="dark"] select:disabled,
[data-bs-theme="dark"] .form-select:disabled,
[data-bs-theme="dark"] select.form-control:disabled {
    background-color: #1e293b !important;
    opacity: 0.6;
    cursor: not-allowed;
}

/* القوائم متعددة الاختيار أو ذات الأسطر المتعددة لا تحتاج لسهم القائمة */
select[multiple],
.form-select[multiple],
select[size]:not([size="1"]),
.form-select[size]:not([size="1"]) {
    padding-left: 0.75rem !important;
    background-image: none !important;
}

/* مؤشر القوائم المنسدلة للأزرار (Dropdown Toggle Caret) */
.dropdown-toggle::after {
    display: inline-block;
    margin-right: 0.45em;
    vertical-align: 0.2em;
    content: "";
    border-top: 0.35em solid currentColor;
    border-right: 0.3em solid transparent;
    border-bottom: 0;
    border-left: 0.3em solid transparent;
}


