/**
 * ALKAFEEL UNIVERSITY ENTERPRISE CLEAN MINIMAL DESIGN SYSTEM
 * نظام التصميم المؤسسي الموحد - جامعة الكفيل
 * مبني وفق معايير Enterprise UI/UX Clean Minimal
 */

/* ==========================================================================
   1. GLOBAL DESIGN TOKENS (الألوان والقياسات الموحدة)
   ========================================================================== */
:root {
    /* ─── 1.1 Brand Palette (هوية رصينة وواحدة) ─── */
    --ak-primary:            #0A3D62; /* كحلي مؤسسي رصين */
    --ak-primary-hover:      #072A43;
    --ak-primary-light:      #17467C;
    --ak-primary-subtle:     rgba(10, 61, 98, 0.05);
    --ak-primary-border:     rgba(10, 61, 98, 0.15);

    /* ─── 1.2 Neutral Surfaces & Backgrounds ─── */
    --ak-bg-app:             #F8FAFC; /* خلفية محايدة ناصعة وهادئة */
    --ak-surface:            #FFFFFF; /* السطح الأساسي */
    --ak-surface-subtle:     #F1F5F9; /* سطح ثانوي / هيدر الجداول */
    --ak-surface-hover:      #F8FAFC;
    --ak-surface-active:     #E2E8F0;

    /* ─── 1.3 Borders & Separators (حدود دقيقة وناعمة) ─── */
    --ak-border:             #E2E8F0;
    --ak-border-subtle:      #EDF2F7;
    --ak-border-focus:       #0A3D62;

    /* ─── 1.4 High-Contrast Typography ─── */
    --ak-text-primary:       #0F172A; /* نص رئيسي داكن وواضح */
    --ak-text-secondary:     #334155; /* نص ثانوي */
    --ak-text-muted:         #64748B; /* نص توضيحي / وصف */
    --ak-text-disabled:      #94A3B8;

    /* ─── 1.5 Semantic Status Colors (دلالية وظيفية صارمة) ─── */
    --ak-success:            #059669; /* أخضر: اعتماد ومصادقة ونجاح */
    --ak-success-hover:      #047857;
    --ak-success-subtle:     #ECFDF5;
    --ak-success-border:     #A7F3D0;

    --ak-warning:            #D97706; /* كهرماني: انتظار ومراجعة وتنبيه */
    --ak-warning-hover:      #B45309;
    --ak-warning-subtle:     #FFFBEB;
    --ak-warning-border:     #FDE68A;

    --ak-danger:             #DC2626; /* أحمر: رفض وتعديل وحذف وإلغاء */
    --ak-danger-hover:       #B91C1C;
    --ak-danger-subtle:      #FEF2F2;
    --ak-danger-border:      #FECACA;

    --ak-info:               #2563EB; /* أزرق: معلومات وإرشاد */
    --ak-info-hover:         #1D4ED8;
    --ak-info-subtle:        #EFF6FF;
    --ak-info-border:        #BFDBFE;

    /* ─── 1.6 Component Geometry (أبعاد هندسية موحدة) ─── */
    --ak-radius-xs:          3px;
    --ak-radius-sm:          5px;
    --ak-radius-md:          7px;
    --ak-radius-lg:          9px;
    --ak-radius-pill:        9999px;

    /* Standard Heights */
    --ak-height-sm:          30px;
    --ak-height-md:          36px; /* القياس القياسي للأزرار والمدخلات */
    --ak-height-lg:          42px;

    /* Shadows (ظلال هادئة ودقيقة خالية من البهرجة) */
    --ak-shadow-xs:          0 1px 2px rgba(15, 23, 42, 0.04);
    --ak-shadow-sm:          0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
    --ak-shadow-md:          0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -1px rgba(15, 23, 42, 0.03);

    /* Spacing scale */
    --ak-space-1:            0.25rem; /* 4px */
    --ak-space-2:            0.5rem;  /* 8px */
    --ak-space-3:            0.75rem; /* 12px */
    --ak-space-4:            1rem;    /* 16px */
    --ak-space-5:            1.25rem; /* 20px */
    --ak-space-6:            1.5rem;  /* 24px */
    --ak-space-8:            2rem;    /* 32px */

    /* Transitions */
    --ak-transition:         all 0.15s ease-in-out;
}

/* ==========================================================================
   2. DARK STYLE TOKENS (الوضع الليلي المتناسق)
   ========================================================================== */
