/**
 * AlBND Enhanced User Management Styles
 * PKG-02: Complete User CRUD with DataTables
 * Version: 2.0.0
 * 
 * Based on RCJY Brand Guidelines
 */

/* ============================================
   RCJY Brand Color Variables
   ============================================ */
:root {
    /* RCJY Primary Colors */
    --rcjy-navy: #052976;
    --rcjy-navy-light: #0a3d9c;
    --rcjy-cyan: var(--primary);
    --rcjy-cyan-light: #7ad4ff;
    --rcjy-green: var(--success);
    --rcjy-green-light: #4dd98f;
    --rcjy-purple: #814FFF;
    --rcjy-purple-light: #a080ff;
    
    /* RCJY Gradients */
    --rcjy-gradient-main: linear-gradient(135deg, var(--rcjy-purple), var(--rcjy-cyan), var(--rcjy-green));
    --rcjy-gradient-navy: linear-gradient(135deg, var(--rcjy-navy), var(--rcjy-purple));
    --rcjy-gradient-accent: linear-gradient(90deg, var(--rcjy-cyan), var(--rcjy-green));
    
    /* RGB values for alpha */
    --rcjy-purple-rgb: 129, 79, 255;
    --rcjy-cyan-rgb: 76, 196, 255;
    --rcjy-green-rgb: 32, 204, 118;
    --rcjy-navy-rgb: 5, 41, 118;
    
    /* User Management Specific */
    --users-card-bg: var(--bg-card);
    --users-hover-bg: rgba(var(--rcjy-purple-rgb), 0.08);
    --users-selected-bg: rgba(var(--rcjy-purple-rgb), 0.15);
    --users-border: var(--border-color);
}

/* ============================================
   Statistics Dashboard
   ============================================ */
.users-stats-dashboard {
    margin-bottom: 1.5rem;
}

.stats-row {
    display: grid;
    grid-template-columns: 280px 1fr 1fr;
    gap: 1.5rem;
}

/* Stat Card Base */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
}

.stat-card:hover {
    border-color: rgba(var(--rcjy-purple-rgb), 0.3);
    box-shadow: 0 8px 25px rgba(var(--rcjy-purple-rgb), 0.15);
    transform: translateY(-2px);
}

.stat-card h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-card h4 i {
    color: var(--rcjy-purple);
}

