/* ========================================
   Orphan Sponsorship Management System
   Arabic RTL Premium Styles
   ======================================== */

/* --- Root Variables --- */
:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --primary-dark: #0e3a5c;
    --secondary: #148f77;
    --secondary-light: #1abc9c;
    --accent: #e67e22;
    --accent-light: #f39c12;
    --danger: #c0392b;
    --danger-light: #e74c3c;
    --success: #27ae60;
    --success-light: #2ecc71;
    --warning: #f39c12;
    --info: #2980b9;
    --dark: #1a1a2e;
    --dark-secondary: #16213e;
    --light: #f8f9fa;
    --light-alt: #eef2f7;
    --border-color: #e0e0e0;
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --text-muted: #95a5a6;
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --card-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
    --transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    --transition-fast: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --sidebar-width: 270px;
    --sidebar-collapsed: 76px;
    --font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.18);
}

/* --- Reset & Global --- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    direction: rtl;
    text-align: right;
    scroll-behavior: smooth;
}

body {
    background: var(--light-alt);
    min-height: 100vh;
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

a {
    text-decoration: none;
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--dark) 0%, var(--dark-secondary) 60%, #0f172a 100%);
    color: #fff;
    z-index: 1050;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -6px 0 30px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.sidebar::-webkit-scrollbar {
    width: 0;
}

.sidebar-brand {
    padding: 22px 20px;
    font-weight: 800;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 72px;
    flex-shrink: 0;
}

.sidebar-brand i {
    font-size: 1.6rem;
    color: var(--accent-light);
    filter: drop-shadow(0 0 6px rgba(243, 156, 18, 0.4));
    flex-shrink: 0;
}

.sidebar-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
    width: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 16px;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.sidebar-link::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: var(--radius-sm);
    z-index: -1;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(-2px);
}

.sidebar-link.active {
    color: #fff;
    font-weight: 600;
}

.sidebar-link.active::before {
    opacity: 1;
}

.sidebar-link.active {
    box-shadow: 0 3px 12px rgba(41, 128, 185, 0.35);
}

.sidebar-link i {
    width: 22px;
    text-align: center;
    font-size: 1.05rem;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.sidebar-link:hover i {
    transform: scale(1.15);
}

.sidebar-link span {
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s ease;
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.15);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.85rem;
}

.user-info i {
    font-size: 1.4rem;
    flex-shrink: 0;
    color: var(--accent-light);
}

.user-info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}

/* Sidebar collapsed */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .user-info span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 22px 10px;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .sidebar-footer {
    padding: 14px 10px;
}

.sidebar.collapsed .user-info {
    justify-content: center;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   TOP BAR
   ======================================== */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.05);
    border-radius: var(--radius);
    margin-bottom: 24px;
    position: sticky;
    top: 12px;
    z-index: 500;
    border: 1px solid var(--glass-border);
}

.top-bar-end {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-toggle {
    font-size: 1.25rem;
    color: var(--primary);
    padding: 6px 10px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--light);
    color: var(--primary-dark);
}

/* ========================================
   MAIN LAYOUT
   ======================================== */
.main-content {
    margin-right: var(--sidebar-width);
    padding: 20px 24px 40px;
    min-height: 100vh;
    transition: margin 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed~.main-content {
    margin-right: var(--sidebar-collapsed);
}

/* ========================================
   PAGE HEADER
   ======================================== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 1.35rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-title i {
    color: var(--primary-light);
    font-size: 1.2rem;
}

/* ========================================
   CARDS
   ======================================== */
.card {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    background: #fff;
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
}

.card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    font-weight: 600;
    padding: 14px 20px;
    border: none;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header.bg-secondary-gradient {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%);
}

.card-header.bg-accent-gradient {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
}

.card-body {
    padding: 20px;
}

/* ========================================
   STAT CARDS (Dashboard)
   ======================================== */
.stat-card {
    border-radius: var(--radius);
    padding: 22px 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    cursor: default;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -30px;
    left: -30px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transition: var(--transition);
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: -40px;
    right: -40px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

.stat-card:hover::before {
    transform: scale(1.2);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

.stat-card .stat-icon {
    font-size: 2.8rem;
    opacity: 0.25;
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 0;
}

.bg-stat-1 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.bg-stat-2 {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.bg-stat-3 {
    background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
}

.bg-stat-4 {
    background: linear-gradient(135deg, #2193b0 0%, #6dd5ed 100%);
}

.bg-stat-5 {
    background: linear-gradient(135deg, #cc2b5e 0%, #753a88 100%);
}

.bg-stat-6 {
    background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%);
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    padding: 9px 20px;
    transition: var(--transition);
    font-size: 0.88rem;
    border: none;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), var(--success-light));
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), var(--danger-light));
    color: #fff;
}

