{% load i18n %}
<!DOCTYPE html>
<html lang="{% get_current_language as LANGUAGE_CODE %}{{ LANGUAGE_CODE }}" dir="{% if LANGUAGE_CODE == 'ar' %}rtl{% else %}ltr{% endif %}">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="theme-color" content="#0097a7">
    <title>{% block title %}{% trans "PX360 - Patient Experience Management" %}{% endblock %}</title>
    
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    
    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
    
    <!-- Google Fonts - Arabic Support -->
    <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700&family=Open+Sans:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    
    <!-- ApexCharts -->
    <script src="https://cdn.jsdelivr.net/npm/apexcharts@3.45.1/dist/apexcharts.min.js"></script>
    
    <!-- D3.js for data visualization -->
    <script src="https://cdn.jsdelivr.net/npm/d3@7.9.0/dist/d3.min.js"></script>
    
    <!-- HTMX for dynamic updates -->
    <script src="https://unpkg.com/htmx.org@1.9.10"></script>
    
    <!-- Select2 for better selects -->
    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
    <link href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" rel="stylesheet" />
    
    <!-- Al Hammadi Theme CSS -->
    <style>
        /* ============================================
           AL HAMMADI HOSPITAL THEME - PX360
           Color Palette:
           - Primary Teal: #0097a7 / #00838f
           - Red Accent: #c62828 / #d32f2f
           - Dark Blue: #1a237e / #283593
           - Light Teal: #4dd0e1 / #80deea
           ============================================ */
        
        :root {
            /* Layout Variables */
            --sidebar-width: 260px;
            --topbar-height: 60px;
            
            /* Al Hammadi Color Palette */
            --hh-primary: #0086d2;
            --hh-primary-dark: #005d93;
            --hh-primary-light: #4caadf;
            --hh-primary-lighter: #b2ebf2;
            --hh-primary-bg: rgba(0, 151, 167, 0.1);
            
            --hh-secondary: #1a237e;
            --hh-secondary-dark: #0d1642;
            --hh-secondary-light: #283593;
            
            --hh-accent: #c62828;
            --hh-accent-light: #d32f2f;
            --hh-accent-dark: #b71c1c;
            
            --hh-success: #00897b;
            --hh-success-light: #26a69a;
            --hh-warning: #f9a825;
            --hh-warning-light: #fbc02d;
            --hh-danger: #c62828;
            --hh-info: #0097a7;
            
            --hh-text-dark: #263238;
            --hh-text-muted: #607d8b;
            --hh-text-light: #90a4ae;
            
            --hh-bg-light: #f5f7fa;
            --hh-bg-white: #ffffff;
            --hh-border: #e0e6ed;
            
            /* Shadows */
            --hh-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
            --hh-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            --hh-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
        }
        
        /* ============================================
           TYPOGRAPHY
           ============================================ */
        body {
            font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            background-color: var(--hh-bg-light);
            color: var(--hh-text-dark);
        }
        
        [dir="rtl"] body {
            font-family: 'Cairo', 'Open Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        }
        
        h1, h2, h3, h4, h5, h6 {
            font-weight: 600;
            color: var(--hh-text-dark);
        }
        
        a {
            color: var(--hh-primary);
            text-decoration: none;
            transition: color 0.2s ease;
        }
        
        a:hover {
            color: var(--hh-primary-dark);
        }
        
        /* ============================================
           SIDEBAR - Al Hammadi Teal Theme
           ============================================ */
        .sidebar {
            position: fixed;
            top: 0;
            left: 0;
            height: 100vh;
            width: var(--sidebar-width);
            background: linear-gradient(180deg, var(--hh-primary-dark) 0%, var(--hh-primary) 50%, var(--hh-primary-dark) 100%);
            color: white;
            overflow-y: auto;
            z-index: 1000;
            box-shadow: 2px 0 15px rgba(0, 0, 0, 0.15);
        }
        
        .sidebar-brand {
            padding: 1.25rem 1rem;
            font-size: 1.4rem;
            font-weight: 700;
            border-bottom: 1px solid rgba(255, 255, 255, 0.15);
            background: rgba(0, 0, 0, 0.1);
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }
        
        .sidebar-brand i {
            color: var(--hh-accent);
            font-size: 1.6rem;
        }
        
        .sidebar-nav {
            padding: 1rem 0;
        }
        
        .sidebar-nav .nav-link {
            color: rgba(255, 255, 255, 0.85);
            padding: 0.75rem 1.25rem;
            border-left: 3px solid transparent;
            transition: all 0.25s ease;
            display: flex;
            align-items: center;
            font-size: 0.9rem;
        }
        
        .sidebar-nav .nav-link:hover {
            color: white;
            background: rgba(255, 255, 255, 0.1);
            border-left-color: var(--hh-accent);
        }
        
        .sidebar-nav .nav-link.active {
            color: white;
            background: rgba(255, 255, 255, 0.15);
            border-left-color: var(--hh-accent);
            font-weight: 600;
        }
        
        .sidebar-nav .nav-link i {
            width: 22px;
            margin-right: 0.75rem;
            font-size: 1.1rem;
        }
        
        .sidebar-nav .badge {
            margin-left: auto;
            font-size: 0.7rem;
            padding: 0.3em 0.6em;
        }
        
        .sidebar-nav .badge.bg-danger {
            background-color: var(--hh-accent) !important;
        }
        
        .sidebar-nav .badge.bg-success {
            background-color: var(--hh-success) !important;
        }
        
        .sidebar-nav .badge.bg-warning {
            background-color: var(--hh-warning) !important;
            color: var(--hh-text-dark) !important;
        }
        
        .sidebar-nav .badge.bg-info {
            background-color: var(--hh-primary-light) !important;
        }
        
        /* Sidebar Submenu */
        .sidebar-nav .collapse .nav-link {
            padding-left: 2.5rem;
            font-size: 0.85rem;
        }
        
        .sidebar-nav hr {
            border-color: rgba(255, 255, 255, 0.1);
            margin: 0.75rem 1rem;
        }
        
        /* ============================================
           TOPBAR
           ============================================ */
        .topbar {
            position: fixed;
            top: 0;
            left: var(--sidebar-width);
            right: 0;
            height: var(--topbar-height);
            background: var(--hh-bg-white);
            border-bottom: 1px solid var(--hh-border);
            z-index: 999;
            box-shadow: var(--hh-shadow-sm);
            display: flex;
            align-items: center;
            padding: 0 1.5rem;
        }
        
        .topbar .navbar-brand {
            color: var(--hh-primary);
            font-weight: 600;
        }
        
        .topbar .nav-link {
            color: var(--hh-text-muted);
            padding: 0.5rem 0.75rem;
        }
        
        .topbar .nav-link:hover {
            color: var(--hh-primary);
        }
        
        .topbar .dropdown-menu {
            border: 1px solid var(--hh-border);
            box-shadow: var(--hh-shadow);
        }
        
        /* ============================================
           MAIN CONTENT
           ============================================ */
        .main-content {
            margin-left: var(--sidebar-width);
            margin-top: var(--topbar-height);
            padding: 1.5rem 2rem;
            min-height: calc(100vh - var(--topbar-height));
            background: var(--hh-bg-light);
        }
        
        /* ============================================
           CARDS - Al Hammadi Style
           ============================================ */
        .card {
            border: none;
            border-radius: 0.5rem;
            box-shadow: var(--hh-shadow-sm);
            margin-bottom: 1.5rem;
            background: var(--hh-bg-white);
            transition: box-shadow 0.2s ease, transform 0.2s ease;
        }
        
        .card:hover {
            box-shadow: var(--hh-shadow);
        }
        
        .card-header {
            background: var(--hh-bg-white);
            border-bottom: 1px solid var(--hh-border);
            padding: 1rem 1.25rem;
            font-weight: 600;
            color: var(--hh-text-dark);
        }
        
        .card-header.bg-primary,
        .card-header.bg-teal {
            background: linear-gradient(135deg, var(--hh-primary) 0%, var(--hh-primary-dark) 100%) !important;
            color: white;
            border-bottom: none;
        }
        
        .card-title {
            font-size: 1rem;
            font-weight: 600;
            color: var(--hh-text-dark);
            margin-bottom: 0;
        }
        
        .card-body {
            padding: 1.25rem;
        }
        
        /* Stat Cards */
        .stat-card {
            border: none;
            border-radius: 0.5rem;
            box-shadow: var(--hh-shadow-sm);
            transition: transform 0.2s ease, box-shadow 0.2s ease;
            overflow: hidden;
        }
        
        .stat-card:hover {
            transform: translateY(-3px);
            box-shadow: var(--hh-shadow-lg);
        }
        
        .stat-card .card-body {
            padding: 1.5rem;
            position: relative;
        }
        
        .stat-card .stat-icon {
            position: absolute;
            top: 1rem;
            right: 1rem;
            width: 48px;
            height: 48px;
            border-radius: 0.5rem;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
        }
        
        [dir="rtl"] .stat-card .stat-icon {
            right: auto;
            left: 1rem;
        }
        
        .stat-card .stat-icon.bg-teal {
            background: var(--hh-primary-bg);
            color: var(--hh-primary);
        }
        
        .stat-card .stat-icon.bg-red {
            background: rgba(198, 40, 40, 0.1);
            color: var(--hh-accent);
        }
        
        .stat-card .stat-icon.bg-blue {
            background: rgba(26, 35, 126, 0.1);
            color: var(--hh-secondary);
        }
        
        .stat-card .stat-icon.bg-green {
            background: rgba(0, 137, 123, 0.1);
            color: var(--hh-success);
        }
        
        .stat-value {
            font-size: 2rem;
            font-weight: 700;
            color: var(--hh-text-dark);
            margin: 0.25rem 0;
            line-height: 1.2;
        }
        
        .stat-label {
            color: var(--hh-text-muted);
            font-size: 0.8rem;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            font-weight: 600;
        }
        
        .stat-trend {
            font-size: 0.85rem;
            margin-top: 0.5rem;
        }
        
        .stat-trend.up {
            color: var(--hh-success);
        }
        
        .stat-trend.down {
            color: var(--hh-danger);
        }
        
        /* ============================================
           BUTTONS - Al Hammadi Style
           ============================================ */
        .btn {
            font-weight: 500;
            padding: 0.5rem 1rem;
            border-radius: 0.375rem;
            transition: all 0.2s ease;
        }
        
        .btn-primary {
            background-color: var(--hh-primary);
            border-color: var(--hh-primary);
        }
        
        .btn-primary:hover,
        .btn-primary:focus {
            background-color: var(--hh-primary-dark);
            border-color: var(--hh-primary-dark);
        }
        
        .btn-secondary {
            background-color: var(--hh-secondary);
            border-color: var(--hh-secondary);
        }
        
        .btn-secondary:hover,
        .btn-secondary:focus {
            background-color: var(--hh-secondary-dark);
            border-color: var(--hh-secondary-dark);
        }
        
        .btn-danger {
            background-color: var(--hh-accent);
            border-color: var(--hh-accent);
        }
        
        .btn-danger:hover,
        .btn-danger:focus {
            background-color: var(--hh-accent-dark);
            border-color: var(--hh-accent-dark);
        }
        
        .btn-success {
            background-color: var(--hh-success);
            border-color: var(--hh-success);
        }
        
        .btn-warning {
            background-color: var(--hh-warning);
            border-color: var(--hh-warning);
            color: var(--hh-text-dark);
        }
        
        .btn-info {
            background-color: var(--hh-primary-light);
            border-color: var(--hh-primary-light);
        }
        
        .btn-outline-primary {
            color: var(--hh-primary);
            border-color: var(--hh-primary);
        }
        
        .btn-outline-primary:hover {
            background-color: var(--hh-primary);
            border-color: var(--hh-primary);
            color: white;
        }
        
        /* Soft Buttons */
        .btn-soft-primary {
            color: var(--hh-primary);
            background-color: var(--hh-primary-bg);
            border-color: transparent;
        }
        
        .btn-soft-primary:hover {
            color: white;
            background-color: var(--hh-primary);
            border-color: var(--hh-primary);
        }
        
        .btn-soft-danger {
            color: var(--hh-accent);
            background-color: rgba(198, 40, 40, 0.1);
            border-color: transparent;
        }
        
        .btn-soft-danger:hover {
            color: white;
            background-color: var(--hh-accent);
            border-color: var(--hh-accent);
        }
        
        .btn-soft-success {
            color: var(--hh-success);
            background-color: rgba(0, 137, 123, 0.1);
            border-color: transparent;
        }
        
        .btn-soft-success:hover {
            color: white;
            background-color: var(--hh-success);
            border-color: var(--hh-success);
        }
        
        /* ============================================
           TABLES
           ============================================ */
        .table-card {
            background: var(--hh-bg-white);
            border-radius: 0.5rem;
            box-shadow: var(--hh-shadow-sm);
            overflow: hidden;
        }
        
        .table-card .card-header {
            background: var(--hh-bg-white);
            border-bottom: 1px solid var(--hh-border);
            padding: 1rem 1.25rem;
        }
        
        .table {
            margin-bottom: 0;
        }
        
        .table thead th {
            background: var(--hh-bg-light);
            border-bottom: 2px solid var(--hh-border);
            color: var(--hh-text-dark);
            font-weight: 600;
            font-size: 0.85rem;
            text-transform: uppercase;
            letter-spacing: 0.03em;
            padding: 0.875rem 1rem;
        }
        
        .table tbody td {
            padding: 0.875rem 1rem;
            vertical-align: middle;
            border-bottom: 1px solid var(--hh-border);
            color: var(--hh-text-dark);
        }
        
        .table tbody tr:hover {
            background-color: var(--hh-primary-bg);
        }
        
        .table-striped tbody tr:nth-of-type(odd) {
            background-color: rgba(0, 151, 167, 0.03);
        }
        
        /* ============================================
           BADGES
           ============================================ */
        .badge {
            padding: 0.4em 0.7em;
            font-weight: 600;
            font-size: 0.75rem;
            border-radius: 0.25rem;
        }
        
        .badge.bg-primary {
            background-color: var(--hh-primary) !important;
        }
        
        .badge.bg-secondary {
            background-color: var(--hh-secondary) !important;
        }
        
        .badge.bg-success {
            background-color: var(--hh-success) !important;
        }
        
        .badge.bg-danger {
            background-color: var(--hh-accent) !important;
        }
        
        .badge.bg-warning {
            background-color: var(--hh-warning) !important;
            color: var(--hh-text-dark) !important;
        }
        
        .badge.bg-info {
            background-color: var(--hh-primary-light) !important;
        }
        
        /* Soft Badges */
        .badge-soft-primary {
            color: var(--hh-primary);
            background-color: var(--hh-primary-bg);
        }
        
        .badge-soft-danger {
            color: var(--hh-accent);
            background-color: rgba(198, 40, 40, 0.1);
        }
        
        .badge-soft-success {
            color: var(--hh-success);
            background-color: rgba(0, 137, 123, 0.1);
        }
        
        .badge-soft-warning {
            color: #e65100;
            background-color: rgba(249, 168, 37, 0.15);
        }
        
        /* ============================================
           FORMS
           ============================================ */
        .form-control {
            border: 1px solid var(--hh-border);
            border-radius: 0.375rem;
            padding: 0.5rem 0.875rem;
            transition: border-color 0.2s ease, box-shadow 0.2s ease;
        }
        
        .form-control:focus {
            border-color: var(--hh-primary);
            box-shadow: 0 0 0 0.2rem var(--hh-primary-bg);
        }
        
        .form-label {
            font-weight: 500;
            color: var(--hh-text-dark);
            margin-bottom: 0.375rem;
        }
        
        .form-select {
            border: 1px solid var(--hh-border);
            border-radius: 0.375rem;
        }
        
        .form-select:focus {
            border-color: var(--hh-primary);
            box-shadow: 0 0 0 0.2rem var(--hh-primary-bg);
        }
        
        .form-check-input:checked {
            background-color: var(--hh-primary);
            border-color: var(--hh-primary);
        }
        
        .form-check-input:focus {
            border-color: var(--hh-primary);
            box-shadow: 0 0 0 0.2rem var(--hh-primary-bg);
        }
        
        /* ============================================
           ALERTS
           ============================================ */
        .alert {
            border: none;
            border-radius: 0.375rem;
            padding: 1rem 1.25rem;
        }
        
        .alert-primary {
            background-color: var(--hh-primary-bg);
            color: var(--hh-primary-dark);
        }
        
        .alert-success {
            background-color: rgba(0, 137, 123, 0.1);
            color: var(--hh-success);
        }
        
        .alert-danger {
            background-color: rgba(198, 40, 40, 0.1);
            color: var(--hh-accent);
        }
        
        .alert-warning {
            background-color: rgba(249, 168, 37, 0.15);
            color: #e65100;
        }
        
        .alert-info {
            background-color: var(--hh-primary-bg);
            color: var(--hh-primary);
        }
        
        /* ============================================
           MODALS
           ============================================ */
        .modal-header {
            background: linear-gradient(135deg, var(--hh-primary) 0%, var(--hh-primary-dark) 100%);
            color: white;
            border-bottom: none;
        }
        
        .modal-header .btn-close {
            filter: brightness(0) invert(1);
        }
        
        .modal-content {
            border: none;
            border-radius: 0.5rem;
            box-shadow: var(--hh-shadow-lg);
        }
        
        .modal-footer {
            border-top: 1px solid var(--hh-border);
        }
        
        /* ============================================
           PAGINATION
           ============================================ */
        .pagination .page-link {
            color: var(--hh-primary);
            border-color: var(--hh-border);
        }
        
        .pagination .page-link:hover {
            background-color: var(--hh-primary-bg);
            border-color: var(--hh-primary);
            color: var(--hh-primary-dark);
        }
        
        .pagination .page-item.active .page-link {
            background-color: var(--hh-primary);
            border-color: var(--hh-primary);
        }
        
        /* ============================================
           PROGRESS BARS
           ============================================ */
        .progress {
            background-color: var(--hh-primary-lighter);
            border-radius: 0.5rem;
            height: 0.5rem;
        }
        
        .progress-bar {
            background-color: var(--hh-primary);
        }
        
        .progress-bar.bg-success {
            background-color: var(--hh-success) !important;
        }
        
        .progress-bar.bg-danger {
            background-color: var(--hh-accent) !important;
        }
        
        .progress-bar.bg-warning {
            background-color: var(--hh-warning) !important;
        }
        
        /* ============================================
           DROPDOWNS
           ============================================ */
        .dropdown-menu {
            border: 1px solid var(--hh-border);
            box-shadow: var(--hh-shadow);
            border-radius: 0.375rem;
        }
        
        .dropdown-item {
            padding: 0.5rem 1rem;
            color: var(--hh-text-dark);
        }
        
        .dropdown-item:hover {
            background-color: var(--hh-primary-bg);
            color: var(--hh-primary);
        }
        
        .dropdown-item.active,
        .dropdown-item:active {
            background-color: var(--hh-primary);
            color: white;
        }
        
        /* ============================================
           NAV TABS & PILLS
           ============================================ */
        .nav-tabs .nav-link {
            color: var(--hh-text-muted);
            border: none;
            border-bottom: 2px solid transparent;
            padding: 0.75rem 1.25rem;
        }
        
        .nav-tabs .nav-link:hover {
            color: var(--hh-primary);
            border-bottom-color: var(--hh-primary-light);
        }
        
        .nav-tabs .nav-link.active {
            color: var(--hh-primary);
            border-bottom-color: var(--hh-primary);
            font-weight: 600;
        }
        
        .nav-pills .nav-link {
            color: var(--hh-text-muted);
            border-radius: 0.375rem;
        }
        
        .nav-pills .nav-link:hover {
            background-color: var(--hh-primary-bg);
            color: var(--hh-primary);
        }
        
        .nav-pills .nav-link.active {
            background-color: var(--hh-primary);
            color: white;
        }
        
        /* ============================================
           PAGE TITLE BOX
           ============================================ */
        .page-title-box {
            padding-bottom: 1rem;
            margin-bottom: 1.5rem;
            border-bottom: 1px solid var(--hh-border);
        }
        
        .page-title-box h4 {
            font-size: 1.25rem;
            font-weight: 600;
            color: var(--hh-text-dark);
            margin: 0;
        }
        
        .page-title-box .breadcrumb {
            margin-bottom: 0;
        }
        
        .breadcrumb-item a {
            color: var(--hh-primary);
        }
        
        .breadcrumb-item.active {
            color: var(--hh-text-muted);
        }
        
        /* ============================================
           SLA INDICATORS
           ============================================ */
        .sla-overdue { 
            color: var(--hh-accent); 
            font-weight: 600;
        }
        .sla-due-soon { 
            color: var(--hh-warning); 
            font-weight: 600;
        }
        .sla-on-time { 
            color: var(--hh-success); 
            font-weight: 600;
        }
        
        /* ============================================
           LOADING SPINNER
           ============================================ */
        .spinner-border {
            color: var(--hh-primary);
        }
        
        .spinner-grow {
            color: var(--hh-primary);
        }
        
        /* ============================================
           AVATAR
           ============================================ */
        .avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            font-size: 0.875rem;
        }
        
        .avatar-sm {
            width: 32px;
            height: 32px;
            font-size: 0.75rem;
        }
        
        .avatar-lg {
            width: 56px;
            height: 56px;
            font-size: 1.25rem;
        }
        
        .avatar-teal {
            background-color: var(--hh-primary-bg);
            color: var(--hh-primary);
        }
        
        .avatar-red {
            background-color: rgba(198, 40, 40, 0.1);
            color: var(--hh-accent);
        }
        
        .avatar-blue {
            background-color: rgba(26, 35, 126, 0.1);
            color: var(--hh-secondary);
        }
        
        /* ============================================
           TIMELINE
           ============================================ */
        .timeline {
            position: relative;
            padding-left: 2rem;
        }
        
        .timeline::before {
            content: '';
            position: absolute;
            left: 0.5rem;
            top: 0;
            bottom: 0;
            width: 2px;
            background: var(--hh-border);
        }
        
        .timeline-item {
            position: relative;
            padding-bottom: 1.5rem;
        }
        
        .timeline-item::before {
            content: '';
            position: absolute;
            left: -1.5rem;
            top: 0.25rem;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: var(--hh-primary);
            border: 2px solid white;
            box-shadow: 0 0 0 2px var(--hh-primary);
        }
        
        /* ============================================
           RTL SUPPORT
           ============================================ */
        [dir="rtl"] .sidebar {
            left: auto;
            right: 0;
            border-left: none;
            border-right: none;
        }
        
        [dir="rtl"] .sidebar-nav .nav-link {
            border-left: none;
            border-right: 3px solid transparent;
        }
        
        [dir="rtl"] .sidebar-nav .nav-link:hover,
        [dir="rtl"] .sidebar-nav .nav-link.active {
            border-left-color: transparent;
            border-right-color: var(--hh-accent);
        }
        
        [dir="rtl"] .sidebar-nav .nav-link i {
            margin-right: 0;
            margin-left: 0.75rem;
        }
        
        [dir="rtl"] .sidebar-nav .badge {
            margin-left: 0;
            margin-right: auto;
        }
        
        [dir="rtl"] .sidebar-nav .collapse .nav-link {
            padding-left: 1.25rem;
            padding-right: 2.5rem;
        }
        
        [dir="rtl"] .topbar {
            left: 0;
            right: var(--sidebar-width);
        }
        
        [dir="rtl"] .main-content {
            margin-left: 0;
            margin-right: var(--sidebar-width);
        }
        
        [dir="rtl"] .timeline {
            padding-left: 0;
            padding-right: 2rem;
        }
        
        [dir="rtl"] .timeline::before {
            left: auto;
            right: 0.5rem;
        }
        
        [dir="rtl"] .timeline-item::before {
            left: auto;
            right: -1.5rem;
        }
        
        /* ============================================
           RESPONSIVE
           ============================================ */
        @media (max-width: 991.98px) {
            .sidebar {
                transform: translateX(-100%);
                transition: transform 0.3s ease;
            }
            
            .sidebar.show {
                transform: translateX(0);
            }
            
            [dir="rtl"] .sidebar {
                transform: translateX(100%);
            }
            
            [dir="rtl"] .sidebar.show {
                transform: translateX(0);
            }
            
            .topbar {
                left: 0;
                right: 0;
            }
            
            [dir="rtl"] .topbar {
                left: 0;
                right: 0;
            }
            
            .main-content {
                margin-left: 0;
                margin-right: 0;
                padding: 1rem;
            }
            
            [dir="rtl"] .main-content {
                margin-left: 0;
                margin-right: 0;
            }
        }
        
        @media (max-width: 575.98px) {
            .stat-value {
                font-size: 1.5rem;
            }
            
            .stat-card .stat-icon {
                width: 40px;
                height: 40px;
                font-size: 1.25rem;
            }
        }
        
        /* ============================================
           UTILITY CLASSES
           ============================================ */
        .text-teal { color: var(--hh-primary) !important; }
        .text-teal-dark { color: var(--hh-primary-dark) !important; }
        .text-red { color: var(--hh-accent) !important; }
        .text-blue { color: var(--hh-secondary) !important; }
        
        .bg-teal { background-color: var(--hh-primary) !important; }
        .bg-teal-light { background-color: var(--hh-primary-bg) !important; }
        .bg-red { background-color: var(--hh-accent) !important; }
        .bg-blue { background-color: var(--hh-secondary) !important; }
        
        .border-teal { border-color: var(--hh-primary) !important; }
        .border-red { border-color: var(--hh-accent) !important; }
        
        /* Hover effects */
        .hover-lift {
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }
        
        .hover-lift:hover {
            transform: translateY(-3px);
            box-shadow: var(--hh-shadow-lg);
        }
        
        /* Gradient backgrounds */
        .bg-gradient-teal {
            background: linear-gradient(135deg, var(--hh-primary) 0%, var(--hh-primary-dark) 100%) !important;
        }
        
        .bg-gradient-red {
            background: linear-gradient(135deg, var(--hh-accent-light) 0%, var(--hh-accent-dark) 100%) !important;
        }
        
        .bg-gradient-blue {
            background: linear-gradient(135deg, var(--hh-secondary-light) 0%, var(--hh-secondary-dark) 100%) !important;
        }
    </style>
    
    {% block extra_css %}{% endblock %}
</head>
<body>
    <!-- Sidebar -->
    {% include 'layouts/partials/sidebar.html' %}
    
    <!-- Topbar -->
    {% include 'layouts/partials/topbar.html' %}
    
    <!-- Main Content -->
    <div class="main-content">
        <!-- Breadcrumbs -->
        {% include 'layouts/partials/breadcrumbs.html' %}
        
        <!-- Flash Messages -->
        {% include 'layouts/partials/flash_messages.html' %}
        
        <!-- Page Content -->
        {% block content %}{% endblock %}
    </div>
    
    <!-- jQuery (required for Select2) -->
    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    
    <!-- Bootstrap 5 JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    
    <!-- Select2 -->
    <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
    
    <!-- Initialize Select2 -->
    <script>
        $(document).ready(function() {
            $('.select2').select2({
                theme: 'bootstrap-5'
            });
        });
    </script>
    
    {% block extra_js %}{% endblock %}
</body>
</html>