/* Total Users Card - Ring Chart */
.stat-total {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.stat-visual {
    flex-shrink: 0;
}

.stat-ring {
    position: relative;
    width: 90px;
    height: 90px;
}

.stat-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.stat-ring .ring-bg {
    fill: none;
    stroke: var(--bg-tertiary);
    stroke-width: 3;
}

.stat-ring .ring-fill {
    fill: none;
    /* stroke is set via inline SVG with gradient */
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dasharray 0.8s ease;
}

/* SVG gradient definition (added via JS if needed) */
.stat-ring svg defs {
    position: absolute;
}

.ring-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-content h4 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.stat-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.active-dot,
.inactive-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.active-dot {
    background: var(--rcjy-green);
}

.inactive-dot {
    background: var(--text-muted);
}

/* Role Bars Card */
.stat-roles {
    padding: 1rem 1.25rem;
}

.role-bars {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.role-bar {
    display: grid;
    grid-template-columns: 100px 1fr 40px;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.375rem;
    border-radius: var(--border-radius);
    transition: background var(--transition-fast);
}

.role-bar:hover {
    background: var(--bg-hover);
}

.role-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-track {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.bar-fill.master {
    background: linear-gradient(90deg, var(--rcjy-purple), var(--rcjy-purple-light));
}

.bar-fill.admin {
    background: linear-gradient(90deg, var(--rcjy-cyan), var(--rcjy-cyan-light));
}

.bar-fill.manager {
    background: linear-gradient(90deg, var(--rcjy-green), var(--rcjy-green-light));
}

.bar-fill.member {
    background: linear-gradient(90deg, var(--rcjy-navy), var(--rcjy-navy-light));
}

.role-count {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
}

/* Activity Card */
.stat-activity {
    padding: 1rem 1.25rem;
}

.activity-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.activity-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    border-radius: var(--border-radius);
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.activity-item:hover {
    transform: translateY(-2px);
}

.activity-item i {
    font-size: 1.25rem;
    margin-bottom: 0.375rem;
}

.activity-item .count {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.activity-item .label {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    margin-top: 0.125rem;
}

.activity-item.success {
    border: 1px solid rgba(var(--rcjy-green-rgb), 0.2);
}
.activity-item.success:hover {
    background: rgba(var(--rcjy-green-rgb), 0.1);
}
.activity-item.success i {
    color: var(--rcjy-green);
}

.activity-item.warning {
    border: 1px solid rgba(245, 158, 11, 0.2);
}
.activity-item.warning:hover {
    background: rgba(245, 158, 11, 0.1);
}
.activity-item.warning i {
    color: var(--warning);
}

.activity-item.info {
    border: 1px solid rgba(var(--rcjy-cyan-rgb), 0.2);
}
.activity-item.info:hover {
    background: rgba(var(--rcjy-cyan-rgb), 0.1);
}
.activity-item.info i {
    color: var(--rcjy-cyan);
}

.activity-item.danger {
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.activity-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}
.activity-item.danger i {
    color: var(--danger);
}

/* ============================================
   Toolbar
   ============================================ */
.users-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    gap: 1rem;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Search Box */
.search-box {
    position: relative;
    width: 280px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

[dir="rtl"] .search-box i {
    left: auto;
    right: 12px;
}

.search-box input {
    width: 100%;
    padding: 0.625rem 2.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--rcjy-purple);
    box-shadow: 0 0 0 3px rgba(var(--rcjy-purple-rgb), 0.15);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.clear-search {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

[dir="rtl"] .clear-search {
    right: auto;
    left: 8px;
}

.clear-search:hover {
    background: var(--danger-light);
    color: var(--danger);
}

/* Filter Group */
.filter-group {
    display: flex;
    gap: 0.5rem;
}

.filter-group select {
    padding: 0.625rem 2rem 0.625rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.8125rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%239ca3af'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 18px;
    min-width: 130px;
    transition: all var(--transition-fast);
}

[dir="rtl"] .filter-group select {
    padding: 0.625rem 0.75rem 0.625rem 2rem;
    background-position: left 8px center;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--rcjy-purple);
}

.filter-group select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Button Group */
.btn-group {
    display: flex;
    gap: 0.5rem;
}

/* Ghost Button */
.btn-ghost {
    padding: 0.625rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--rcjy-purple);
    border-color: var(--rcjy-purple);
}

/* ============================================
   Bulk Actions Bar
   ============================================ */
.bulk-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(var(--rcjy-purple-rgb), 0.15), rgba(var(--rcjy-cyan-rgb), 0.1));
    border: 1px solid rgba(var(--rcjy-purple-rgb), 0.3);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    animation: slideDown 0.3s ease;
}

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

.bulk-actions-bar.hidden {
    display: none;
}

.bulk-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.selection-count {
    font-weight: 600;
    color: var(--text-primary);
}

.selection-count span {
    color: var(--rcjy-purple);
}

.btn-text {
    background: none;
    border: none;
    color: var(--rcjy-cyan);
    cursor: pointer;
    font-size: 0.8125rem;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.btn-text:hover {
    color: var(--rcjy-cyan-light);
}

.bulk-actions {
    display: flex;
    gap: 0.5rem;
}

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

.users-table-card .card-body {
    padding: 0;
}

/* DataTables Overrides */
#users-datatable {
    width: 100% !important;
    border-collapse: collapse;
}

#users-datatable thead {
    background: var(--bg-tertiary);
}

#users-datatable thead th {
    padding: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

#users-datatable tbody tr {
    transition: background var(--transition-fast);
}

#users-datatable tbody tr:hover {
    background: var(--users-hover-bg);
}

#users-datatable tbody tr.selected {
    background: var(--users-selected-bg);
}

#users-datatable tbody td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

/* Column Widths */
.col-checkbox {
    width: 48px;
    text-align: center;
}

.col-user {
    min-width: 220px;
}

.col-email {
    min-width: 200px;
}

.col-positions {
    min-width: 180px;
}

.col-role {
    width: 130px;
}

.col-status {
    width: 100px;
}

.col-activity {
    width: 140px;
}

.col-actions {
    width: 120px;
}

/* Checkbox Styling */
#users-datatable input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--rcjy-purple);
    cursor: pointer;
}

/* User Cell */
.user-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: white;
    background: var(--avatar-color, var(--rcjy-purple));
    flex-shrink: 0;
}

.user-avatar.has-image {
    background: transparent;
}

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

.status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
}

.status-dot.active {
    background: var(--rcjy-green);
}