.btn-warning {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
}

.btn-warning:hover {
    color: #fff;
}

.btn-info {
    background: linear-gradient(135deg, var(--info), #3498db);
    color: #fff;
}

.btn-info:hover {
    color: #fff;
}

.btn-secondary {
    background: linear-gradient(135deg, #95a5a6, #bdc3c7);
    color: #fff;
}

.btn-secondary:hover {
    color: #fff;
}

.btn-outline-primary {
    border: 2px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: #fff;
}

.btn-outline-danger {
    border: 2px solid var(--danger);
    color: var(--danger);
    background: transparent;
    font-weight: 600;
}

.btn-outline-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 5px 14px;
    font-size: 0.82rem;
    border-radius: var(--radius-xs);
}

.btn-lg {
    padding: 12px 32px;
    font-size: 1rem;
}

.btn-action {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
    transition: var(--transition-fast);
}

.btn-action:hover {
    transform: scale(1.1);
}

/* ========================================
   TABLES (DataTables)
   ======================================== */
.dataTables_wrapper {
    direction: rtl;
    font-size: 0.88rem;
}

.dataTables_wrapper .dataTables_filter {
    text-align: right !important;
    margin-bottom: 12px;
}

.dataTables_wrapper .dataTables_filter input {
    margin-right: 8px !important;
    margin-left: 0 !important;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    padding: 8px 14px;
    transition: var(--transition);
    min-width: 220px;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.12);
    outline: none;
}

.dataTables_wrapper .dataTables_length {
    text-align: right !important;
    margin-bottom: 12px;
}

.dataTables_wrapper .dataTables_length select {
    border-radius: var(--radius-xs);
    padding: 6px 12px;
    border: 1.5px solid var(--border-color);
}

.dataTables_wrapper .dataTables_info {
    text-align: right !important;
    color: var(--text-secondary);
    font-size: 0.82rem;
    padding-top: 12px;
}

.dataTables_wrapper .dataTables_paginate {
    text-align: left !important;
    padding-top: 12px;
}

table.dataTable {
    border-collapse: collapse !important;
    width: 100% !important;
}

table.dataTable thead th {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    font-weight: 600;
    padding: 13px 16px;
    border: none;
    font-size: 0.85rem;
    white-space: nowrap;
    text-align: right;
}

table.dataTable thead th:first-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

table.dataTable thead th:last-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

table.dataTable tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    font-size: 0.86rem;
    border-bottom: 1px solid #f0f0f0;
    text-align: right;
}

table.dataTable tbody tr {
    transition: background-color 0.15s ease;
    content-visibility: auto;
    contain-intrinsic-size: auto 48px;
}

table.dataTable tbody tr:hover {
    background: rgba(41, 128, 185, 0.04) !important;
}

table.dataTable tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.012);
}

/* Table responsive wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
}

div.dataTables_wrapper div.dataTables_filter {
    text-align: right;
}

div.dataTables_wrapper div.dataTables_length label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 5px 13px !important;
    border-radius: var(--radius-xs) !important;
    margin: 0 2px !important;
    font-size: 0.82rem;
    transition: var(--transition-fast) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    color: #fff !important;
    border: none !important;
}

.dataTables_wrapper .dataTables_processing {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(4px);
    border-radius: var(--radius-sm);
}

/* ========================================
   BADGES
   ======================================== */
.badge {
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 50px;
    font-size: 0.78rem;
    letter-spacing: 0.3px;
}

.badge-active {
    background: linear-gradient(135deg, var(--success), var(--success-light));
    color: #fff;
}

