/* ==========================================================================
   نظام الحسيني للتحكيم الشرعي - خالد ادعيس الحسيني
   Design System & Custom CSS (RTL, Modern, Elegant Sharia Identity)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Cairo:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary-rgb: 11, 59, 96;
    --primary-color: #0b3b60; /* Royal Navy Blue from Logo */
    --primary-hover: #082a45;
    --primary-light: #e1edf7;
    
    --secondary-color: #08223a; /* Deep Slate Navy */
    --secondary-hover: #051829;
    --secondary-light: #f0f6fa;
    
    --gold-color: #c59b27; /* Rich Metallic Gold from Logo */
    --gold-hover: #a88118;
    --gold-light: #fdf6e2;
    
    --body-bg: #f5f8fb;
    --card-bg: #ffffff;
    --text-main: #13283c;
    --text-muted: #5f7a94;
    --border-color: #d6e3ee;
    
    --sidebar-width: 280px;
    --header-height: 72px;
    --font-sans: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-serif: 'Amiri', serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--body-bg);
    color: var(--text-main);
    direction: rtl;
    text-align: right;
    font-size: 15px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #eef4f8;
}
::-webkit-scrollbar-thumb {
    background: #c3d6e5;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #9ab7cf;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--secondary-color);
    letter-spacing: -0.01em;
}

.font-serif {
    font-family: var(--font-serif);
}

.sharia-quote {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    line-height: 1.9;
    background: #fdfaf3;
    border-right: 4px solid var(--gold-color);
    padding: 16px 20px;
    border-radius: 6px;
    color: #451a03;
}

/* Layout Architecture */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar - Luxury Royal Navy & Gold Theme */
.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #f8fbfe 0%, #edf4f9 50%, #f3f8fc 100%);
    color: #133857;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #d4e2ed;
    box-shadow: -4px 0 24px rgba(11, 59, 96, 0.06);
    transition: all 0.3s ease;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid #d6e5f0;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(11, 59, 96, 0.03);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #0b3b60;
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #0b3b60 0%, #164e7a 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(11, 59, 96, 0.28);
}

.brand-title {
    font-weight: 800;
    font-size: 15.5px;
    line-height: 1.25;
    color: #0b3b60;
}

.brand-subtitle {
    font-size: 11.5px;
    color: #c59b27;
    font-weight: 700;
}

.sidebar-nav {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px 12px;
}

.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: #c3d6e5;
    border-radius: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: #9ab7cf;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: #0b3b60;
    padding: 14px 12px 6px;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-section-title::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c59b27;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #133857;
    text-decoration: none;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 4px;
    border: 1px solid rgba(214, 230, 242, 0.6);
    background: rgba(255, 255, 255, 0.6);
}

.sidebar-link i {
    font-size: 18px;
    width: 22px;
    text-align: center;
    color: #0b3b60;
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    background: #ffffff;
    color: #0b3b60;
    border-color: #bad3e6;
    box-shadow: 0 3px 12px rgba(11, 59, 96, 0.08);
    transform: translateX(-3px);
}

.sidebar-link:hover i {
    color: #c59b27;
    transform: scale(1.12);
}

.sidebar-link.active {
    background: linear-gradient(135deg, #0b3b60 0%, #164e7a 100%);
    color: #ffffff !important;
    font-weight: 700;
    border-color: #0b3b60;
    box-shadow: 0 4px 15px rgba(11, 59, 96, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.sidebar-link.active i {
    color: #f1c40f !important;
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid #d6e5f0;
    background: #ffffff;
}

.sidebar-avatar {
    background: linear-gradient(135deg, #0b3b60 0%, #c59b27 100%);
    box-shadow: 0 2px 8px rgba(11, 59, 96, 0.2);
}

.sidebar-user-name {
    color: #08223a;
}

.sidebar-user-role {
    color: #c59b27;
    font-weight: 700;
}

.sidebar-logout-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #94a3b8;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    text-decoration: none;
}

.sidebar-logout-btn:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
    transform: scale(1.05);
}

/* Sharia Button */
.btn-sharia {
    background: linear-gradient(135deg, #0b3b60 0%, #164e7a 100%);
    border: 1px solid #0b3b60;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(11, 59, 96, 0.2);
    transition: all 0.2s ease;
}

.btn-sharia:hover {
    background: linear-gradient(135deg, #082a45 0%, #0b3b60 100%);
    border-color: #082a45;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(11, 59, 96, 0.3);
    transform: translateY(-1px);
}

.btn-gold {
    background: linear-gradient(135deg, #c59b27 0%, #dfb441 100%);
    border: 1px solid #c59b27;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(197, 155, 39, 0.25);
    transition: all 0.2s ease;
}

.btn-gold:hover {
    background: linear-gradient(135deg, #a88118 0%, #c59b27 100%);
    color: #ffffff;
    transform: translateY(-1px);
}

/* Main Container */
.app-main {
    flex-grow: 1;
    margin-right: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: all 0.3s ease;
}

/* Top Navbar */
.app-header {
    height: var(--header-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.header-search {
    width: 360px;
    position: relative;
}

.header-search input {
    width: 100%;
    padding: 9px 40px 9px 16px;
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: 24px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.header-search input:focus {
    background: #ffffff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.15);
    outline: none;
}

.header-search i {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Content Area */
.app-content {
    flex-grow: 1;
    padding: 28px;
}

/* Cards & Surfaces */
.card-custom {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 24px;
}

.card-custom:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.04);
}

.card-custom .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
}

.card-custom .card-body {
    padding: 22px;
}

/* KPI Metric Cards */
.kpi-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
    transition: transform 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-3px);
}

.kpi-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.kpi-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.kpi-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--secondary-color);
    line-height: 1;
}

/* Buttons */
.btn-sharia {
    background: linear-gradient(135deg, var(--primary-color), #059669);
    color: #ffffff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(4, 120, 87, 0.2);
}

.btn-sharia:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-color));
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(4, 120, 87, 0.3);
    transform: translateY(-1px);
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold-color), #f59e0b);
    color: #ffffff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.2);
}

