/**
 * MoM Documentation System - Main Stylesheet
 * Version: 1.0.0
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    /* Colors */
    --primary: #d4a853;
    --primary-light: #e8c97a;
    --primary-dark: #b8923f;
    --primary-rgb: 212, 168, 83;
    
    /* Background Colors */
    --bg-primary: #0a0f1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1f2937;
    --bg-card: #161f2e;
    --bg-hover: rgba(255, 255, 255, 0.05);
    
    /* Text Colors */
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --text-inverse: #0a0f1a;
    
    /* Border Colors */
    --border-color: #374151;
    --border-light: rgba(255, 255, 255, 0.1);
    
    /* Status Colors */
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);
    --info: #3b82f6;
    --info-light: rgba(59, 130, 246, 0.15);
    
    /* Level Colors */
    --level-1: #d4a853;
    --level-2: #3b82f6;
    --level-3: #10b981;
    --level-4: #8b5cf6;
    --level-5: #ec4899;
    --level-6: #6b7280;
    
    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --header-height: 64px;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;
    
    /* Fonts */
    --font-en: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-ar: 'IBM Plex Sans Arabic', 'Cairo', sans-serif;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 25px 50px rgba(0, 0, 0, 0.5);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

/* ============================================
   Base Reset & Typography
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-en);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

[dir="rtl"] body {
    font-family: var(--font-ar);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-light);
}

img {
    max-width: 100%;
    height: auto;
}

/* ============================================
   App Loader
   ============================================ */
.app-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.app-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Layout Structure
   ============================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition-normal), width var(--transition-normal);
}

[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary);
    font-size: 18px;
    font-weight: 700;
    text-decoration: none;
}

.sidebar-logo img {
    width: 32px;
    height: 32px;
}

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

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-secondary);
    border-radius: var(--border-radius);
    margin-bottom: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

a.nav-item.nav-link-external {
    text-decoration: none;
    color: var(--text-secondary);
}

a.nav-item.nav-link-external:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

[dir="rtl"] .nav-badge {
    margin-left: 0;
    margin-right: auto;
}