.dark-style {
    --ak-primary:            #38BDF8;
    --ak-primary-hover:      #0EA5E9;
    --ak-primary-light:      #7DD3FC;
    --ak-primary-subtle:     rgba(56, 189, 248, 0.08);
    --ak-primary-border:     rgba(56, 189, 248, 0.2);

    --ak-bg-app:             #0B1120;
    --ak-surface:            #1E293B;
    --ak-surface-subtle:     #172033;
    --ak-surface-hover:      #243044;
    --ak-surface-active:     #334155;

    --ak-border:             rgba(255, 255, 255, 0.08);
    --ak-border-subtle:      rgba(255, 255, 255, 0.04);
    --ak-border-focus:       #38BDF8;

    --ak-text-primary:       #F8FAFC;
    --ak-text-secondary:     #CBD5E1;
    --ak-text-muted:         #94A3B8;
    --ak-text-disabled:      #64748B;

    --ak-success:            #34D399;
    --ak-success-subtle:     rgba(52, 211, 153, 0.12);
    --ak-success-border:     rgba(52, 211, 153, 0.25);

    --ak-warning:            #FBBF24;
    --ak-warning-subtle:     rgba(251, 191, 36, 0.12);
    --ak-warning-border:     rgba(251, 191, 36, 0.25);

    --ak-danger:             #F87171;
    --ak-danger-subtle:      rgba(248, 113, 113, 0.12);
    --ak-danger-border:      rgba(248, 113, 113, 0.25);

    --ak-info:               #60A5FA;
    --ak-info-subtle:        rgba(96, 165, 250, 0.12);
    --ak-info-border:        rgba(96, 165, 250, 0.25);

    --ak-shadow-sm:          0 1px 3px rgba(0, 0, 0, 0.3);
    --ak-shadow-md:          0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   3. GLOBAL RESET & TYPOGRAPHY
   ========================================================================== */
body, input, button, select, textarea, .form-control, .form-select, .btn, .card, .table, h1, h2, h3, h4, h5, h6, p, a, span, label, div {
    font-family: 'Tajawal', 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--ak-bg-app) !important;
    color: var(--ak-text-primary) !important;
    font-size: 0.875rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Hierarchy: clean, intentional, not oversized */
h1, .h1 { font-size: 1.375rem; font-weight: 700; line-height: 1.3; color: var(--ak-text-primary); margin-bottom: 0.5rem; }
h2, .h2 { font-size: 1.25rem; font-weight: 700; line-height: 1.35; color: var(--ak-text-primary); margin-bottom: 0.5rem; }
h3, .h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.4; color: var(--ak-text-primary); margin-bottom: 0.5rem; }
h4, .h4 { font-size: 1rem; font-weight: 600; line-height: 1.4; color: var(--ak-text-primary); margin-bottom: 0.35rem; }
h5, .h5 { font-size: 0.9375rem; font-weight: 600; line-height: 1.4; color: var(--ak-text-primary); margin-bottom: 0.25rem; }
h6, .h6 { font-size: 0.875rem; font-weight: 600; line-height: 1.4; color: var(--ak-text-secondary); margin-bottom: 0.25rem; }

.text-muted { color: var(--ak-text-muted) !important; }
.text-secondary { color: var(--ak-text-secondary) !important; }
.text-primary { color: var(--ak-primary) !important; }

/* Link styling */
a {
    color: var(--ak-primary);
    text-decoration: none;
    transition: var(--ak-transition);
}
a:hover {
    color: var(--ak-primary-hover);
}

/* ==========================================================================
   4. COMPACT STANDARDIZED PAGE HEADER (معالجة Problem A)
   ========================================================================== */
/* النمط المؤسسي النظيف: مساحة واضحة، بدون خلفيات ملونة ضخمة أو أيقونات زخرفية */
.ak-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    padding-bottom: 1rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--ak-border);
    background: transparent;
}

.ak-page-header-main {
    flex: 1 1 auto;
    min-width: 250px;
}

/* Breadcrumb Navigation */
.ak-breadcrumb {
    margin-bottom: 0.35rem;
}
.ak-breadcrumb .breadcrumb {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0;
    padding: 0;
    font-size: 0.78rem;
    line-height: 1.4;
    background: transparent;
}
.ak-breadcrumb .breadcrumb-item {
    display: inline-flex;
    align-items: center;
    color: var(--ak-text-muted);
    line-height: 1.4;
}
.ak-breadcrumb .breadcrumb-item a {
    color: var(--ak-text-muted);
    display: inline-flex;
    align-items: center;
    line-height: inherit;
}
.ak-breadcrumb .breadcrumb-item a:hover {
    color: var(--ak-primary);
}
.ak-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.45rem;
    color: var(--ak-text-disabled);
    font-size: 0.95rem;
    line-height: 1;
    height: 1em;
    vertical-align: middle;
    transform: translateY(-1.5px);
}
.ak-breadcrumb .breadcrumb-item.active {
    color: var(--ak-text-secondary);
    font-weight: 500;
}

/* Page Title & Subtitle */
.ak-page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ak-text-primary);
    margin: 0 0 0.15rem 0;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.ak-page-subtitle {
    font-size: 0.8125rem;
    color: var(--ak-text-muted);
    margin: 0;
    line-height: 1.4;
}

/* Action button area */
.ak-page-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ==========================================================================
   5. STRICT ACTION HIERARCHY & BUTTONS (معالجة Problem E & Sec 10)
   ========================================================================== */
.btn {
    font-weight: 500;
    font-size: 0.84rem;
    height: var(--ak-height-md);
    padding: 0 0.95rem;
    border-radius: var(--ak-radius-md);
    transition: var(--ak-transition);
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    vertical-align: middle !important;
    gap: 0.35rem !important;
    line-height: 1.35 !important;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}