.badge-completed {
    background: linear-gradient(135deg, #95a5a6, #bdc3c7);
    color: #fff;
}

.badge-cancelled {
    background: linear-gradient(135deg, var(--danger), var(--danger-light));
    color: #fff;
}

.badge-warning {
    background: linear-gradient(135deg, var(--warning), var(--accent-light));
    color: #fff;
}

/* ========================================
   FORMS
   ======================================== */
.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    padding: 10px 14px;
    font-size: 0.88rem;
    transition: var(--transition);
    background-color: #fff;
    color: var(--text-primary);
    text-align: right;
    direction: rtl;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(41, 128, 185, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.form-label {
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 6px;
    font-size: 0.86rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-label .text-danger {
    font-size: 0.9em;
}

.form-section {
    background: var(--light);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.form-section-title {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-light);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

/* Input Group RTL */
.input-group {
    direction: rtl;
}

.input-group>.form-control {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.input-group>.btn:last-child,
.input-group>.input-group-text:last-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

/* ========================================
   SELECT2 RTL
   ======================================== */
.select2-container--bootstrap-5 .select2-selection {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    min-height: 44px;
    transition: var(--transition);
}

.select2-container--bootstrap-5 .select2-selection:focus,
.select2-container--bootstrap-5.select2-container--focus .select2-selection {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(41, 128, 185, 0.1);
}

.select2-container--bootstrap-5 .select2-dropdown {
    border-radius: var(--radius-sm);
    box-shadow: var(--card-shadow-hover);
    border: 1px solid var(--border-color);
}

/* ========================================
   LOGIN PAGE
   ======================================== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 40%, var(--secondary) 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 70%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 70% 30%, rgba(255, 255, 255, 0.08) 0%, transparent 40%);
    animation: loginBg 20s linear infinite;
}

@keyframes loginBg {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.login-card {
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    max-width: 420px;
    width: 100%;
    padding: 44px 36px;
    animation: fadeInUp 0.6s ease-out;
    position: relative;
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo i {
    font-size: 3.2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 14px;
    display: block;
}

.login-logo h2 {
    color: var(--primary-dark);
    font-weight: 800;
    font-size: 1.35rem;
}

/* ========================================
   PROFILE (Orphan/Sponsor View)
   ======================================== */
.profile-photo {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--primary-light);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    transition: var(--transition);
}

.profile-photo:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
}

.profile-photo-placeholder {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 3rem;
    border: 4px solid #fff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 3px;
    text-transform: none;
}

.info-value {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-word;
}

/* ========================================
   TABS
   ======================================== */
.nav-tabs {
    border-bottom: 2px solid var(--border-color);
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar {
    display: none;
}

.nav-tabs .nav-link {
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 12px 18px;
    transition: var(--transition);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    white-space: nowrap;
    font-size: 0.88rem;
}

.nav-tabs .nav-link:hover {
    color: var(--primary);
    background: rgba(41, 128, 185, 0.06);
}

.nav-tabs .nav-link.active {
    color: var(--primary);
    border-bottom: 3px solid var(--primary);
    background: transparent;
    font-weight: 700;
}

/* ========================================
   MODALS
   ======================================== */
.modal-content {
    border: none;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.modal-header {
    padding: 16px 24px;
    border: none;
}

.modal-header .modal-title {
    font-weight: 700;
    font-size: 1.05rem;
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid #f0f0f0;
    gap: 8px;
}

/* RTL modal close button */
.modal-header .btn-close {
    margin: 0;
    margin-left: 0;
    margin-right: auto;
}

/* ========================================
   PERMISSION MATRIX
   ======================================== */
.permission-matrix {
    border-radius: var(--radius);
    overflow: hidden;
    width: 100%;
}

.permission-matrix th {
    background: var(--primary);
    color: #fff;
    padding: 12px 14px;
    font-weight: 600;
    text-align: center;
    font-size: 0.85rem;
}

.permission-matrix td {
    padding: 11px 14px;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f0;
}

.permission-matrix .form-check-input {
    width: 22px;
    height: 22px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.permission-matrix .form-check-input:checked {
    background-color: var(--success);
    border-color: var(--success);
}

.permission-matrix .module-name {
    font-weight: 600;
    text-align: right;
    color: var(--text-primary);
}

/* ========================================
   MEDIA GALLERY
   ======================================== */
.media-card {
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    background: #fff;
}

.media-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--card-shadow-hover);
}

.media-card img,
.media-card video {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.media-card .media-info {
    padding: 12px;
    font-size: 0.82rem;
}

.media-card .media-date {
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* Orphan portal card */
.orphan-portal-card {
    transition: var(--transition);
    border: 2px solid transparent;
}

.orphan-portal-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-4px);
}

/* ========================================
   FINANCIAL SUMMARY
   ======================================== */
.financial-card {
    border-radius: var(--radius);
    padding: 18px;
    text-align: center;
    color: #fff;
}

.financial-card .amount {
    font-size: 1.5rem;
    font-weight: 800;
}

.financial-card .label {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* ========================================
   TOGGLE SWITCH
   ======================================== */
.form-switch .form-check-input {
    width: 3em;
    height: 1.5em;
    cursor: pointer;
    transition: var(--transition-fast);
}

.form-switch .form-check-input:checked {
    background-color: var(--success);
    border-color: var(--success);
}

/* ========================================
   TIMELINE
   ======================================== */
.timeline {
    position: relative;
    padding: 20px 0;
}

.timeline::before {
    content: '';
    position: absolute;
    right: 20px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, var(--primary-light), var(--border-color));
    border-radius: 3px;
}

.timeline-item {
    position: relative;
    padding-right: 50px;
    margin-bottom: 24px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    right: 14px;
    top: 6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px var(--primary-light);
    transition: var(--transition-fast);
}

.timeline-item.active::before {
    background: var(--success);
    box-shadow: 0 0 0 2px var(--success-light), 0 0 12px rgba(39, 174, 96, 0.3);
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in {
    animation: fadeInUp 0.45s ease-out both;
}

.slide-in {
    animation: slideInRight 0.4s ease-out both;
}

/* GPU layer promotion for frequently animated elements */
.stat-card, .card, .btn, .media-card { will-change: transform; }

/* View Transitions API (Chrome 111+) */
@view-transition {
    navigation: auto;
}

::view-transition-old(root) {
    animation: 0.15s ease-out both fadeIn;
    animation-direction: reverse;
}

::view-transition-new(root) {
    animation: 0.25s ease-out both fadeInUp;
}

/* Page enter animation (fallback for non-VT browsers) */
.main-content {
    animation: fadeInUp 0.3s ease-out;
}

/* Staggered animation for stat cards */
.row>[class*="col-"]:nth-child(1) .stat-card {
    animation: fadeInUp 0.4s ease-out 0.05s both;
}

.row>[class*="col-"]:nth-child(2) .stat-card {
    animation: fadeInUp 0.4s ease-out 0.1s both;
}

.row>[class*="col-"]:nth-child(3) .stat-card {
    animation: fadeInUp 0.4s ease-out 0.15s both;
}

.row>[class*="col-"]:nth-child(4) .stat-card {
    animation: fadeInUp 0.4s ease-out 0.2s both;
}

.row>[class*="col-"]:nth-child(5) .stat-card {
    animation: fadeInUp 0.4s ease-out 0.25s both;
}

.row>[class*="col-"]:nth-child(6) .stat-card {
    animation: fadeInUp 0.4s ease-out 0.3s both;
}

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h5 {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* ========================================
   SCROLLBAR
   ======================================== */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #c8c8c8;
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ========================================
   SWEETALERT RTL
   ======================================== */
.swal2-rtl {
    direction: rtl;
}

.swal2-popup {
    border-radius: 18px !important;
    font-family: var(--font-family) !important;
    padding: 24px !important;
}

.swal2-title {
    font-size: 1.2rem !important;
    font-weight: 700 !important;
}

.swal2-html-container {
    font-size: 0.92rem !important;
}

.swal2-confirm,
.swal2-cancel {
    border-radius: var(--radius-sm) !important;
    font-weight: 600 !important;
    padding: 10px 28px !important;
}

/* ========================================
   BOOTSTRAP RTL OVERRIDES
   ======================================== */
.text-start {
    text-align: right !important;
}

.text-end {
    text-align: left !important;
}

.ms-1,
.ms-2,
.ms-3,
.ms-auto {
    margin-right: inherit;
}

.me-1 {
    margin-left: 0.25rem !important;
    margin-right: 0 !important;
}

.me-2 {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

.me-3 {
    margin-left: 1rem !important;
    margin-right: 0 !important;
}

.me-auto {
    margin-left: auto !important;
    margin-right: 0 !important;
}

.ps-1,
.ps-2,
.ps-3 {
    padding-right: inherit;
}

.pe-1 {
    padding-left: 0.25rem !important;
}

.pe-2 {
    padding-left: 0.5rem !important;
}

.float-start {
    float: right !important;
}

.float-end {
    float: left !important;
}

/* Dropdown menu RTL */
.dropdown-menu {
    text-align: right;
}

.dropdown-menu-end {
    left: 0;
    right: auto;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

.divider {
    height: 1px;
    background: var(--border-color);
    margin: 16px 0;
}

/* ========================================
   RESPONSIVE — TABLET (992px)
   ======================================== */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-right: 0 !important;
        padding: 16px;
    }

    .top-bar {
        border-radius: var(--radius-sm);
        top: 8px;
        margin-left: 0;
        margin-right: 0;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .page-title {
        font-size: 1.2rem;
    }

    .stat-card .stat-value {
        font-size: 1.6rem;
    }

    .stat-card .stat-icon {
        font-size: 2.2rem;
    }

    .card-body {
        padding: 16px;
    }

    .profile-photo,
    .profile-photo-placeholder {
        width: 110px;
        height: 110px;
    }

    /* Tables scroll horizontally on tablet */
    .card .dataTables_wrapper {
        overflow-x: auto;
    }

    /* Modal full width on tablet */
    .modal-dialog {
        max-width: 90%;
        margin: 1rem auto;
    }

    .nav-tabs .nav-link {
        padding: 10px 14px;
        font-size: 0.84rem;
    }
}

/* ========================================
   RESPONSIVE — MOBILE (576px)
   ======================================== */
@media (max-width: 576px) {
    .main-content {
        padding: 10px;
    }

    .top-bar {
        padding: 8px 12px;
        margin-bottom: 14px;
        top: 4px;
    }

    .page-title {
        font-size: 1.05rem;
    }

    .page-header .btn {
        width: 100%;
        text-align: center;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card .stat-value {
        font-size: 1.4rem;
    }

    .stat-card .stat-icon {
        font-size: 1.8rem;
        top: 12px;
        left: 12px;
    }

    .stat-card .stat-label {
        font-size: 0.78rem;
    }

    .card-body {
        padding: 12px;
    }

    .card-header {
        padding: 12px 14px;
        font-size: 0.88rem;
    }

    .form-section {
        padding: 14px;
    }

    .profile-photo,
    .profile-photo-placeholder {
        width: 90px;
        height: 90px;
        font-size: 2rem;
    }

    /* Stack form columns */
    .row.g-3>[class*="col-md-"],
    .row.g-3>[class*="col-lg-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Full width modal on mobile */
    .modal-dialog {
        max-width: 100%;
        margin: 0.5rem;
    }

    .modal-body {
        padding: 14px 16px;
    }

    /* Table font size */
    table.dataTable thead th {
        font-size: 0.78rem;
        padding: 10px 8px;
    }

    table.dataTable tbody td {
        font-size: 0.78rem;
        padding: 8px;
    }

    .btn-action {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }

    /* DataTables search and length */
    .dataTables_wrapper .dataTables_filter input {
        min-width: 140px;
    }

    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length {
        width: 100%;
        text-align: right !important;
        margin-bottom: 8px;
    }

    /* Tabs scroll */
    .nav-tabs .nav-link {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    /* Login */
    .login-card {
        padding: 28px 20px;
        border-radius: 18px;
    }

    .login-logo i {
        font-size: 2.5rem;
    }

    .login-logo h2 {
        font-size: 1.1rem;
    }

    /* Permission matrix responsive */
    .permission-matrix {
        font-size: 0.78rem;
    }

    .permission-matrix th {
        padding: 8px 4px;
        font-size: 0.75rem;
    }

    .permission-matrix td {
        padding: 8px 4px;
    }

    .permission-matrix .form-check-input {
        width: 18px;
        height: 18px;
    }

    /* Timeline */
    .timeline::before {
        right: 12px;
    }

    .timeline-item {
        padding-right: 36px;
    }

    .timeline-item::before {
        right: 6px;
        width: 12px;
        height: 12px;
    }

    /* Portal orphan cards */
    .orphan-portal-card .rounded-circle {
        width: 70px !important;
        height: 70px !important;
    }
}

/* ========================================
   PRINT
   ======================================== */
@media print {

    .sidebar,
    .top-bar,
    .btn,
    .dataTables_filter,
    .dataTables_length,
    .dataTables_paginate,
    .sidebar-overlay {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    .stat-card {
        border: 1px solid #ddd;
        color: #333 !important;
        background: #f9f9f9 !important;
    }

    body {
        background: #fff;
    }
}