/* Nav Group - Collapsible Menu */
.nav-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    color: var(--text-secondary);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.nav-group-header:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-group-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.nav-group-title i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.nav-group-arrow {
    font-size: 12px;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

.nav-group-header.collapsed .nav-group-arrow {
    transform: rotate(-90deg);
}

[dir="rtl"] .nav-group-header.collapsed .nav-group-arrow {
    transform: rotate(90deg);
}

.nav-group-items {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    opacity: 1;
}

.nav-group-items.collapsed {
    max-height: 0;
    opacity: 0;
}

.nav-group-items .nav-item {
    padding-left: 44px;
    font-size: 13px;
}

[dir="rtl"] .nav-group-items .nav-item {
    padding-left: 12px;
    padding-right: 44px;
}

.nav-group-items .nav-item i {
    font-size: 14px;
    width: 18px;
}

/* Active state for parent group when child is active */
.nav-group-header.has-active {
    color: var(--primary);
}

.nav-group-header.has-active .nav-group-title i {
    color: var(--primary);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

[dir="rtl"] .main-content {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

/* ============================================
   Header
   ============================================ */
.header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
}

.header-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all var(--transition-fast);
}

.header-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.header-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-menu:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: var(--text-inverse);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.user-info {
    text-align: left;
}

[dir="rtl"] .user-info {
    text-align: right;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================
   Page Content
   ============================================ */
.page-content {
    flex: 1;
    padding: 24px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

/* ============================================
   Stats Grid
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-icon.primary { background: rgba(var(--primary-rgb), 0.15); color: var(--primary); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.info { background: var(--info-light); color: var(--info); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.danger { background: var(--danger-light); color: var(--danger); }

.stat-content h3 {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 4px;
}

.stat-content p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ============================================
   Grid Layout
   ============================================ */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-label.required::after {
    content: ' *';
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.form-control:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

[dir="rtl"] select.form-control {
    background-position: left 12px center;
    padding-right: 16px;
    padding-left: 36px;
}

.form-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-error {
    font-size: 13px;
    color: var(--danger);
    margin-top: 6px;
}

/* Form Row */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 576px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-light);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    filter: brightness(1.1);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    filter: brightness(1.1);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

/* Button Group */
.btn-group {
    display: flex;
    gap: 8px;
}

/* ============================================
   Tables
   ============================================ */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

[dir="rtl"] .table th,
[dir="rtl"] .table td {
    text-align: right;
}

.table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover td {
    background: var(--bg-hover);
}

.table-actions {
    display: flex;
    gap: 8px;
}

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

/* Status Badges */
.badge-draft { background: rgba(107, 114, 128, 0.2); color: #9ca3af; }
.badge-submitted { background: var(--info-light); color: #60a5fa; }
.badge-under-review { background: var(--warning-light); color: #fbbf24; }
.badge-approved { background: var(--success-light); color: #34d399; }
.badge-rejected { background: var(--danger-light); color: #f87171; }
.badge-archived { background: rgba(139, 92, 246, 0.2); color: #a78bfa; }
.badge-active { background: var(--success-light); color: #34d399; }
.badge-inactive { background: rgba(107, 114, 128, 0.2); color: #9ca3af; }
.badge-pending { background: var(--warning-light); color: #fbbf24; }

/* Priority Badges */
.badge-low { background: var(--success-light); color: var(--success); }
.badge-medium { background: var(--warning-light); color: var(--warning); }
.badge-high { background: rgba(249, 115, 22, 0.2); color: #fb923c; }
.badge-urgent { background: var(--danger-light); color: var(--danger); }

/* Level Badges */
.level-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.level-1 { background: rgba(var(--primary-rgb), 0.2); color: var(--level-1); }
.level-2 { background: var(--info-light); color: var(--level-2); }
.level-3 { background: var(--success-light); color: var(--level-3); }
.level-4 { background: rgba(139, 92, 246, 0.2); color: var(--level-4); }
.level-5 { background: rgba(236, 72, 153, 0.2); color: var(--level-5); }
.level-6 { background: rgba(107, 114, 128, 0.2); color: var(--level-6); }

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--border-radius-xl);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 600px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-xl);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal.modal-lg {
    max-width: 800px;
}

.modal.modal-sm {
    max-width: 400px;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

[dir="rtl"] .toast-container {
    right: auto;
    left: 20px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 16px 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    animation: slideInRight var(--transition-normal) ease;
}

[dir="rtl"] .toast {
    animation: slideInLeft var(--transition-normal) ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--info); }

[dir="rtl"] .toast {
    border-left: none;
}
[dir="rtl"] .toast.success { border-right: 4px solid var(--success); }
[dir="rtl"] .toast.error { border-right: 4px solid var(--danger); }
[dir="rtl"] .toast.warning { border-right: 4px solid var(--warning); }
[dir="rtl"] .toast.info { border-right: 4px solid var(--info); }

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.toast-message {
    font-size: 14px;
    color: var(--text-secondary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}

.toast-close:hover {
    color: var(--text-primary);
}

/* ============================================
   Tabs
   ============================================ */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.tab {
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast);
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--primary);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ============================================
   Dropdown
   ============================================ */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-fast);
}

[dir="rtl"] .dropdown-menu {
    right: auto;
    left: 0;
}

.dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(4px);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.dropdown-item i {
    width: 16px;
    text-align: center;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

/* ============================================
   Tree View (Hierarchy)
   ============================================ */
.tree-container {
    padding: 8px 0;
}

.tree-node {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    transition: all var(--transition-fast);
}

.tree-node:hover {
    background: var(--bg-hover);
}

.tree-node.locked {
    border: 2px dashed var(--border-color);
}

.tree-node.dragging {
    opacity: 0.5;
}

.tree-node.drag-over {
    background: var(--success-light);
    border: 2px solid var(--success);
}

.tree-node.drag-over-invalid {
    background: var(--danger-light);
    border: 2px solid var(--danger);
}

.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 14px;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.tree-node.locked .drag-handle {
    cursor: not-allowed;
}

.tree-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tree-name {
    font-weight: 500;
}

.tree-name-ar {
    color: var(--text-muted);
    font-size: 13px;
}

.tree-children {
    margin-left: 24px;
    padding-left: 16px;
    border-left: 2px solid var(--border-color);
}

[dir="rtl"] .tree-children {
    margin-left: 0;
    margin-right: 24px;
    padding-left: 0;
    padding-right: 16px;
    border-left: none;
    border-right: 2px solid var(--border-color);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    max-width: 400px;
    margin: 0 auto;
}

/* ============================================
   Loading States
   ============================================ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    border-radius: var(--border-radius);
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   Alerts
   ============================================ */
.alert {
    padding: 16px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert-success {
    background: var(--success-light);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.alert-danger {
    background: var(--danger-light);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-warning {
    background: var(--warning-light);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}

.alert-info {
    background: var(--info-light);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

/* ============================================
   Login Page
   ============================================ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    padding: 20px;
}

.login-box {
    background: var(--bg-card);
    border-radius: var(--border-radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo img {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
}

.login-logo h1 {
    color: var(--primary);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 14px;
}

.lang-switch {
    position: fixed;
    top: 20px;
    right: 20px;
}

[dir="rtl"] .lang-switch {
    right: auto;
    left: 20px;
}

/* ============================================
   Workflow Stepper
   ============================================ */
.workflow-stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
}

.workflow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex: 1;
}

.workflow-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 16px;
    left: calc(50% + 20px);
    right: calc(-50% + 20px);
    height: 2px;
    background: var(--border-color);
}

.workflow-step.completed:not(:last-child)::after {
    background: var(--success);
}

.step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.workflow-step.active .step-circle {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-inverse);
}

.workflow-step.completed .step-circle {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.step-label {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

.workflow-step.active .step-label,
.workflow-step.completed .step-label {
    color: var(--text-primary);
}

/* ============================================
   Digital Signature
   ============================================ */
.signature-pad {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-tertiary);
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: crosshair;
}

.signature-pad canvas {
    width: 100%;
    height: 200px;
}

.signature-actions {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

/* ============================================
   File Upload
   ============================================ */
.file-upload {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.file-upload:hover {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.05);
}

.file-upload.dragover {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
}

.file-upload i {
    font-size: 48px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.file-upload p {
    color: var(--text-secondary);
}

.file-list {
    margin-top: 16px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-hover);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 500;
    margin-bottom: 2px;
}

.file-size {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .page-content {
        padding: 16px;
    }
    
    .header {
        padding: 0 16px;
    }
    
    .user-info {
        display: none;
    }
    
    .modal {
        max-height: calc(100vh - 20px);
        margin: 10px;
    }
}

/* Mobile menu overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

@media (max-width: 768px) {
    .sidebar-overlay.active {
        display: block;
    }
}

/* ============================================
   Utilities
   ============================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.m-0 { margin: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.p-0 { padding: 0; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }

.d-flex { display: flex; }
.d-block { display: block; }
.d-none { display: none; }

.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }

.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

.rounded { border-radius: var(--border-radius); }
.rounded-lg { border-radius: var(--border-radius-lg); }

.shadow { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* ============================================
   Enhanced Hierarchy View with Holders
   ============================================ */

.tree-node {
    position: relative;
}

.tree-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tree-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.position-holders {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

.holder-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--accent-gold);
}

.holder-badge .primary-indicator {
    color: #ffd700;
    font-size: 0.65rem;
}

.vacant-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--danger);
}

.vacant-position {
    border-left: 3px solid var(--danger);
}

.type-badge {
    display: inline-flex;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
}

.type-badge.type-council {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
}

.type-badge.type-committee {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.type-badge.type-team {
    background: rgba(249, 115, 22, 0.2);
    color: #fb923c;
}

.type-badge.type-working_group {
    background: rgba(236, 72, 153, 0.2);
    color: #f472b6;
}

/* Position Details Modal */
.position-details .position-icon {
    color: #000;
}

.holder-item .holder-avatar,
.holder-row .holder-avatar {
    width: 36px;
    height: 36px;
    background: var(--accent-gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #000;
    flex-shrink: 0;
}

/* Approval Chain Preview */
.approval-chain-preview {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
}

.chain-step {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 12px;
}

.chain-step .step-number {
    width: 28px;
    height: 28px;
    background: var(--accent-gold);
    color: #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.chain-arrow {
    text-align: center;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 4px 0;
}

/* Manage Holders */
.manage-holders hr {
    border: none;
    border-top: 1px solid var(--border-color);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .tree-main {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .position-holders {
        margin-top: 8px;
    }
    
    .holder-row {
        flex-wrap: wrap;
    }
    
    .holder-row select {
        width: 100% !important;
        margin-top: 8px;
    }
}

/* ============================================
   Top Level Drop Zone
   ============================================ */

.top-level-drop-zone {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.1), rgba(212, 175, 55, 0.05));
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    margin-bottom: 16px;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.top-level-drop-zone:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.top-level-drop-zone.drag-over {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    transform: scale(1.02);
}

.top-level-drop-zone i {
    margin-right: 8px;
}

/* Reorganize Modal */
.reorganize-modal .reorganize-list {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
}

.reorganize-item {
    transition: all 0.2s ease;
}

.reorganize-item:hover {
    background: var(--bg-primary) !important;
}

.reorganize-item .drag-handle {
    color: var(--text-muted);
    cursor: grab;
}

.reorganize-item .drag-handle:active {
    cursor: grabbing;
}

/* Change Parent Button */
.btn-group .btn-ghost[title*="Change"] i,
.btn-group .btn-ghost[title*="تغيير"] i {
    color: var(--info);
}

/* Modal Large */
.modal-lg .modal-content {
    max-width: 700px;
}

/* Better tree node hover for drag */
.tree-node {
    transition: all 0.2s ease;
}

.tree-node.drag-over {
    background: rgba(212, 175, 55, 0.15) !important;
    border-color: var(--accent-gold) !important;
    transform: translateX(5px);
}

.tree-node.drag-over-invalid {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: var(--danger) !important;
}

.tree-node.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

/* ============================================
   User Statistics Cards
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    border-color: var(--accent-gold);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(212, 175, 55, 0.2);
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-card.stat-success .stat-icon {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.stat-card.stat-danger .stat-icon {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.stat-card.stat-warning .stat-icon {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.stat-card.stat-info .stat-icon {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info);
}

.stat-card .stat-info {
    flex: 1;
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Bulk Actions Bar */
.bulk-actions-bar {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(212, 175, 55, 0.05));
    border: 1px solid var(--accent-gold);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bulk-actions-bar #selected-count {
    font-weight: 700;
    color: var(--accent-gold);
    font-size: 18px;
}

/* Status Badge Hover */
.status-badge {
    transition: all 0.2s ease;
}

.status-badge:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* User checkbox styling */
.user-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

#select-all-users {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Import Preview */
#import-preview-table {
    font-size: 12px;
}

#import-preview-table th {
    background: var(--bg-primary);
    font-weight: 600;
}

/* Flex wrap for filters */
.flex-wrap {
    flex-wrap: wrap;
}

/* ============================================
   Collapsible Tree
   ============================================ */

.tree-node-wrapper {
    position: relative;
}

.btn-collapse {
    width: 24px;
    height: 24px;
    border: none;
    background: var(--bg-secondary);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-collapse:hover {
    background: var(--accent-gold);
    color: var(--bg-primary);
}

.btn-collapse.collapsed {
    background: var(--bg-tertiary);
}

.collapse-spacer {
    width: 24px;
    flex-shrink: 0;
}

.tree-children {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    max-height: 5000px;
    opacity: 1;
}

.tree-children.collapsed {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

.tree-node.collapsed {
    opacity: 0.7;
}

.children-count {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 4px;
}

/* Expand/Collapse All Button Group */
.btn-group-toggle {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.btn-group-toggle .btn {
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--border-color);
}

.btn-group-toggle .btn:last-child {
    border-right: none;
}

/* ============================================
   Same-Level Reorder Drop Zones
   ============================================ */

.tree-drop-zone {
    height: 4px;
    margin: 2px 0;
    border-radius: 2px;
    transition: all 0.2s ease;
    position: relative;
}

.tree-drop-zone.active {
    height: 8px;
    background: var(--accent-gold);
    margin: 8px 0;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.tree-drop-zone.active::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 2px;
    background: var(--accent-gold);
}

.tree-drop-zone.active::after {
    content: '↕';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: var(--accent-gold);
    color: var(--bg-primary);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

/* Tree Node Updates */
.tree-node {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Drag handle updates */
.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    user-select: none;
    font-size: 14px;
    padding: 4px;
}

.drag-handle:active {
    cursor: grabbing;
}

.tree-node.dragging .drag-handle {
    cursor: grabbing;
}

/* ============================================
   Two-Branch Hierarchy Styles
   ============================================ */

/* Governing Body Card */
.governing-body-card {
    background: linear-gradient(145deg, rgba(168, 85, 247, 0.15), rgba(168, 85, 247, 0.05));
    border: 2px solid #a855f7;
    border-radius: 12px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.governing-label {
    background: #a855f7;
    color: white;
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.governing-content {
    padding: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.governing-content:hover {
    background: rgba(168, 85, 247, 0.1);
}

.governing-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.governing-name-ar {
    font-size: 1rem;
    color: #c084fc;
    margin-bottom: 10px;
}

/* Branch Tabs */
.branch-tabs {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.branch-tabs .tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

.branch-tabs .tab:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

.branch-tabs .tab.active {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

.branch-content {
    display: none;
}

.branch-content.active {
    display: block;
}

/* Two Branch Container */
.two-branch-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px;
}

@media (max-width: 1024px) {
    .two-branch-container {
        grid-template-columns: 1fr;
    }
}

/* Branch Column */
.branch-column {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.branch-header-bar {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.branch-header-bar .badge {
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

.branch-header-bar.admin {
    background: linear-gradient(135deg, #1e40af, #1e3a8a);
    color: #93c5fd;
}

.branch-header-bar.groups {
    background: linear-gradient(135deg, #166534, #14532d);
    color: #86efac;
}

.branch-tree-container {
    padding: 15px;
    min-height: 300px;
    max-height: 600px;
    overflow-y: auto;
}

/* Tree Node Styling Updates */
.tree-node {
    display: block;
    margin-bottom: 2px;
}

.tree-node-content {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.tree-node-content:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.tree-node.node-council .tree-node-content {
    border-left: 4px solid #a855f7;
}

.tree-node.node-committee .tree-node-content {
    border-left: 4px solid #f59e0b;
}

.tree-node.node-vacant .tree-node-content {
    border-left: 4px solid var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

/* Collapse Button */
.btn-collapse {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    border-radius: 4px;
    flex-shrink: 0;
}

.btn-collapse:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.collapse-spacer {
    width: 20px;
    flex-shrink: 0;
}

/* Drag Handle */
.tree-drag-handle {
    color: var(--text-muted);
    cursor: grab;
    user-select: none;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 4px;
    flex-shrink: 0;
}

.tree-drag-handle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tree-drag-handle:active {
    cursor: grabbing;
}

/* Tree Info */
.tree-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.tree-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-holder {
    font-size: 12px;
    color: var(--success);
    background: var(--success-light);
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.tree-holder.vacant {
    color: var(--danger);
    background: var(--danger-light);
}

.tree-holder .holder-count {
    margin-left: 4px;
    opacity: 0.7;
}

/* Type Badge */
.type-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 600;
    white-space: nowrap;
}

.type-badge.council {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
}

.type-badge.committee {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

/* Children Count */
.children-count {
    font-size: 11px;
    color: var(--text-muted);
}

/* Tree Actions */
.tree-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.tree-node-content:hover .tree-actions {
    opacity: 1;
}

/* Tree Children */
.tree-children {
    margin-left: 30px;
    padding-left: 15px;
    border-left: 2px solid var(--border-color);
    margin-top: 5px;
    overflow: hidden;
    max-height: 2000px;
    transition: max-height 0.3s ease-out, opacity 0.2s;
}

.tree-children.collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
}

/* Drop Zones */
.tree-drop-zone {
    height: 4px;
    margin: 2px 0;
    border-radius: 2px;
    transition: all 0.2s;
}

.tree-drop-zone.drag-over,
.tree-drop-zone:hover {
    height: 8px;
    background: var(--primary);
    box-shadow: 0 0 10px rgba(212, 168, 83, 0.5);
}

.top-level-drop-zone {
    padding: 15px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 15px;
    transition: all 0.2s;
}

.top-level-drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(212, 168, 83, 0.1);
    color: var(--primary);
}

/* Relationships Container */
.relationships-container {
    min-height: 300px;
}

.relationships-table .table {
    background: var(--bg-secondary);
}

.relationship-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

/* Legend */
.tree-legend .legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 20px;
}

.tree-legend .legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.tree-legend .legend-color.admin {
    background: #3b82f6;
}

.tree-legend .legend-color.council {
    background: #a855f7;
}

.tree-legend .legend-color.committee {
    background: #f59e0b;
}

.tree-legend .legend-color.vacant {
    background: var(--danger);
}

/* Badge colors */
.badge-purple {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i {
    margin-bottom: 15px;
    opacity: 0.5;
}

/* Dragging State */
.tree-node-content.dragging {
    opacity: 0.5;
    border-color: var(--primary);
}

/* Org Chart Button */
.btn-icon {
    padding: 8px 10px;
}

/* ============================================
   AlBND v2.0 CSS ADDITIONS
   ============================================ */

/* FIX: Ensure collapse works reliably */
.tree-children.collapsed {
    display: none !important;
}

/* ============================================
   VERTICAL TREE LAYOUT (NEW)
   ============================================ */
:root {
    --tree-line-color: #4b5563;
    --tree-node-spacing: 20px;
}

.vertical-tree-container {
    overflow-x: auto;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-lg);
    min-height: 400px;
}

/* Tree wrapper for centering */
.vertical-tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 40px;
}

/* Tree Node */
.vtree-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 0 15px;
}

/* Node Card */
.vtree-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 12px 16px;
    min-width: 180px;
    max-width: 250px;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 2;
}

.vtree-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 20px rgba(212, 168, 83, 0.2);
    transform: translateY(-2px);
}

.vtree-card.node-council {
    border-color: #a855f7;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(168, 85, 247, 0.1) 100%);
}

.vtree-card.node-committee {
    border-color: #f59e0b;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(245, 158, 11, 0.1) 100%);
}

.vtree-card.node-vacant {
    border-color: var(--danger);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(239, 68, 68, 0.05) 100%);
}

/* Node Title */
.vtree-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
}

.vtree-title-ar {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    direction: rtl;
}

/* Node Holder */
.vtree-holder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    margin-top: 6px;
}

.vtree-holder.filled {
    background: var(--success-light);
    color: var(--success);
}

.vtree-holder.vacant {
    background: var(--danger-light);
    color: var(--danger);
}

.vtree-holder-extra {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 4px;
}

/* Node Type Badge */
.vtree-type {
    position: absolute;
    top: -10px;
    right: 10px;
    font-size: 9px;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 600;
}

.vtree-type.council {
    background: #a855f7;
    color: white;
}

.vtree-type.committee {
    background: #f59e0b;
    color: white;
}

/* Node Actions */
.vtree-actions {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.vtree-card:hover .vtree-actions {
    opacity: 1;
}

.vtree-action-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.2s;
}

.vtree-action-btn:hover {
    background: var(--primary);
    color: var(--text-inverse);
}

.vtree-action-btn.danger:hover {
    background: var(--danger);
    color: white;
}

/* Vertical Connector Lines */
.vtree-connector-down {
    width: 2px;
    height: 25px;
    background: var(--tree-line-color);
    margin: 0 auto;
}

/* Children Container */
.vtree-children {
    display: flex;
    justify-content: center;
    position: relative;
    padding-top: 0;
}

/* Horizontal line above children */
.vtree-children::before {
    content: '';
    position: absolute;
    top: 0;
    height: 2px;
    background: var(--tree-line-color);
    left: calc(50% - 50px);
    right: calc(50% - 50px);
}

/* Each child has vertical line going up */
.vtree-children > .vtree-node {
    position: relative;
}

.vtree-children > .vtree-node::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 25px;
    background: var(--tree-line-color);
}

/* Single child - no horizontal line */
.vtree-children[data-count="1"]::before {
    display: none;
}

/* Multi-children horizontal span */
.vtree-children:not([data-count="1"])::before {
    left: 15%;
    right: 15%;
}

/* Collapse/Expand Button */
.vtree-toggle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 2px solid var(--tree-line-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    margin: 5px auto;
    position: relative;
    z-index: 3;
    transition: all 0.2s;
}

.vtree-toggle:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-inverse);
}

.vtree-toggle.collapsed {
    background: var(--bg-secondary);
}

/* Hidden children */
.vtree-children.collapsed {
    display: none;
}

/* Drag and Drop States */
.vtree-card.dragging {
    opacity: 0.5;
    border-style: dashed;
}

.vtree-card.drag-over {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(212, 168, 83, 0.4);
}

/* ============================================
   Role Badges (New 4-tier system)
   ============================================ */
.role-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.role-badge.master-admin,
.role-badge.master_admin {
    background: linear-gradient(135deg, #d4a853, #f59e0b);
    color: #000;
}

.role-badge.level-admin,
.role-badge.level_admin {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: white;
}

.role-badge.entity-manager,
.role-badge.entity_manager {
    background: linear-gradient(135deg, #10b981, #14b8a6);
    color: white;
}

.role-badge.member {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* RTL Support additions */
body.lang-ar {
    direction: rtl;
}

body.lang-ar .sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border-color);
}

body.lang-ar .main-content {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

body.lang-ar .nav-badge {
    margin-left: 0;
    margin-right: auto;
}

body.lang-ar .toast-container {
    right: auto;
    left: 20px;
}

body.lang-ar .tree-legend .legend-item {
    margin-right: 0;
    margin-left: 20px;
}

/* ============================================
   Responsive for Vertical Tree
   ============================================ */
@media (max-width: 1200px) {
    .vertical-tree-container {
        overflow-x: auto;
    }
    
    .vtree-card {
        min-width: 150px;
        padding: 10px 12px;
    }
    
    .vtree-title {
        font-size: 12px;
    }
}

/* Print Styles for Tree */
@media print {
    .vtree-actions,
    .vtree-toggle {
        display: none !important;
    }
    
    .vtree-card {
        border-color: #000 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}

/* ============================================
   GOVERNING BODY SECTION (Supreme Authority)
   ============================================ */
.governing-body-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.governing-body-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, rgba(212, 168, 83, 0.15) 0%, rgba(168, 85, 247, 0.1) 100%);
    border: 2px solid var(--primary);
    border-radius: var(--border-radius-lg);
    padding: 16px 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(212, 168, 83, 0.2);
    min-width: 350px;
}

.governing-body-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(212, 168, 83, 0.3);
}

.governing-crown {
    font-size: 32px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.governing-content {
    flex: 1;
}

.governing-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 4px;
}

.governing-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.governing-name-ar {
    font-size: 14px;
    color: var(--text-secondary);
    direction: rtl;
}

.governing-actions {
    display: flex;
    gap: 4px;
}

/* Connector from governing body to branches */
.governing-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 40px;
}

/* Governing Body Placeholder (when not set) */
.governing-body-placeholder {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, rgba(212, 168, 83, 0.15) 0%, rgba(100, 100, 100, 0.1) 100%);
    border: 3px dashed var(--primary);
    border-radius: var(--border-radius-lg);
    padding: 20px 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 400px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.governing-body-placeholder:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(212, 168, 83, 0.25) 0%, rgba(168, 85, 247, 0.15) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(212, 168, 83, 0.3);
}

.governing-body-placeholder .governing-crown {
    opacity: 0.7;
    font-size: 28px;
}

.governing-body-placeholder:hover .governing-crown {
    opacity: 1;
}

.connector-line {
    width: 2px;
    height: 25px;
    background: var(--primary);
}

.connector-split {
    width: 60%;
    max-width: 400px;
    height: 2px;
    background: var(--primary);
    position: relative;
}

.connector-split::before,
.connector-split::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 15px;
    background: var(--primary);
    bottom: 0;
}

.connector-split::before {
    left: 0;
}

.connector-split::after {
    right: 0;
}

/* ============================================
   ADVISORY BOARD ATTACHMENT
   ============================================ */
.tree-node-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 0;
}

.advisory-attachment {
    display: flex;
    align-items: center;
    margin-left: 0;
    position: relative;
}

.advisory-connector-line {
    width: 30px;
    height: 2px;
    background: #14b8a6;
    border-style: dashed;
    margin-right: -1px;
}

.advisory-card {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(20, 184, 166, 0.1) 100%);
    border: 2px dashed #14b8a6;
    border-radius: var(--border-radius-md);
    padding: 10px 14px;
    min-width: 180px;
    max-width: 220px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.advisory-card:hover {
    border-style: solid;
    box-shadow: 0 4px 15px rgba(20, 184, 166, 0.25);
    transform: translateY(-2px);
}

.advisory-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.advisory-icon {
    font-size: 16px;
}

.advisory-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #14b8a6;
    font-weight: 600;
}

.advisory-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.advisory-name-ar {
    font-size: 11px;
    color: var(--text-secondary);
    direction: rtl;
    margin-bottom: 6px;
}

.advisory-holder {
    font-size: 11px;
    margin-bottom: 6px;
}

.advisory-holder .filled {
    color: var(--success);
}

.advisory-holder .vacant {
    color: var(--danger);
}

.advisory-reports-to {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--text-muted);
    padding-top: 6px;
    border-top: 1px dashed var(--border-color);
}

.dotted-arrow {
    color: #14b8a6;
    font-family: monospace;
}

.reports-label {
    font-style: italic;
}

/* Advisory Board Type Badge */
.type-badge.advisory {
    background: rgba(20, 184, 166, 0.2);
    color: #14b8a6;
    border: 1px solid #14b8a6;
}

.node-advisory {
    border-left-color: #14b8a6 !important;
}

.node-advisory .tree-node-content {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(20, 184, 166, 0.05) 100%);
}

/* Advisory Info Box in Modal */
.advisory-info-box {
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-md);
    padding: 12px 16px;
    margin-bottom: 16px;
    border-left: 3px solid #14b8a6;
}

.advisory-info-box .info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.advisory-info-box .info-row:last-child {
    margin-bottom: 0;
}

.advisory-info-box .info-label {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 100px;
}

.advisory-info-box .info-value {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Legend update */
.tree-legend .legend-item.advisory::before {
    background: #14b8a6;
}

/* Password Reset Options */
.reset-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.reset-option {
    display: block;
    cursor: pointer;
}

.reset-option input[type="radio"] {
    display: none;
}

.reset-option-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-md);
    transition: all 0.2s ease;
}

.reset-option-content i {
    font-size: 24px;
    margin-top: 2px;
}

.reset-option input[type="radio"]:checked + .reset-option-content {
    border-color: var(--primary);
    background: rgba(212, 168, 83, 0.1);
}

.reset-option:hover .reset-option-content {
    border-color: var(--primary);
}

.new-password-display {
    background: linear-gradient(135deg, var(--bg-secondary), rgba(212, 168, 83, 0.1));
}

.input-group {
    display: flex;
    gap: 0;
}

.input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* ============================================
   MOBILE RESPONSIVE ENHANCEMENTS
   ============================================ */

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    padding: 8px;
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: background 0.2s;
}

.mobile-menu-toggle:hover {
    background: var(--bg-secondary);
}

/* Mobile Header Improvements */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .header {
        padding: 0 10px;
        height: 52px;
        gap: 8px;
    }
    
    .header-left {
        flex: 1;
        min-width: 0;
    }
    
    .header-title {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .header-right {
        gap: 4px;
        flex-shrink: 0;
    }
    
    .header-btn {
        width: 36px;
        height: 36px;
        padding: 0;
        font-size: 14px;
    }
    
    .user-menu {
        padding: 6px 8px;
        gap: 6px;
    }
    
    .user-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .user-info {
        display: none;
    }
    
    .user-menu .fa-chevron-down {
        display: none;
    }
}

/* Mobile Sidebar */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }
    
    [dir="rtl"] .sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%);
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar.open {
        transform: translateX(0) !important;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        backdrop-filter: blur(2px);
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100%;
    }
    
    .page-content {
        padding: 12px;
        padding-bottom: 80px;
    }
}