.btn:focus, .btn:active {
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(10, 61, 98, 0.15);
}

.btn-sm {
    height: var(--ak-height-sm) !important;
    min-height: var(--ak-height-sm) !important;
    padding: 0 0.75rem !important;
    font-size: 0.78rem !important;
    border-radius: var(--ak-radius-sm) !important;
    gap: 0.3rem !important;
    line-height: 1.35 !important;
}

.btn-xs {
    height: 25px !important;
    min-height: 25px !important;
    padding: 0 0.55rem !important;
    font-size: 0.72rem !important;
    font-weight: 600 !important;
    border-radius: var(--ak-radius-sm) !important;
    gap: 0.25rem !important;
    line-height: 1.3 !important;
}

.btn-lg {
    height: var(--ak-height-lg) !important;
    min-height: var(--ak-height-lg) !important;
    padding: 0 1.25rem !important;
    font-size: 0.9375rem !important;
    border-radius: var(--ak-radius-lg) !important;
    gap: 0.45rem !important;
    line-height: 1.4 !important;
}

/* Button Icons - Universal Perfect Centering */
.btn i,
.btn [class^="ti-"],
.btn [class*=" ti-"],
.btn .fa,
.btn .fas,
.btn .far,
.btn svg {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    vertical-align: middle !important;
    line-height: 1 !important;
    font-size: 1.1em !important;
    margin: 0 !important;
    align-self: center !important;
    flex-shrink: 0 !important;
}

.btn-xs i,
.btn-xs [class^="ti-"],
.btn-xs [class*=" ti-"] {
    font-size: 0.82rem !important;
}

.btn-sm i,
.btn-sm [class^="ti-"],
.btn-sm [class*=" ti-"] {
    font-size: 0.92rem !important;
}

/* Square Icon-Only Button */
.btn-icon {
    width: var(--ak-height-md);
    height: var(--ak-height-md);
    padding: 0 !important;
    border-radius: var(--ak-radius-sm);
    flex-shrink: 0;
}
.btn-icon.btn-sm {
    width: var(--ak-height-sm);
    height: var(--ak-height-sm);
}
.btn-icon.btn-xs {
    width: 25px !important;
    height: 25px !important;
}

/* ─── 5.1 Primary Action (أهم إجراء في الصفحة - واحد فقط) ─── */
.btn-primary {
    background-color: var(--ak-primary) !important;
    border-color: var(--ak-primary) !important;
    color: #FFFFFF !important;
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--ak-primary-hover) !important;
    border-color: var(--ak-primary-hover) !important;
    color: #FFFFFF !important;
}

/* ─── 5.2 Secondary Action (إجراء داعم / ثانوي) ─── */
.btn-secondary,
.btn-outline-secondary {
    background-color: var(--ak-surface) !important;
    border-color: var(--ak-border) !important;
    color: var(--ak-text-secondary) !important;
}
.btn-secondary:hover,
.btn-outline-secondary:hover {
    background-color: var(--ak-surface-subtle) !important;
    border-color: #CBD5E1 !important;
    color: var(--ak-text-primary) !important;
}

.btn-outline-primary {
    background-color: transparent !important;
    border-color: var(--ak-primary) !important;
    color: var(--ak-primary) !important;
}
.btn-outline-primary:hover {
    background-color: var(--ak-primary-subtle) !important;
    color: var(--ak-primary-hover) !important;
}

/* ─── 5.3 Tertiary Action / Ghost ─── */
.btn-ghost {
    background-color: transparent !important;
    border-color: transparent !important;
    color: var(--ak-text-secondary) !important;
}
.btn-ghost:hover {
    background-color: var(--ak-surface-subtle) !important;
    color: var(--ak-text-primary) !important;
}

/* ─── 5.4 Destructive Action (إجراءات الحذف والإلغاء الصريحة فقط) ─── */
.btn-danger,
.btn-outline-danger {
    background-color: transparent !important;
    border-color: var(--ak-danger-border) !important;
    color: var(--ak-danger) !important;
}
.btn-danger:hover,
.btn-outline-danger:hover {
    background-color: var(--ak-danger) !important;
    border-color: var(--ak-danger) !important;
    color: #FFFFFF !important;
}
.btn-danger-solid {
    background-color: var(--ak-danger) !important;
    border-color: var(--ak-danger) !important;
    color: #FFFFFF !important;
}
.btn-danger-solid:hover {
    background-color: var(--ak-danger-hover) !important;
    border-color: var(--ak-danger-hover) !important;
}

/* ─── 5.5 Success Button ─── */
.btn-success {
    background-color: var(--ak-success) !important;
    border-color: var(--ak-success) !important;
    color: #FFFFFF !important;
}
.btn-success:hover {
    background-color: var(--ak-success-hover) !important;
    border-color: var(--ak-success-hover) !important;
}
.btn-outline-success {
    background-color: transparent !important;
    border-color: var(--ak-success-border) !important;
    color: var(--ak-success) !important;
}
/* ─── 5.6 Soft Semantic Label Buttons (تخفيف الأزرار الدلالية الملونة) ─── */
.btn-label-primary {
    background-color: var(--ak-primary-subtle) !important;
    border-color: var(--ak-primary-border) !important;
    color: var(--ak-primary) !important;
}
.btn-label-primary:hover {
    background-color: var(--ak-primary) !important;
    color: #FFFFFF !important;
}