.status-dot.inactive {
    background: var(--text-muted);
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

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

.user-name-ar {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    direction: rtl;
}

.user-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Email Cell */
.email-link {
    color: var(--rcjy-cyan);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color var(--transition-fast);
}

.email-link:hover {
    color: var(--rcjy-cyan-light);
    text-decoration: underline;
}

.phone-info {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.phone-info i {
    margin-right: 4px;
}

[dir="rtl"] .phone-info i {
    margin-right: 0;
    margin-left: 4px;
}

/* Position Badges */
.position-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.position-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.position-badge.primary {
    background: rgba(var(--rcjy-purple-rgb), 0.15);
    color: var(--rcjy-purple-light);
}

.position-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    font-size: 0.6875rem;
    color: var(--text-secondary);
}

.no-position {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Role Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-purple {
    background: rgba(var(--rcjy-purple-rgb), 0.15);
    color: var(--rcjy-purple-light);
}

.badge-cyan {
    background: rgba(var(--rcjy-cyan-rgb), 0.15);
    color: var(--rcjy-cyan);
}

.badge-green {
    background: rgba(var(--rcjy-green-rgb), 0.15);
    color: var(--rcjy-green);
}

.badge-navy {
    background: rgba(var(--rcjy-navy-rgb), 0.15);
    color: #6b9fff;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

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

/* Status Toggle Button */
.status-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.status-toggle.active {
    background: rgba(var(--rcjy-green-rgb), 0.15);
    color: var(--rcjy-green);
}

.status-toggle.inactive {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.status-toggle:hover {
    transform: scale(1.05);
}

.status-toggle i {
    font-size: 0.625rem;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.status-toggle:hover i {
    opacity: 1;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.375rem;
    justify-content: flex-end;
}

.btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--rcjy-cyan);
    border-color: var(--border-light);
}

.btn-icon:active {
    transform: scale(0.95);
}

/* Empty State */
.empty-row td {
    padding: 4rem 2rem !important;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}

.empty-state p {
    font-size: 0.9375rem;
}

/* ============================================
   DataTables Custom Pagination
   ============================================ */
.dataTables_wrapper {
    padding: 0;
}

/* DataTables Dark Theme Override */
table.dataTable {
    border-collapse: collapse !important;
}

table.dataTable thead th,
table.dataTable thead td {
    border-bottom: 1px solid var(--border-color) !important;
}

table.dataTable.no-footer {
    border-bottom: none !important;
}

table.dataTable tbody tr {
    background: transparent !important;
}

table.dataTable tbody tr:hover {
    background: var(--users-hover-bg) !important;
}

table.dataTable tbody tr.selected {
    background: var(--users-selected-bg) !important;
}

table.dataTable.stripe tbody tr.odd {
    background: rgba(255, 255, 255, 0.02) !important;
}

table.dataTable.stripe tbody tr.odd:hover {
    background: var(--users-hover-bg) !important;
}

.dataTables_wrapper .dataTables_filter {
    display: none; /* We use our custom search */
}

.dataTables_info {
    color: var(--text-secondary) !important;
    font-size: 0.8125rem;
    padding: 1rem !important;
}

.dataTables_length {
    padding: 1rem;
}

.dataTables_length select {
    padding: 0.375rem 2rem 0.375rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    margin: 0 0.5rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%239ca3af'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
    background-size: 16px;
}

.dataTables_paginate {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.25rem;
    padding: 1rem;
}

.dataTables_paginate .paginate_button {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.8125rem;
}

.dataTables_paginate .paginate_button:hover:not(.disabled):not(.current) {
    background: var(--bg-hover);
    color: var(--rcjy-purple);
    border-color: var(--rcjy-purple);
}

.dataTables_paginate .paginate_button.current {
    background: var(--rcjy-purple);
    border-color: var(--rcjy-purple);
    color: white;
}

.dataTables_paginate .paginate_button.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================
   User Form Modals
   ============================================ */
.user-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-section {
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: 1.25rem;
}

.form-section h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-section h4 i {
    color: var(--rcjy-purple);
    font-size: 0.875rem;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

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

.form-grid .span-2 {
    grid-column: span 2;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

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

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.625rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--rcjy-purple);
    box-shadow: 0 0 0 3px rgba(var(--rcjy-purple-rgb), 0.15);
}

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

.form-group input.rtl {
    text-align: right;
    direction: rtl;
}

/* Input with Icon */
.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.875rem;
}

[dir="rtl"] .input-with-icon i {
    left: auto;
    right: 12px;
}

.input-with-icon input {
    padding-left: 2.5rem;
}

[dir="rtl"] .input-with-icon input {
    padding-left: 0.75rem;
    padding-right: 2.5rem;
}

/* Bilingual Group */
.bilingual-group {
    position: relative;
}

.btn-translate {
    position: absolute;
    right: 0;
    top: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--rcjy-cyan);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.btn-translate:hover {
    background: rgba(var(--rcjy-cyan-rgb), 0.15);
}

/* Avatar Upload */
.avatar-section {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

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

.avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    border: 3px solid var(--border-color);
    overflow: hidden;
    transition: border-color var(--transition-fast);
}

.avatar-preview:hover {
    border-color: var(--rcjy-purple);
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-upload input[type="file"] {
    display: none;
}

.avatar-actions {
    display: flex;
    gap: 0.5rem;
}

/* Password Input */
.password-input {
    position: relative;
}

.password-input input {
    padding-right: 2.5rem;
    width: 100%;
}

[dir="rtl"] .password-input input {
    padding-right: 0.75rem;
    padding-left: 2.5rem;
}

.toggle-password {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition-fast);
}

[dir="rtl"] .toggle-password {
    right: auto;
    left: 8px;
}

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

/* Password Strength */
.password-strength {
    margin-top: 0.5rem;
}

.strength-bar {
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.strength-fill {
    height: 100%;
    transition: width 0.3s ease, background 0.3s ease;
}

.strength-fill.weak { width: 20%; background: var(--danger); }
.strength-fill.fair { width: 40%; background: var(--warning); }
.strength-fill.good { width: 60%; background: var(--warning); }
.strength-fill.strong { width: 80%; background: var(--rcjy-cyan); }
.strength-fill.excellent { width: 100%; background: var(--rcjy-green); }

.strength-text {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h4 {
    margin-bottom: 0;
}

/* Positions Container */
#positions-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.empty-positions {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
}

.position-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.position-row select {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.position-row .btn-icon {
    color: var(--danger);
}

.position-row .btn-icon:hover {
    background: var(--danger-light);
}

/* Options Section */
.options-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--rcjy-purple);
}

/* ============================================
   View User Modal
   ============================================ */
.user-profile {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(var(--rcjy-purple-rgb), 0.1), rgba(var(--rcjy-cyan-rgb), 0.05));
    border-radius: var(--border-radius-lg);
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--rcjy-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

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

.profile-info h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.profile-info .name-ar {
    font-size: 1rem;
    color: var(--text-secondary);
    direction: rtl;
    margin-bottom: 0.5rem;
}

.profile-info .profile-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.profile-meta span {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.profile-meta span i {
    margin-right: 0.375rem;
}

[dir="rtl"] .profile-meta span i {
    margin-right: 0;
    margin-left: 0.375rem;
}

/* Profile Section */
.profile-section {
    padding: 1.25rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
}

.profile-section h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.profile-section h4 i {
    color: var(--rcjy-purple);
}

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

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

.detail-item label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.detail-item span {
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.detail-item span a {
    color: var(--rcjy-cyan);
    text-decoration: none;
}

.detail-item span a:hover {
    text-decoration: underline;
}

/* Positions List */
.positions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.position-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--rcjy-purple-rgb), 0.15);
    border-radius: var(--border-radius);
    color: var(--rcjy-purple);
}

.position-details {
    flex: 1;
}

.position-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.position-path {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Activity Timeline */
.activity-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.timeline-item {
    display: flex;
    gap: 1rem;
    position: relative;
    padding-bottom: 1.25rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 32px;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

[dir="rtl"] .timeline-item::before {
    left: auto;
    right: 15px;
}

.timeline-item:last-child::before {
    display: none;
}

.timeline-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 50%;
    color: var(--text-muted);
    flex-shrink: 0;
    z-index: 1;
}

.timeline-item.login .timeline-icon {
    background: rgba(var(--rcjy-green-rgb), 0.15);
    color: var(--rcjy-green);
}

.timeline-item.update .timeline-icon {
    background: rgba(var(--rcjy-cyan-rgb), 0.15);
    color: var(--rcjy-cyan);
}

.timeline-item.create .timeline-icon {
    background: rgba(var(--rcjy-purple-rgb), 0.15);
    color: var(--rcjy-purple);
}

.timeline-content {
    flex: 1;
    padding-top: 4px;
}

.timeline-title {
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
}

.timeline-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   Password Reset Modal
   ============================================ */
.reset-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.reset-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.reset-option:hover {
    border-color: var(--rcjy-purple);
}

.reset-option.active {
    border-color: var(--rcjy-purple);
    background: rgba(var(--rcjy-purple-rgb), 0.1);
}

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

.reset-option .option-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    color: var(--rcjy-purple);
}

.reset-option .option-text {
    flex: 1;
}

.reset-option .option-text h5 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
}