/* Mobile Stats Cards */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px;
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    
    .stat-card .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .stat-card .stat-value {
        font-size: 22px;
    }
    
    .stat-card .stat-label {
        font-size: 11px;
    }
}

/* ============================================
   MOBILE USER TABLE - CARD VIEW
   ============================================ */
@media (max-width: 768px) {
    /* Hide table header on mobile */
    .users-table thead {
        display: none;
    }
    
    .users-table tbody {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .users-table tbody tr {
        display: flex;
        flex-direction: column;
        background: var(--bg-secondary);
        border-radius: 12px;
        padding: 14px;
        border: 1px solid var(--border-color);
        gap: 10px;
    }
    
    .users-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        border: none;
        background: none !important;
    }
    
    .users-table tbody td:empty {
        display: none;
    }
    
    /* Checkbox cell */
    .users-table tbody td:first-child {
        position: absolute;
        top: 14px;
        right: 14px;
    }
    
    [dir="rtl"] .users-table tbody td:first-child {
        right: auto;
        left: 14px;
    }
    
    .users-table tbody tr {
        position: relative;
        padding-right: 50px;
    }
    
    [dir="rtl"] .users-table tbody tr {
        padding-right: 14px;
        padding-left: 50px;
    }
    
    /* User info - make it prominent */
    .users-table .user-cell {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 4px;
    }
    
    .users-table .user-cell .user-avatar {
        display: none;
    }
    
    .users-table .user-cell .user-details {
        width: 100%;
    }
    
    .users-table .user-cell .user-name {
        font-size: 16px;
        font-weight: 600;
    }
    
    .users-table .user-cell .user-email {
        font-size: 13px;
        word-break: break-all;
    }
    
    /* Actions at bottom, full width */
    .users-table tbody td:last-child {
        border-top: 1px solid var(--border-color);
        padding-top: 12px;
        margin-top: 4px;
    }
    
    .users-table .table-actions {
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .users-table .table-actions .btn {
        flex: 1;
        min-width: 60px;
        justify-content: center;
    }
    
    /* User stats grid */
    .user-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }
    
    .user-stat-card {
        padding: 12px;
        text-align: center;
    }
    
    .user-stat-card .stat-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
        margin: 0 auto 8px;
    }
    
    .user-stat-card .stat-number {
        font-size: 20px;
    }
    
    .user-stat-card .stat-label {
        font-size: 10px;
    }
    
    /* Bulk actions */
    .bulk-actions-bar {
        flex-direction: column;
        gap: 8px;
        padding: 12px;
    }
    
    .bulk-actions-bar .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   MOBILE MEETINGS TABLE
   ============================================ */