.btn-label-secondary {
    background-color: var(--ak-surface-subtle) !important;
    border-color: var(--ak-border) !important;
    color: var(--ak-text-secondary) !important;
}
.btn-label-secondary:hover {
    background-color: var(--ak-border) !important;
    color: var(--ak-text-primary) !important;
}

.btn-label-success {
    background-color: var(--ak-success-subtle) !important;
    border-color: var(--ak-success-border) !important;
    color: var(--ak-success) !important;
}
.btn-label-success:hover {
    background-color: var(--ak-success) !important;
    color: #FFFFFF !important;
}

.btn-label-warning {
    background-color: var(--ak-warning-subtle) !important;
    border-color: var(--ak-warning-border) !important;
    color: var(--ak-warning) !important;
}
.btn-label-warning:hover {
    background-color: var(--ak-warning) !important;
    color: #FFFFFF !important;
}

.btn-label-danger {
    background-color: var(--ak-danger-subtle) !important;
    border-color: var(--ak-danger-border) !important;
    color: var(--ak-danger) !important;
}
.btn-label-danger:hover {
    background-color: var(--ak-danger) !important;
    color: #FFFFFF !important;
}

.btn-label-info {
    background-color: var(--ak-info-subtle) !important;
    border-color: var(--ak-info-border) !important;
    color: var(--ak-info) !important;
}
.btn-label-info:hover {
    background-color: var(--ak-info) !important;
    color: #FFFFFF !important;
}

/* ==========================================================================
   6. CARDS & CONTENT SURFACES (معالجة Problem C: منع التشتت والبطاقات الفائضة)
   ========================================================================== */
.card, .ak-surface-card {
    background: var(--ak-surface);
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-lg);
    box-shadow: var(--ak-shadow-xs);
    margin-bottom: 1.25rem;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--ak-border);
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Stepper and Multi-section Card Headers must stack cleanly */
.form-step-card .card-header,
.card-header.ak-stepper-header,
.card-header.d-block {
    display: block !important;
    width: 100% !important;
}

@media (max-width: 768px) {
    .card-header:not(.d-flex-mobile) {
        display: block !important;
        width: 100% !important;
    }
}
.card-header h5, .card-header h6, .card-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--ak-text-primary);
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background: var(--ak-surface-subtle);
    border-top: 1px solid var(--ak-border);
    padding: 0.75rem 1.25rem;
}

/* Section divider within card/page */
.ak-section-divider {
    border-top: 1px solid var(--ak-border-subtle);
    margin: 1.25rem 0;
}

/* Section header without card */
.ak-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--ak-border-subtle);
}
.ak-section-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--ak-text-primary);
    margin: 0;
}

/* ==========================================================================
   7. CLEAN DATA TABLES (معالجة Section 9: جداول بيانات مهنية ومريحة)
   ========================================================================== */
.ak-table-container,
.table-responsive {
    background: var(--ak-surface);
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-lg);
    overflow: hidden;
}

.table {
    margin-bottom: 0;
    width: 100%;
    vertical-align: middle;
    border-collapse: collapse;
}

.table > thead th {
    background-color: var(--ak-surface-subtle) !important;
    color: var(--ak-text-secondary) !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    padding: 0.65rem 0.85rem !important;
    border-bottom: 1px solid var(--ak-border) !important;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.table > tbody > tr {
    border-bottom: 1px solid var(--ak-border-subtle);
    transition: background-color 0.12s ease;
}

.table > tbody > tr:hover {
    background-color: var(--ak-surface-subtle) !important;
}

.table > tbody > tr > td {
    padding: 0.65rem 0.85rem !important;
    font-size: 0.8125rem;
    color: var(--ak-text-primary);
    vertical-align: middle;
}

/* Table empty state */
.ak-table-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--ak-text-muted);
}
.ak-table-empty i {
    font-size: 2.25rem;
    color: var(--ak-text-disabled);
    margin-bottom: 0.5rem;
    display: block;
}

/* Compact Table Row Actions */
.ak-row-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Table Dropdown Menu & Action Button (همبركر بتن مجاور للاسم) */
.table-responsive {
    min-height: 240px;
}
.table td .dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.table td .dropdown-menu {
    z-index: 1060 !important;
    min-width: 205px;
    box-shadow: 0 10px 25px -5px rgba(10, 61, 98, 0.12), 0 8px 10px -6px rgba(10, 61, 98, 0.08) !important;
    border: 1px solid var(--ak-border) !important;
    border-radius: var(--ak-radius-md) !important;
}
.table td .dropdown-item {
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    border-radius: var(--ak-radius-sm);
    transition: var(--ak-transition);
}
.table td .dropdown-item:hover {
    background-color: var(--ak-surface-subtle);
}
.table td .dropdown-item.text-danger:hover {
    background-color: var(--ak-danger-subtle);
    color: var(--ak-danger) !important;
}