.reset-option .option-text p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.generated-password {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(var(--rcjy-green-rgb), 0.1);
    border: 1px solid rgba(var(--rcjy-green-rgb), 0.3);
    border-radius: var(--border-radius);
}

.generated-password code {
    flex: 1;
    font-family: 'Fira Code', monospace;
    font-size: 1.125rem;
    color: var(--rcjy-green);
    letter-spacing: 0.1em;
}

.generated-password button {
    padding: 0.5rem 0.75rem;
    background: var(--rcjy-green);
    border: none;
    border-radius: var(--border-radius);
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.generated-password button:hover {
    background: var(--rcjy-green-light);
}

/* ============================================
   More Actions Dropdown
   ============================================ */
.actions-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    overflow: hidden;
    animation: fadeIn 0.15s ease;
}

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

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

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

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

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

.dropdown-item.danger {
    color: var(--danger);
}

.dropdown-item.danger:hover {
    background: var(--danger-light);
}

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

/* ============================================
   Responsive Styles
   ============================================ */
@media (max-width: 1200px) {
    .stats-row {
        grid-template-columns: 1fr 1fr;
    }
    
    .stat-total {
        grid-column: span 2;
        justify-content: center;
    }
}

@media (max-width: 992px) {
    .stats-row {
        grid-template-columns: 1fr;
    }
    
    .stat-total {
        grid-column: span 1;
    }
    
    .users-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar-left,
    .toolbar-right {
        width: 100%;
        justify-content: flex-start;
    }
    
    .search-box {
        width: 100%;
    }
    
    .filter-group {
        flex-wrap: wrap;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-grid .span-2 {
        grid-column: span 1;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .bulk-actions-bar {
        flex-direction: column;
        gap: 1rem;
    }
    
    .bulk-info,
    .bulk-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    #users-datatable thead th,
    #users-datatable tbody td {
        padding: 0.75rem 0.5rem;
    }
    
    .col-positions,
    .col-activity {
        display: none;
    }
    
    .user-cell {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .action-buttons {
        flex-wrap: wrap;
    }
    
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .profile-info .profile-meta {
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .activity-grid {
        grid-template-columns: 1fr;
    }
    
    .toolbar-right {
        flex-direction: column;
    }
    
    .btn-group {
        width: 100%;
    }
    
    .btn-group .btn {
        flex: 1;
    }
    
    .col-email,
    .col-role {
        display: none;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .users-stats-dashboard,
    .users-toolbar,
    .bulk-actions-bar,
    .col-checkbox,
    .col-actions,
    .dataTables_length,
    .dataTables_paginate {
        display: none !important;
    }
    
    .users-table-card {
        border: 1px solid #ddd;
    }
    
    #users-datatable tbody tr {
        page-break-inside: avoid;
    }
}

/* ============================================
   Animations
   ============================================ */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

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

/* Tooltip Styles (for tippy.js or custom) */
[data-tippy-content] {
    cursor: help;
}

/* Focus Visible States */
:focus-visible {
    outline: 2px solid var(--rcjy-purple);
    outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--rcjy-purple);
    outline-offset: 2px;
}

/* ============================================
   Reset Password Modal Styles
   ============================================ */
.reset-password-options {
    padding: 0;
}

.reset-password-options > p {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.radio-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.radio-option:hover {
    background: rgba(var(--rcjy-purple-rgb), 0.1);
    border-color: var(--rcjy-purple);
}

.radio-option input[type="radio"] {
    margin-top: 3px;
    flex-shrink: 0;
}

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

.radio-option .option-content > i {
    display: none;
}

.radio-option .option-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.radio-option .option-title::before {
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
}

.radio-option:nth-child(1) .option-title::before {
    content: "\f074"; /* fa-random */
    color: var(--primary);
}

.radio-option:nth-child(2) .option-title::before {
    content: "\f11c"; /* fa-keyboard */
    color: var(--warning);
}

.radio-option:nth-child(3) .option-title::before {
    content: "\f0e0"; /* fa-envelope */
    color: var(--info);
}

.radio-option .option-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: block;
}

#set-password-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Generated Password Display */
.generated-password-display {
    text-align: center;
    padding: 1rem;
}

.generated-password-display .password-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 1rem 0;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 2px dashed var(--primary);
    border-radius: 8px;
}

.generated-password-display code {
    font-size: 1.3rem;
    color: var(--accent-gold);
    letter-spacing: 2px;
}

.generated-password-display .warning {
    color: var(--warning);
    font-size: 0.9rem;
    margin-top: 1rem;
}