@media (max-width: 768px) {
    .meetings-table thead {
        display: none;
    }
    
    .meetings-table tbody {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .meetings-table tbody tr {
        display: flex;
        flex-direction: column;
        background: var(--bg-secondary);
        border-radius: 12px;
        padding: 14px;
        border: 1px solid var(--border-color);
        gap: 8px;
    }
    
    .meetings-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        border: none;
        background: none !important;
        font-size: 14px;
    }
    
    .meetings-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 12px;
    }
    
    .meetings-table tbody td:last-child {
        border-top: 1px solid var(--border-color);
        padding-top: 12px;
        margin-top: 4px;
    }
    
    .meetings-table .table-actions {
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
    }
}

/* ============================================
   MOBILE TREE VIEW - FIXED
   ============================================ */
@media (max-width: 768px) {
    .tree-view {
        padding: 8px;
        overflow-x: auto;
    }
    
    .branch-container {
        min-width: 300px;
    }
    
    .tree-node {
        margin-left: 12px !important;
    }
    
    [dir="rtl"] .tree-node {
        margin-left: 0 !important;
        margin-right: 12px !important;
    }
    
    .tree-item {
        padding: 10px;
        margin-bottom: 8px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        min-width: 250px;
    }
    
    .tree-main {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    
    .tree-toggle {
        position: absolute;
        top: 10px;
        left: 10px;
        width: 24px;
        height: 24px;
    }
    
    [dir="rtl"] .tree-toggle {
        left: auto;
        right: 10px;
    }
    
    .tree-item.has-children {
        padding-left: 40px;
    }
    
    [dir="rtl"] .tree-item.has-children {
        padding-left: 10px;
        padding-right: 40px;
    }
    
    .tree-info {
        width: 100%;
    }
    
    .tree-name {
        font-size: 13px;
        font-weight: 600;
        word-break: break-word;
    }
    
    .tree-type {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    .tree-meta {
        flex-wrap: wrap;
        gap: 4px;
        margin-top: 4px;
    }
    
    .tree-meta .badge {
        font-size: 9px;
        padding: 2px 5px;
    }
    
    .position-holders {
        width: 100%;
        margin-top: 6px;
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .holder-badge {
        font-size: 10px;
        padding: 3px 6px;
    }
    
    .tree-actions {
        width: 100%;
        justify-content: flex-start;
        gap: 6px;
        padding-top: 8px;
        border-top: 1px solid var(--border-color);
        flex-wrap: wrap;
    }
    
    .tree-actions .btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .tree-actions .btn span {
        display: none;
    }
    
    /* Branch headers */
    .branch-header {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .branch-header .badge {
        font-size: 11px;
        padding: 2px 8px;
    }
    
    /* Governing body */
    .governing-section {
        padding: 12px;
        margin-bottom: 16px;
    }
    
    .governing-body-display {
        padding: 14px;
        min-width: auto;
    }
    
    .governing-body-display .governing-crown {
        font-size: 24px;
    }
    
    .governing-body-placeholder {
        min-width: auto;
        width: 100%;
        padding: 14px;
        flex-direction: row;
        gap: 12px;
    }
    
    .governing-body-placeholder .governing-crown {
        font-size: 20px;
    }
    
    /* Two branches side by side - stack on mobile */
    .branches-container {
        flex-direction: column !important;
        gap: 16px;
    }
    
    .branch-wrapper {
        width: 100% !important;
        min-width: auto !important;
    }
}

/* ============================================
   MOBILE MODAL - BOTTOM SHEET STYLE
   ============================================ */
@media (max-width: 768px) {
    .modal-backdrop {
        padding: 0;
        align-items: flex-end;
    }
    
    .modal {
        width: 100%;
        max-width: 100%;
        max-height: 85vh;
        margin: 0;
        border-radius: 20px 20px 0 0;
        animation: slideUp 0.3s ease;
    }
    
    @keyframes slideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    .modal-header {
        padding: 20px 16px 12px;
        position: sticky;
        top: 0;
        background: var(--bg-primary);
        z-index: 10;
        border-bottom: 1px solid var(--border-color);
    }
    
    .modal-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: var(--border-color);
        border-radius: 2px;
    }
    
    .modal-header h3 {
        font-size: 16px;
        margin-top: 8px;
    }
    
    .modal-body {
        padding: 16px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-footer {
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        position: sticky;
        bottom: 0;
        background: var(--bg-primary);
        border-top: 1px solid var(--border-color);
        flex-direction: column-reverse;
        gap: 8px;
    }
    
    .modal-footer .btn {
        width: 100%;
        justify-content: center;
        padding: 14px;
    }
}

/* ============================================
   MOBILE FORMS
   ============================================ */
@media (max-width: 768px) {
    .form-control {
        padding: 14px 16px;
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    .form-row {
        grid-template-columns: 1fr !important;
    }
    
    .form-group {
        margin-bottom: 16px;
    }
    
    .form-label {
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    select.form-control {
        padding-right: 40px;
    }
    
    [dir="rtl"] select.form-control {
        padding-right: 16px;
        padding-left: 40px;
    }
}

/* ============================================
   MOBILE CARDS
   ============================================ */
@media (max-width: 768px) {
    .card {
        border-radius: 12px;
    }
    
    .card-header {
        padding: 12px 14px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .card-header h3 {
        font-size: 15px;
    }
    
    .card-header-actions {
        width: 100%;
        display: flex;
        gap: 8px;
    }
    
    .card-header-actions .btn {
        flex: 1;
        justify-content: center;
        padding: 10px;
        font-size: 13px;
    }
    
    .card-body {
        padding: 14px;
    }
}

/* ============================================
   MOBILE BUTTONS
   ============================================ */
@media (max-width: 768px) {
    .btn {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .btn-sm {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .btn i {
        font-size: 14px;
    }
}

/* ============================================
   MOBILE TABS
   ============================================ */
@media (max-width: 768px) {
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }
    
    .tabs::-webkit-scrollbar {
        display: none;
    }
    
    .tab-btn {
        padding: 10px 14px;
        white-space: nowrap;
        font-size: 12px;
        flex-shrink: 0;
    }
}

/* ============================================
   MOBILE BOTTOM NAVIGATION
   ============================================ */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 6px 0;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        justify-content: space-around;
    }
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 10px;
    transition: color 0.2s;
    cursor: pointer;
    background: none;
    border: none;
    min-width: 64px;
}

.mobile-nav-item i {
    font-size: 18px;
    margin-bottom: 2px;
}

.mobile-nav-item.active,
.mobile-nav-item:hover {
    color: var(--primary);
}

.mobile-nav-item.active i {
    transform: scale(1.1);
}

/* ============================================
   MOBILE DASHBOARD
   ============================================ */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }
    
    .quick-actions-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .quick-action-btn {
        padding: 14px 10px;
        font-size: 12px;
    }
    
    .quick-action-btn i {
        font-size: 20px;
    }
    
    .activity-item {
        padding: 10px;
        font-size: 13px;
    }
}

/* ============================================
   MOBILE SEARCH & FILTERS
   ============================================ */
@media (max-width: 768px) {
    .search-filters {
        flex-direction: column;
        gap: 10px;
    }
    
    .search-box {
        width: 100%;
    }
    
    .filter-group {
        width: 100%;
        display: flex;
        gap: 8px;
    }
    
    .filter-group select {
        flex: 1;
    }
}

/* ============================================
   MOBILE PASSWORD RESET MODAL
   ============================================ */
@media (max-width: 768px) {
    .reset-options {
        gap: 8px;
    }
    
    .reset-option-content {
        padding: 12px;
        gap: 10px;
    }
    
    .reset-option-content i {
        font-size: 18px;
        min-width: 24px;
    }
    
    .reset-option-content strong {
        font-size: 13px;
    }
    
    .reset-option-content small {
        font-size: 10px;
    }
    
    .user-info-box {
        padding: 10px !important;
    }
    
    .user-info-box strong {
        font-size: 14px;
    }
}

/* ============================================
   MOBILE TOAST
   ============================================ */
@media (max-width: 768px) {
    .toast-container {
        left: 12px;
        right: 12px;
        bottom: 70px;
        top: auto;
    }
    
    .toast {
        width: 100%;
        font-size: 13px;
        padding: 12px 14px;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.show-mobile {
    display: none !important;
}

.show-mobile-flex {
    display: none !important;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
    
    .show-mobile-flex {
        display: flex !important;
    }
}

/* ============================================
   RTL MOBILE FIXES
   ============================================ */
@media (max-width: 768px) {
    [dir="rtl"] .modal-footer {
        flex-direction: column-reverse;
    }
    
    [dir="rtl"] .tree-actions {
        justify-content: flex-start;
    }
}

/* ============================================
   PUBLIC HIERARCHY DYNAMIC LOADING
   ============================================ */
.hierarchy-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: rgba(255, 255, 255, 0.6);
}

.hierarchy-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(212, 168, 83, 0.2);
    border-top-color: #d4a853;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.hierarchy-loading p {
    font-size: 14px;
}

.hierarchy-error {
    text-align: center;
    padding: 40px 20px;
    color: #f87171;
}

/* Governing Body Holders */
.gov-card .gov-holders {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(168, 85, 247, 0.3);
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

.gov-card .gov-holders i {
    margin-right: 6px;
    color: #c084fc;
}

[dir="rtl"] .gov-card .gov-holders i {
    margin-right: 0;
    margin-left: 6px;
}

/* ============================================
   MOBILE TREE VIEW - COMPREHENSIVE FIX
   ============================================ */
@media (max-width: 768px) {
    /* Prevent horizontal overflow on entire page */
    .page-content {
        overflow-x: hidden;
    }
    
    /* Tree container - allow horizontal scroll if needed */
    .branch-tree,
    .tree-container {
        overflow-x: auto;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Reduce indentation significantly */
    .tree-children {
        margin-left: 12px !important;
        padding-left: 8px !important;
        border-left-width: 1px !important;
    }
    
    [dir="rtl"] .tree-children {
        margin-left: 0 !important;
        margin-right: 12px !important;
        padding-left: 0 !important;
        padding-right: 8px !important;
        border-left: none !important;
        border-right: 1px solid var(--border-color) !important;
    }
    
    /* Tree node - ensure minimum readable width */
    .tree-node {
        margin-left: 0 !important;
        margin-right: 0 !important;
        min-width: 280px;
        width: 100%;
    }
    
    .tree-node-wrapper {
        width: 100%;
        min-width: 280px;
    }
    
    /* Tree node content - horizontal layout with wrapping */
    .tree-node-content {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
        padding: 10px;
        gap: 8px;
        width: 100%;
        min-width: 260px;
        box-sizing: border-box;
    }
    
    /* First row items stay inline */
    .btn-collapse,
    .collapse-spacer {
        width: 24px;
        height: 24px;
        flex-shrink: 0;
    }
    
    .tree-drag-handle {
        flex-shrink: 0;
        padding: 4px;
    }
    
    /* Tree info - horizontal text, no vertical writing */
    .tree-info {
        flex: 1 1 auto;
        min-width: 150px;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .tree-name {
        font-size: 13px;
        font-weight: 600;
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: normal; /* Don't break mid-word */
        line-height: 1.4;
        width: 100%;
        text-align: start;
    }
    
    .tree-type-badge,
    .type-badge,
    .badge {
        font-size: 9px !important;
        padding: 2px 5px !important;
        white-space: nowrap;
    }
    
    .tree-holder {
        font-size: 11px;
        white-space: nowrap;
    }
    
    .children-count {
        font-size: 10px;
        white-space: nowrap;
    }
    
    /* Actions - new row, horizontal */
    .tree-actions {
        width: 100%;
        flex-basis: 100%;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        padding-top: 8px;
        margin-top: 4px;
        border-top: 1px solid var(--border-color);
        justify-content: flex-start;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .tree-actions .btn {
        padding: 8px 12px;
        font-size: 12px;
        min-width: 40px;
        min-height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .tree-actions .btn i {
        font-size: 14px;
    }
    
    /* Hide text labels in action buttons on mobile */
    .tree-actions .btn span {
        display: none;
    }
    
    /* Drop zones - smaller */
    .tree-drop-zone {
        height: 2px;
        margin: 1px 0;
    }
    
    .top-level-drop-zone {
        padding: 10px;
        font-size: 12px;
    }
    
    /* Branch headers */
    .branch-header {
        padding: 10px;
        font-size: 12px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .branch-header .btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    /* Advisory boards - stack */
    .advisory-board-wrapper {
        margin-left: 12px !important;
        padding-left: 8px !important;
    }
    
    [dir="rtl"] .advisory-board-wrapper {
        margin-left: 0 !important;
        margin-right: 12px !important;
        padding-left: 0 !important;
        padding-right: 8px !important;
    }
    
    .advisory-board-card {
        padding: 8px;
        font-size: 12px;
        min-width: 200px;
    }
    
    /* Governing body */
    .governing-section {
        padding: 10px;
    }
    
    .governing-body-display,
    .governing-body-placeholder {
        padding: 12px;
        min-width: auto !important;
        width: 100%;
    }
    
    .governing-body-display .position-name,
    .governing-body-placeholder span {
        font-size: 13px;
    }
    
    /* Reports-to relationship */
    .reports-to-wrapper {
        font-size: 10px;
        padding: 4px;
    }
    
    .dotted-arrow {
        font-size: 10px;
    }
}

/* Extra small screens (< 400px) - allow scroll */
@media (max-width: 400px) {
    .tree-node,
    .tree-node-wrapper,
    .tree-node-content {
        min-width: 260px;
    }
    
    .tree-children {
        margin-left: 8px !important;
        padding-left: 6px !important;
    }
    
    [dir="rtl"] .tree-children {
        margin-right: 8px !important;
        padding-right: 6px !important;
    }
    
    .tree-node-content {
        padding: 8px;
    }
    
    .tree-name {
        font-size: 12px;
    }
    
    .tree-actions .btn {
        padding: 6px 10px;
        min-width: 36px;
        min-height: 32px;
    }
}

/* ============================================
   Phase 2 - Action Items, Profile, Workflow
   Version: 4.0.0
   ============================================ */

/* Action Items Grid */
.action-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.action-item-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border-light);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.action-item-card:hover {
    border-color: rgba(255,255,255,0.2);
}

.action-item-card.overdue {
    border-color: var(--danger);
    border-left-width: 3px;
}

.action-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.action-item-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.action-item-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.action-item-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.action-item-meta i {
    margin-right: 0.25rem;
}

.action-item-progress {
    margin: 1rem 0;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
}

.progress-bar {
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--info), var(--primary));
    border-radius: 3px;
    transition: width 0.3s ease;
}

.action-item-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
}

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-tab {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.filter-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.filter-tab.active {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

/* Profile Page */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.profile-avatar {
    font-size: 5rem;
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.profile-info {
    text-align: center;
}

.profile-info h2 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* Signature Section */
.signature-preview {
    padding: 2rem;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    text-align: center;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border-light);
}

.signature-image {
    max-width: 100%;
    max-height: 100px;
    object-fit: contain;
}

.no-signature {
    color: var(--text-muted);
}

.no-signature i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    display: block;
}

.signature-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.signature-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.signature-upload-area:hover {
    border-color: var(--primary);
    background: rgba(255,255,255,0.02);
}

.upload-placeholder {
    color: var(--text-muted);
}

.upload-placeholder i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
    color: var(--primary);
}

.upload-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.upload-preview img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 4px;
}

/* Memberships */
.memberships-grid {
    display: grid;
    gap: 0.75rem;
}

.membership-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    transition: background 0.2s;
}

.membership-item:hover {
    background: var(--bg-hover);
}

.membership-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    border-radius: 50%;
    color: var(--text-inverse);
    flex-shrink: 0;
}

.membership-name {
    font-weight: 500;
    color: var(--text-primary);
}

.membership-meta {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

/* OTP Input */
.otp-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.otp-input-group input {
    font-size: 1.25rem;
    letter-spacing: 0.5rem;
    text-align: center;
    font-family: monospace;
}

.otp-input-group .btn {
    white-space: nowrap;
}

/* Form Rows */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* RTL Input */
.form-control.rtl {
    direction: rtl;
    text-align: right;
}

/* Phase 2 Responsive */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .action-items-grid {
        grid-template-columns: 1fr;
    }
    
    .profile-grid {
        grid-template-columns: 1fr;
    }
    
    .otp-input-group {
        flex-direction: column;
    }
    
    .filter-tabs {
        justify-content: center;
    }
}

/* ============================================
   Acknowledgments Page
   ============================================ */

.acknowledgments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.acknowledgment-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1.25rem;
    border: 1px solid var(--border-light);
    transition: border-color 0.2s;
}

.acknowledgment-card:hover {
    border-color: rgba(255,255,255,0.2);
}

.acknowledgment-card.acknowledged {
    opacity: 0.8;
    border-color: var(--success);
}

.acknowledgment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.acknowledgment-card .meeting-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    color: var(--text-primary);
}

.acknowledgment-card .meeting-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.acknowledgment-card .meeting-meta i {
    margin-right: 0.25rem;
}

.distributed-info,
.acknowledged-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 0.5rem 0;
    border-top: 1px solid var(--border-light);
    margin-top: 0.75rem;
}