/* ==========================================================================
   8. UNIFIED SEARCH & FILTER PANEL (معالجة Section 11)
   ========================================================================== */
.ak-filter-panel {
    background: var(--ak-surface);
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-lg);
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
}

.ak-filter-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ak-text-secondary);
    margin-bottom: 0.3rem;
    display: block;
}

/* ==========================================================================
   9. FORMS & INPUTS (معالجة Section 8: قوالب النماذج النظيفة)
   ========================================================================== */
.form-label {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--ak-text-secondary);
    margin-bottom: 0.3rem;
    display: inline-block;
}

.form-control, .form-select {
    height: var(--ak-height-md);
    border: 1px solid var(--ak-border) !important;
    border-radius: var(--ak-radius-md);
    padding: 0.35rem 0.75rem;
    font-size: 0.84rem;
    color: var(--ak-text-primary) !important;
    background-color: var(--ak-surface) !important;
    transition: var(--ak-transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--ak-border-focus) !important;
    box-shadow: 0 0 0 2px var(--ak-primary-subtle) !important;
    outline: none;
}

.form-control-sm, .form-select-sm {
    height: var(--ak-height-sm);
    padding: 0.2rem 0.6rem;
    font-size: 0.78rem;
    border-radius: var(--ak-radius-sm);
}

textarea.form-control {
    height: auto;
    min-height: 80px;
}

/* ==========================================================================
   9.1 UNIFIED SEAMLESS INPUT GROUPS (RTL & LTR)
   ========================================================================== */
.input-group {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    position: relative !important;
    width: 100% !important;
}

.input-group > .form-control,
.input-group > .form-select,
.input-group > .input-group-text,
.input-group > .btn {
    position: relative;
    display: flex;
    align-items: center;
    margin: 0 !important;
    height: var(--ak-height-md) !important;
}