.btn-gold:hover {
    background: linear-gradient(135deg, var(--gold-hover), var(--gold-color));
    color: #ffffff;
    transform: translateY(-1px);
}

/* AI Badge & Indicators */
.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    border: 1px solid #bbf7d0;
    color: #15803d;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.ai-pulse {
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Case Hub Tabs Navigation System (Responsive Multi-Stage Matrix) */
.case-tabs-nav-wrapper {
    background: #ffffff;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    padding: 14px 16px;
    margin-bottom: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.case-stages-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: stretch;
}

.case-stage-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 8px 10px;
    border-radius: 10px;
    flex-grow: 1;
    min-width: fit-content;
}

.case-stage-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 700;
    color: #475569;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 4px;
    margin-bottom: 2px;
}

.case-stage-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.case-tab-pill {
    padding: 7px 12px;
    color: #334155;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.case-tab-pill i {
    font-size: 14px;
}

.case-tab-pill:hover {
    background: #f1f5f9;
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.case-tab-pill.active {
    background: linear-gradient(135deg, #047857, #065f46);
    color: #ffffff !important;
    border-color: #047857;
    box-shadow: 0 4px 10px rgba(4, 120, 87, 0.25);
    font-weight: 700;
}

.case-tab-pill.active i {
    color: #ffffff !important;
}

.case-tab-pill.active .badge {
    background: rgba(255, 255, 255, 0.25) !important;
    color: #ffffff !important;
    border: none !important;
}

/* Timeline */
.timeline {
    position: relative;
    padding-right: 32px;
}

.timeline::before {
    content: '';
    position: absolute;
    right: 14px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e2e8f0;
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
}

.timeline-marker {
    position: absolute;
    right: -32px;
    top: 4px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* Wizard Steps */
.wizard-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-bottom: 36px;
}

.wizard-steps::before {
    content: '';
    position: absolute;
    top: 24px;
    right: 40px;
    left: 40px;
    height: 3px;
    background: #e2e8f0;
    z-index: 1;
}

.wizard-step {
    position: relative;
    z-index: 2;
    text-align: center;
    width: 140px;
}

.wizard-step-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #cbd5e1;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    margin: 0 auto 10px;
    transition: all 0.3s ease;
}

.wizard-step.active .wizard-step-circle {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(4, 120, 87, 0.35);
}

.wizard-step.completed .wizard-step-circle {
    border-color: var(--gold-color);
    background: var(--gold-color);
    color: #ffffff;
}

.wizard-step-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.wizard-step.active .wizard-step-label {
    color: var(--secondary-color);
    font-weight: 700;
}

/* Comprehensive Responsive Breakpoints */
@media (max-width: 1366px) {
    .app-sidebar {
        width: 250px;
    }
    .app-main {
        margin-right: 250px;
    }
    .app-content {
        padding: 20px;
    }
}

@media (max-width: 1199.98px) {
    .header-search {
        width: 240px;
    }
    .case-tab-link {
        padding: 9px 12px;
        font-size: 12.5px;
    }
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(3, 14, 25, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(100%);
        width: 290px;
        max-width: 85vw;
        box-shadow: -8px 0 36px rgba(11, 59, 96, 0.3);
    }
    .app-sidebar.show {
        transform: translateX(0);
    }
    .app-main {
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        min-width: 0 !important;
    }
    .header-search {
        display: none;
    }
    .app-content {
        padding: 16px 12px;
        min-width: 0 !important;
    }
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        margin-bottom: 0;
    }
    .table-responsive table {
        min-width: 580px;
    }
    .wizard-steps::before {
        display: none;
    }
    .wizard-steps {
        flex-wrap: wrap;
        gap: 12px;
        justify-content: center;
    }
    .wizard-step {
        width: 100px;
    }
    .wizard-step-circle {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }
    .wizard-step-label {
        font-size: 11px;
    }
}

@media (max-width: 767.98px) {
    .app-header {
        padding: 0 12px;
        height: 60px;
    }
    .card-custom {
        margin-bottom: 16px;
    }
    .card-custom .card-header {
        padding: 12px 14px;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .card-custom .card-body {
        padding: 14px;
    }
    .kpi-card {
        padding: 14px 12px;
        gap: 12px;
        border-radius: 10px;
    }
    .kpi-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
        border-radius: 10px;
    }
    .kpi-title {
        font-size: 11.5px;
    }
    .kpi-value {
        font-size: 20px;
    }
    .case-tabs-scroll-btn {
        display: none;
    }
}

@media (max-width: 575.98px) {
    body {
        font-size: 13.5px;
    }
    .app-content {
        padding: 12px 8px;
    }
    .card-custom {
        border-radius: 10px;
        margin-bottom: 14px;
    }
    .kpi-card {
        padding: 10px 8px;
        gap: 8px;
        border-radius: 10px;
    }
    .kpi-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
        border-radius: 8px;
    }
    .kpi-title {
        font-size: 11px;
        margin-bottom: 2px;
    }
    .kpi-value {
        font-size: 17px;
        font-weight: 800;
    }
    .btn-sharia, .btn-gold, .btn {
        font-size: 12.5px;
        padding: 6px 12px;
    }
    .case-tab-link {
        padding: 8px 10px;
        font-size: 12px;
    }
}