.acknowledged-info {
    color: var(--success);
}

.acknowledgment-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
}

/* Checkbox Label */
.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
    margin-top: 0.25rem;
    width: 18px;
    height: 18px;
}

/* Entity Members */
.entity-members-card .table-responsive {
    margin-top: 1rem;
}

@media (max-width: 768px) {
    .acknowledgments-grid {
        grid-template-columns: 1fr;
    }
    
    .acknowledgment-card .meeting-meta {
        flex-direction: column;
        gap: 0.25rem;
    }
}

/* ============================================
   Profile Page Styles
   ============================================ */

.profile-container {
    max-width: 900px;
    margin: 0 auto;
}

.profile-header-card {
    margin-bottom: 1.5rem;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
}

.profile-avatar-large {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--gold));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--bg-primary);
    flex-shrink: 0;
}

.profile-avatar-large img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.profile-avatar-large span {
    color: var(--bg-primary);
}

.avatar-edit-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gold);
    border: 2px solid var(--bg-card);
    color: var(--bg-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.avatar-edit-btn:hover {
    transform: scale(1.1);
}

.profile-header-info {
    flex: 1;
}

.profile-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.profile-email {
    color: var(--text-secondary);
    margin: 0 0 0.75rem 0;
    font-size: 0.95rem;
}

.profile-email i {
    margin-right: 0.5rem;
    color: var(--gold);
}

.profile-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.profile-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.profile-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

.profile-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.profile-info-item label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-info-item span {
    font-size: 1rem;
    color: var(--text-primary);
}

.security-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.security-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.security-option-info h4 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.security-option-info h4 i {
    margin-right: 0.5rem;
    color: var(--gold);
}

.security-option-info p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.positions-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.position-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-light);
}

.position-item i {
    color: var(--gold);
}

.position-item span:not(.badge) {
    flex: 1;
}

/* User Modal Styles */
.user-modal-content {
    padding: 0.5rem 0;
}

.user-modal-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 1rem;
}

.user-avatar-large {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--gold));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--bg-primary);
    flex-shrink: 0;
}

.user-avatar-large img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.user-modal-info h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.1rem;
}

.user-modal-info p {
    margin: 0 0 0.5rem 0;
    font-size: 0.85rem;
}

.user-modal-menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-primary);
    font-size: 0.95rem;
    text-align: left;
    width: 100%;
}

[dir="rtl"] .user-menu-item {
    text-align: right;
}

.user-menu-item:hover {
    background: var(--bg-primary);
}

.user-menu-item i:first-child {
    width: 20px;
    color: var(--gold);
}

.user-menu-item span {
    flex: 1;
}

.user-menu-item i:last-child {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .profile-badges {
        justify-content: center;
    }
    
    .profile-info-grid {
        grid-template-columns: 1fr;
    }
    
    .security-option {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
}