.input-group > .form-control,
.input-group > .form-select {
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

.input-group-sm > .form-control,
.input-group-sm > .form-select,
.input-group-sm > .input-group-text,
.input-group-sm > .btn {
    height: var(--ak-height-sm) !important;
    font-size: 0.78rem !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.input-group-lg > .form-control,
.input-group-lg > .form-select,
.input-group-lg > .input-group-text,
.input-group-lg > .btn {
    height: var(--ak-height-lg) !important;
    font-size: 0.95rem !important;
}

/* Input Group Addon (.input-group-text) */
.input-group-text {
    background-color: var(--ak-surface-subtle) !important;
    border: 1px solid var(--ak-border) !important;
    color: var(--ak-text-muted);
    font-size: 0.84rem;
    padding: 0 0.75rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap !important;
    line-height: 1 !important;
    transition: var(--ak-transition);
}

.input-group-sm > .input-group-text {
    padding: 0 0.55rem !important;
}

/* Icon inside Addon - Absolute Vertical & Horizontal Centering */
.input-group-text i,
.input-group-text [class^="ti-"],
.input-group-text [class*=" ti-"],
.input-group-text .fa,
.input-group-text .fas,
.input-group-text .far,
.input-group-text svg {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    vertical-align: middle !important;
    line-height: 1 !important;
    margin: 0 !important;
    font-size: 1.15rem !important;
    align-self: center !important;
    flex-shrink: 0 !important;
}

.input-group-sm > .input-group-text i,
.input-group-sm > .input-group-text [class^="ti-"],
.input-group-sm > .input-group-text [class*=" ti-"] {
    font-size: 0.95rem !important;
}

/* ─── RTL Seamless Connection (Right to Left) ─── */
/* In RTL, :first-child is on the RIGHT; :last-child is on the LEFT */
html[dir="rtl"] .input-group > :first-child:not(:last-child),
[dir="rtl"] .input-group > :first-child:not(:last-child),
.input-group > :first-child:not(:last-child) {
    border-top-right-radius: var(--ak-radius-md) !important;
    border-bottom-right-radius: var(--ak-radius-md) !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-left: 0 !important;
}

html[dir="rtl"] .input-group > :last-child:not(:first-child),
[dir="rtl"] .input-group > :last-child:not(:first-child),
.input-group > :last-child:not(:first-child) {
    border-top-left-radius: var(--ak-radius-md) !important;
    border-bottom-left-radius: var(--ak-radius-md) !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

html[dir="rtl"] .input-group > :not(:first-child):not(:last-child),
[dir="rtl"] .input-group > :not(:first-child):not(:last-child),
.input-group > :not(:first-child):not(:last-child) {
    border-radius: 0 !important;
    border-left: 0 !important;
}

/* Small input-group radii */
html[dir="rtl"] .input-group-sm > :first-child:not(:last-child),
[dir="rtl"] .input-group-sm > :first-child:not(:last-child),
.input-group-sm > :first-child:not(:last-child) {
    border-top-right-radius: var(--ak-radius-sm) !important;
    border-bottom-right-radius: var(--ak-radius-sm) !important;
}

html[dir="rtl"] .input-group-sm > :last-child:not(:first-child),
[dir="rtl"] .input-group-sm > :last-child:not(:first-child),
.input-group-sm > :last-child:not(:first-child) {
    border-top-left-radius: var(--ak-radius-sm) !important;
    border-bottom-left-radius: var(--ak-radius-sm) !important;
}

/* ─── LTR Explicit Overrides ─── */
html[dir="ltr"] .input-group > :first-child:not(:last-child),
[dir="ltr"] .input-group > :first-child:not(:last-child) {
    border-top-left-radius: var(--ak-radius-md) !important;
    border-bottom-left-radius: var(--ak-radius-md) !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-right: 0 !important;
    border-left: 1px solid var(--ak-border) !important;
}

html[dir="ltr"] .input-group > :last-child:not(:first-child),
[dir="ltr"] .input-group > :last-child:not(:first-child) {
    border-top-right-radius: var(--ak-radius-md) !important;
    border-bottom-right-radius: var(--ak-radius-md) !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

html[dir="ltr"] .input-group > :not(:first-child):not(:last-child),
[dir="ltr"] .input-group > :not(:first-child):not(:last-child) {
    border-radius: 0 !important;
    border-right: 0 !important;
}

/* ─── Unified Focus Group ─── */
.input-group:focus-within {
    box-shadow: 0 0 0 2px var(--ak-primary-subtle) !important;
    border-radius: var(--ak-radius-md) !important;
}

.input-group-sm:focus-within {
    border-radius: var(--ak-radius-sm) !important;
}

.input-group:focus-within > .form-control,
.input-group:focus-within > .form-select {
    border-color: var(--ak-border-focus) !important;
    box-shadow: none !important;
    z-index: 3;
}

.input-group:focus-within > .input-group-text {
    border-color: var(--ak-border-focus) !important;
    color: var(--ak-primary) !important;
    background-color: var(--ak-surface-hover) !important;
}

/* Form Helper Text */
.form-text, .helper-text {
    font-size: 0.75rem;
    color: var(--ak-text-muted);
    margin-top: 0.25rem;
}

/* Required Indicator */
.ak-required, .required-star {
    color: var(--ak-danger);
    margin-right: 2px;
    font-weight: 700;
}

/* Checkbox and Radio */
.form-check-input {
    border-color: #CBD5E1;
}
.form-check-input:checked {
    background-color: var(--ak-primary);
    border-color: var(--ak-primary);
}
.form-check-label {
    font-size: 0.84rem;
    color: var(--ak-text-secondary);
}

/* ==========================================================================
   10. SEMANTIC STATUS BADGES (معالجة Problem D)
   ========================================================================== */
.badge {
    padding: 0.22rem 0.55rem !important;
    font-size: 0.72rem !important;
    font-weight: 600 !important;
    border-radius: var(--ak-radius-sm) !important;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    line-height: 1.2;
}

/* Approved / Success / Completed */
.badge-ak-success,
.badge-approved {
    background-color: var(--ak-success-subtle) !important;
    color: var(--ak-success) !important;
    border: 1px solid var(--ak-success-border);
}

/* Pending / Review / Warning */
.badge-ak-warning,
.badge-pending {
    background-color: var(--ak-warning-subtle) !important;
    color: var(--ak-warning) !important;
    border: 1px solid var(--ak-warning-border);
}

/* Rejected / Modification / Error */
.badge-ak-danger,
.badge-rejected {
    background-color: var(--ak-danger-subtle) !important;
    color: var(--ak-danger) !important;
    border: 1px solid var(--ak-danger-border);
}

/* Info / Active */
.badge-ak-info,
.badge-info {
    background-color: var(--ak-info-subtle) !important;
    color: var(--ak-info) !important;
    border: 1px solid var(--ak-info-border);
}

/* Neutral / Secondary / Draft */
.badge-ak-secondary,
.badge-draft {
    background-color: var(--ak-surface-subtle) !important;
    color: var(--ak-text-muted) !important;
    border: 1px solid var(--ak-border);
}

.badge-ak-primary {
    background-color: var(--ak-primary-subtle) !important;
    color: var(--ak-primary) !important;
    border: 1px solid var(--ak-primary-border);
}

/* ==========================================================================
   11. COMPACT WORKFLOW STEPPER (معالجة Problem B: بديل نظيف لمؤشر الخطوات الضخم)
   ========================================================================== */
.ak-workflow-stepper {
    background: var(--ak-surface);
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-lg);
    padding: 0.65rem 0.85rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    overflow-x: auto;
}

.ak-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.65rem;
    border-radius: var(--ak-radius-md);
    cursor: pointer;
    transition: var(--ak-transition);
    color: var(--ak-text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid transparent;
}

.ak-step:hover {
    background-color: var(--ak-surface-subtle);
    color: var(--ak-text-primary);
}

.ak-step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--ak-surface-subtle);
    border: 1px solid var(--ak-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--ak-text-muted);
    flex-shrink: 0;
}

.ak-step.active {
    background-color: var(--ak-primary-subtle);
    color: var(--ak-primary);
    font-weight: 600;
    border-color: var(--ak-primary-border);
}
.ak-step.active .ak-step-number {
    background-color: var(--ak-primary);
    color: #FFFFFF;
    border-color: var(--ak-primary);
}

.ak-step.completed {
    color: var(--ak-text-secondary);
}
.ak-step.completed .ak-step-number {
    background-color: var(--ak-success-subtle);
    color: var(--ak-success);
    border-color: var(--ak-success-border);
}

.ak-step-divider {
    flex-grow: 1;
    height: 1px;
    background-color: var(--ak-border);
    min-width: 16px;
    max-width: 40px;
}
.ak-step-divider.completed {
    background-color: var(--ak-success);
}

/* Fallback for existing legacy step selectors */
.steps-nav {
    background: var(--ak-surface) !important;
    border: 1px solid var(--ak-border) !important;
    border-radius: var(--ak-radius-lg) !important;
    padding: 0.65rem 0.85rem !important;
    margin-bottom: 1.25rem !important;
    gap: 0.35rem !important;
}
.step-item {
    font-size: 0.8125rem !important;
    color: var(--ak-text-muted) !important;
    gap: 0.45rem !important;
}
.step-item.active {
    color: var(--ak-primary) !important;
    font-weight: 600 !important;
}
.step-num {
    width: 24px !important;
    height: 24px !important;
    font-size: 0.75rem !important;
    background: var(--ak-surface-subtle) !important;
    border: 1px solid var(--ak-border) !important;
    color: var(--ak-text-muted) !important;
    box-shadow: none !important;
}
.step-item.active .step-num {
    background: var(--ak-primary) !important;
    color: #FFFFFF !important;
    border-color: var(--ak-primary) !important;
    box-shadow: none !important;
}
.step-item.completed .step-num {
    background: var(--ak-success-subtle) !important;
    color: var(--ak-success) !important;
    border-color: var(--ak-success-border) !important;
    box-shadow: none !important;
}
.step-divider {
    height: 1px !important;
    background: var(--ak-border) !important;
    max-width: 35px !important;
}
.step-divider.completed {
    background: var(--ak-success) !important;
}

/* ==========================================================================
   12. KPI & ANALYTICAL CARDS (للوحات القياس والتقارير حصراً - Section 7)
   ========================================================================== */
.ak-kpi-card {
    background: var(--ak-surface);
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-lg);
    padding: 1rem 1.15rem;
    box-shadow: var(--ak-shadow-xs);
}

.ak-kpi-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ak-text-muted);
    margin-bottom: 0.25rem;
}

.ak-kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ak-text-primary);
    line-height: 1.2;
}

.ak-kpi-meta {
    font-size: 0.75rem;
    color: var(--ak-text-muted);
    margin-top: 0.25rem;
}

/* Compatible wrapper for legacy ak-stat-card */
.ak-stat-card {
    background: var(--ak-surface) !important;
    border: 1px solid var(--ak-border) !important;
    border-radius: var(--ak-radius-md) !important;
    padding: 0.85rem 1rem !important;
    box-shadow: var(--ak-shadow-xs) !important;
}
.ak-stat-number {
    font-size: 1.35rem !important;
    font-weight: 700 !important;
    color: var(--ak-text-primary) !important;
}
.ak-stat-label {
    font-size: 0.78rem !important;
    color: var(--ak-text-muted) !important;
    font-weight: 500 !important;
}
.ak-stat-icon-wrapper {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    font-size: 1.15rem !important;
    border-radius: var(--ak-radius-sm) !important;
}

/* ==========================================================================
   13. ALERTS & SYSTEM FEEDBACK
   ========================================================================== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--ak-radius-md);
    font-size: 0.84rem;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1rem;
}
.alert-success {
    background-color: var(--ak-success-subtle);
    border-color: var(--ak-success-border);
    color: var(--ak-success);
}
.alert-warning {
    background-color: var(--ak-warning-subtle);
    border-color: var(--ak-warning-border);
    color: var(--ak-warning);
}
.alert-danger {
    background-color: var(--ak-danger-subtle);
    border-color: var(--ak-danger-border);
    color: var(--ak-danger);
}
.alert-info {
    background-color: var(--ak-info-subtle);
    border-color: var(--ak-info-border);
    color: var(--ak-info);
}

/* ==========================================================================
   14. TABS & WORKSPACE NAVIGATION
   ========================================================================== */
.nav-tabs {
    border-bottom: 1px solid var(--ak-border);
}
.nav-tabs .nav-link {
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--ak-text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.65rem 1rem;
    background: transparent;
    transition: var(--ak-transition);
}
.nav-tabs .nav-link:hover {
    color: var(--ak-text-primary);
    border-bottom-color: var(--ak-border);
}
.nav-tabs .nav-link.active {
    color: var(--ak-primary);
    font-weight: 600;
    border-bottom-color: var(--ak-primary);
    background: transparent;
}

/* ==========================================================================
   15. MODALS & OVERLAYS
   ========================================================================== */
.modal-content {
    background-color: var(--ak-surface);
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-lg);
    box-shadow: var(--ak-shadow-md);
}
.modal-header {
    border-bottom: 1px solid var(--ak-border);
    padding: 0.85rem 1.25rem;
}
.modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ak-text-primary);
}
.modal-footer {
    border-top: 1px solid var(--ak-border);
    padding: 0.75rem 1.25rem;
    gap: 0.5rem;
}

/* Dropdown Menu */
.dropdown-menu {
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-md);
    box-shadow: var(--ak-shadow-md);
    padding: 0.35rem;
    min-width: 180px;
    background-color: var(--ak-surface);
}
.dropdown-item {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ak-text-secondary);
    padding: 0.45rem 0.75rem;
    border-radius: var(--ak-radius-sm);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    transition: var(--ak-transition);
}
.dropdown-item:hover {
    background-color: var(--ak-surface-subtle);
    color: var(--ak-primary);
}
.dropdown-item.text-danger:hover {
    background-color: var(--ak-danger-subtle);
    color: var(--ak-danger) !important;
}

/* Pagination */
.pagination {
    margin-bottom: 0;
    gap: 0.25rem;
}
.page-link {
    font-size: 0.8125rem;
    height: 32px;
    min-width: 32px;
    padding: 0 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ak-radius-sm) !important;
    border: 1px solid var(--ak-border);
    color: var(--ak-text-secondary);
    background-color: var(--ak-surface);
}
.page-link:hover {
    background-color: var(--ak-surface-subtle);
    color: var(--ak-primary);
    border-color: #CBD5E1;
}
.page-item.active .page-link {
    background-color: var(--ak-primary) !important;
    border-color: var(--ak-primary) !important;
    color: #FFFFFF !important;
}

/* ==========================================================================
   16. SIDEBAR & APP SHELL REFINEMENT
   ========================================================================== */
#layout-menu {
    background-color: #081B2E !important; /* لون جانبي رصين متدرج بهدوء */
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}
.menu-item .menu-link {
    font-size: 0.84rem;
    font-weight: 500;
    border-radius: var(--ak-radius-md);
    margin: 0.15rem 0.75rem;
    padding: 0.55rem 0.85rem;
    color: rgba(255, 255, 255, 0.75) !important;
    transition: var(--ak-transition);
}
.menu-item .menu-link:hover {
    background-color: rgba(255, 255, 255, 0.06) !important;
    color: #FFFFFF !important;
}
.menu-item.active > .menu-link {
    background-color: var(--ak-primary-light) !important;
    color: #FFFFFF !important;
    font-weight: 600;
}
.menu-header-text {
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.4) !important;
}

/* Clean Top Navbar */
#layout-navbar {
    background-color: var(--ak-surface) !important;
    border-bottom: 1px solid var(--ak-border);
    box-shadow: none !important;
    height: 56px;
    padding: 0 1.25rem;
}

/* ==========================================================================
   17. RESPONSIVE DESIGN (معالجة Section 13)
   ========================================================================== */
@media (max-width: 768px) {
    .ak-page-header {
        flex-direction: column;
        align-items: stretch;
    }
    .ak-page-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .ak-workflow-stepper {
        padding: 0.5rem;
    }
    .ak-step {
        padding: 0.35rem 0.5rem;
    }
    .ak-step-title {
        display: none; /* Hide text on small screens, keep step number */
    }
    .table-responsive {
        border-radius: var(--ak-radius-md);
    }
}

/* ==========================================================================
   18. MODAL & BACKDROP STACKING (حل مشكلة حجب المودال بواسطة الـ backdrop)
   ========================================================================== */
.modal {
    z-index: 1095 !important;
}
.modal.show {
    z-index: 1095 !important;
}
.modal-backdrop {
    z-index: 1080 !important;
}
.modal-backdrop.show {
    z-index: 1080 !important;
}
.modal.nested-modal,
#imageCropperModal {
    z-index: 1110 !important;
}
.modal-backdrop.nested-backdrop {
    z-index: 1105 !important;
}
/* Force solid opaque background on modals to prevent translucent backdrop bleed-through */
.modal .modal-content {
    background-color: #ffffff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2) !important;
}
[data-bs-theme="dark"] .modal .modal-content,
.dark-style .modal .modal-content {
    background-color: #2b2c40 !important;
    color: #f1f2f4 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

/* ==========================================================================
   19. COLLAPSIBLE FILTER CARDS (كروت التصفية القابلة للطي والتوسيع)
   ========================================================================== */
.cursor-pointer {
    cursor: pointer !important;
}
.ak-filter-card {
    background-color: #f8f9fa;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-radius: var(--ak-radius-md, 10px);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}
.ak-filter-card:hover {
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
}
[data-bs-theme="dark"] .ak-filter-card,
.dark-style .ak-filter-card {
    background-color: #2b2c40 !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}
.filter-card-header {
    user-select: none;
    transition: background-color 0.15s ease;
}
.filter-card-header:hover {
    background-color: rgba(0, 0, 0, 0.02) !important;
}
[data-bs-theme="dark"] .filter-card-header:hover,
.dark-style .filter-card-header:hover {
    background-color: rgba(255, 255, 255, 0.03) !important;
}
.collapse-icon,
.collapse-emp-icon,
.collapse-sub-icon {
    transition: transform 0.2s ease;
}

