/* ==========================================================================
   HALELI / LIBOCARD - MODERN FINTECH SYSTEM CSS
   Includes 3 Themes matching the 3 Logos:
   1. Light Mode (Pure White & Deep Purple Accent)
   2. Purple Mode (Vibrant Purple Background & Glassmorphic White Accent)
   3. Dark Mode (Onyx Charcoal & Neon Purple Accent)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Outfit:wght@500;600;700;800&display=swap');

/* --- RTL ARABIC TYPOGRAPHY OVERRIDE --- */
[dir="rtl"], [dir="rtl"] body, [dir="rtl"] input, [dir="rtl"] button, [dir="rtl"] select, [dir="rtl"] textarea, [dir="rtl"] label {
  font-family: 'Cairo', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif !important;
}

/* --- THEME VARIABLES --- */
:root {
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --transition-speed: 0.3s;
  --border-radius-sm: 8px;
  --border-radius-md: 14px;
  --border-radius-lg: 20px;
  --border-radius-xl: 28px;
}

/* 1. LIGHT MODE (Pure White & Purple accents) */
[data-theme="light"] {
  --bg-app: #f4f5f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-header: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f1f5f9;

  --border-color: #e2e8f0;
  --border-focus: #7c3aed;
  --border-subtle: rgba(0, 0, 0, 0.06);

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-heading: #1e1b4b;

  --brand-purple: #5b1480;
  --brand-purple-light: #7c3aed;
  --brand-purple-glow: rgba(91, 20, 128, 0.15);
  --brand-purple-subtle: #f3e8ff;

  --logo-text: #5b1480;
  --logo-badge-bg: #5b1480;
  --logo-badge-icon: #ffffff;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 8px 24px rgba(91, 20, 128, 0.06);
  --shadow-lg: 0 16px 40px rgba(91, 20, 128, 0.12);
  --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.25);

  --card-gradient: linear-gradient(135deg, #5b1480 0%, #7c3aed 100%);
  --badge-bg: #f1f5f9;
  --badge-text: #475569;
  --table-header-bg: #f8fafc;
  --modal-overlay: rgba(15, 23, 42, 0.5);
}

/* 2. VIBRANT PURPLE MODE (Signature Purple - High Contrast) */
[data-theme="purple"] {
  --bg-app: #380752;
  --bg-app-gradient: linear-gradient(135deg, #240438 0%, #4c0a6e 50%, #380752 100%);
  --bg-surface: rgba(255, 255, 255, 0.14);
  --bg-surface-elevated: rgba(255, 255, 255, 0.20);
  --bg-header: rgba(36, 4, 56, 0.95);
  --bg-sidebar: rgba(28, 3, 44, 0.95);
  --bg-card: rgba(255, 255, 255, 0.14);
  --bg-card-hover: rgba(255, 255, 255, 0.22);
  --bg-input: rgba(255, 255, 255, 0.18);

  --border-color: rgba(255, 255, 255, 0.32);
  --border-focus: #f3e8ff;
  --border-subtle: rgba(255, 255, 255, 0.22);

  --text-main: #ffffff;
  --text-muted: #f3e8ff;
  --text-light: #e9d5ff;
  --text-heading: #ffffff;

  --brand-purple: #c084fc;
  --brand-purple-light: #f3e8ff;
  --brand-purple-glow: rgba(243, 232, 255, 0.45);
  --brand-purple-subtle: rgba(255, 255, 255, 0.20);

  --logo-text: #ffffff;
  --logo-badge-bg: #ffffff;
  --logo-badge-icon: #4c0a6e;

  --shadow-sm: 0 4px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(243, 232, 255, 0.4);

  --card-gradient: linear-gradient(135deg, #7e22ce 0%, #a855f7 50%, #c084fc 100%);
  --badge-bg: rgba(255, 255, 255, 0.20);
  --badge-text: #ffffff;
  --table-header-bg: rgba(0, 0, 0, 0.3);
  --modal-overlay: rgba(20, 2, 32, 0.85);
}

/* 3. ONYX DARK MODE (Charcoal Dark & Neon Purple) */
[data-theme="dark"] {
  --bg-app: #121316;
  --bg-surface: #18191e;
  --bg-surface-elevated: #22242b;
  --bg-header: rgba(18, 19, 22, 0.95);
  --bg-sidebar: #15161a;
  --bg-card: #1c1d24;
  --bg-card-hover: #262832;
  --bg-input: #23252f;

  --border-color: #2e303d;
  --border-focus: #a855f7;
  --border-subtle: rgba(168, 85, 247, 0.15);

  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-light: #71717a;
  --text-heading: #ffffff;

  --brand-purple: #9333ea;
  --brand-purple-light: #c084fc;
  --brand-purple-glow: rgba(168, 85, 247, 0.3);
  --brand-purple-subtle: rgba(147, 51, 234, 0.15);

  --logo-text: #c084fc;
  --logo-badge-bg: #27272a;
  --logo-badge-icon: #a855f7;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 20px 45px rgba(0, 0, 0, 0.8);
  --shadow-glow: 0 0 22px rgba(168, 85, 247, 0.35);

  --card-gradient: linear-gradient(135deg, #27103b 0%, #581c87 100%);
  --badge-bg: #27272a;
  --badge-text: #d4d4d8;
  --table-header-bg: #15161a;
  --modal-overlay: rgba(0, 0, 0, 0.8);
}

/* --- BASE STYLES --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  background-image: var(--bg-app-gradient, none);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color var(--transition-speed), color var(--transition-speed);
  overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  color: var(--text-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* --- GLOBAL ICON SPACING FOR HEADINGS (LTR & RTL) --- */
.glass-card h4,
.modal-title,
.card-header h4,
.section-title h4,
.kyc-details-container h4 {
  display: flex !important;
  align-items: center !important;
  gap: 0.65rem !important;
}

[dir="rtl"] .glass-card h4 i,
[dir="rtl"] .modal-title i,
[dir="rtl"] .card-header i,
[dir="rtl"] .section-title i,
[dir="rtl"] .kyc-details-container h4 i {
  margin-left: 0.65rem !important;
  margin-right: 0 !important;
}

[dir="ltr"] .glass-card h4 i,
[dir="ltr"] .modal-title i,
[dir="ltr"] .card-header i,
[dir="ltr"] .section-title i,
[dir="ltr"] .kyc-details-container h4 i {
  margin-right: 0.65rem !important;
  margin-left: 0 !important;
}

a {
  color: var(--brand-purple-light);
  text-decoration: none;
  transition: color var(--transition-speed);
}

button {
  font-family: var(--font-main);
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
}

/* --- LOGIN PAGE SPECIAL STYLES --- */
.login-page-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-xl);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  position: relative;
  z-index: 10;
  transition: all var(--transition-speed);
}

.login-card:hover {
  box-shadow: var(--shadow-glow);
}

.login-header-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.login-logo-badge {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: var(--logo-badge-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.login-logo-badge svg {
  width: 36px;
  height: 36px;
  fill: var(--logo-badge-icon);
}

.login-brand-title {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--logo-text);
  letter-spacing: -0.03em;
}

.login-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: -6px;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.contained-input-group {
  display: flex;
  align-items: center;
  width: 100%;
  position: relative;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  transition: all 0.25s ease;
  min-height: 52px;
}

.contained-input-group:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-purple-glow);
}

.contained-input-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  color: var(--text-light);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.contained-input-field {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  padding: 14px 16px 14px 10px;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  color: var(--text-main) !important;
  font-size: 1rem;
  font-weight: 400;
}

[dir="rtl"] .contained-input-field {
  padding: 14px 10px 14px 16px;
  font-weight: 500;
}

.contained-input-field::placeholder {
  font-size: 0.98rem;
  font-weight: 400;
  opacity: 0.78;
}

.contained-input-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  align-self: stretch;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  border-inline-start: 1px solid var(--border-color);
  color: var(--text-light);
  font-size: 1.05rem;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.contained-input-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: var(--text-main);
}

.login-input-wrapper {
  position: relative;
}

.login-input-wrapper i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}

.login-input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  border-radius: var(--border-radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.95rem;
  transition: all 0.25s ease;
}

.login-input:focus {
  border-color: var(--border-focus);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-purple-glow);
}

.btn-login-submit {
  width: 100%;
  padding: 14px;
  border-radius: 30px;
  background: var(--brand-purple);
  color: #ffffff;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: var(--shadow-md);
  transition: all 0.25s ease;
  margin-top: 10px;
}

.btn-login-submit:hover {
  background: var(--brand-purple-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

/* --- THEME SWITCHER WIDGET --- */
.theme-selector-pill {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  padding: 4px;
  border-radius: 30px;
  border: 1px solid var(--border-color);
  gap: 4px;
}

.theme-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.25s ease;
}

.theme-btn i {
  font-size: 0.95rem;
}

.theme-btn:hover {
  color: var(--text-main);
}

.theme-btn.active {
  background: var(--brand-purple);
  color: #ffffff !important;
  box-shadow: var(--shadow-sm);
}

/* APP CONTAINER */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.app-sidebar {
  width: 270px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--transition-speed);
  backdrop-filter: blur(12px);
}

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

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

.logo-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--logo-badge-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.logo-badge svg {
  width: 26px;
  height: 26px;
  fill: var(--logo-badge-icon);
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--logo-text);
  letter-spacing: -0.03em;
}

.sidebar-nav {
  padding: 20px 16px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  font-weight: 700;
  padding: 12px 12px 6px 12px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  border-radius: var(--border-radius-md);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.93rem;
  transition: all 0.2s ease;
  position: relative;
}

.nav-item i {
  font-size: 1.15rem;
  width: 22px;
  text-align: center;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  transform: translateX(3px);
}

.nav-item.active {
  background: var(--brand-purple-subtle);
  color: var(--brand-purple-light);
  font-weight: 700;
}

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

.user-card-sm {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--border-radius-md);
  background: var(--bg-card-hover);
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--brand-purple-light);
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

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

.app-main {
  flex: 1;
  margin-left: 270px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-header {
  height: 74px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(12px);
}

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

.toggle-sidebar-btn {
  display: none;
  font-size: 1.25rem;
  color: var(--text-main);
  padding: 8px;
  border-radius: 8px;
  background: var(--bg-card-hover);
}

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

.header-search i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}

.header-search input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border-radius: 30px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.88rem;
}

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

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  background: #ef4444;
  border-radius: 50%;
}

.page-content {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
}

.page-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-primary {
  background: var(--brand-purple);
  color: #ffffff;
  padding: 10px 22px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 20px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toggle-btn,
.toggle-btn:hover,
.toggle-btn:focus {
  background-color: #64748b !important;
  border-color: #64748b !important;
  color: #ffffff !important;
}

.toggle-btn i {
  color: #ffffff !important;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 28px;
}

.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.hero-card-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-md);
}

.virtual-card {
  width: 100%;
  height: 220px;
  background: var(--card-gradient);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.25);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.35s ease;
}

.virtual-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 20px 30px -10px rgba(111, 66, 193, 0.35);
}

.treasury-card {
  width: 100%;
  min-height: 220px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(15, 23, 42, 0.85) 60%, rgba(99, 102, 241, 0.15) 100%);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 12px 28px -8px rgba(16, 185, 129, 0.15);
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.treasury-card:hover {
  transform: translateY(-2px);
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 16px 32px -8px rgba(16, 185, 129, 0.25);
}

.treasury-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 20px;
  color: #10b981;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.treasury-stream-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.treasury-stream-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.treasury-stream-pill strong {
  color: var(--text-main);
  font-family: var(--font-heading);
}

.card-header-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.25rem;
}

.card-brand-icon {
  width: 28px;
  height: 28px;
  background: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-purple);
  font-weight: 900;
}

.chip-contactless {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-chip {
  width: 38px;
  height: 28px;
  background: linear-gradient(135deg, #fce055 0%, #dfac6c 100%);
  border-radius: 6px;
}

.card-balance-val {
  font-size: 1.8rem;
  font-family: var(--font-heading);
  font-weight: 800;
}

.card-footer-line {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.hero-action-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero-balance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hero-main-amount {
  font-size: 2.2rem;
  font-family: var(--font-heading);
  font-weight: 800;
  margin: 6px 0 16px 0;
}

.quick-actions-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.action-card-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  color: var(--text-main);
  gap: 8px;
}

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

.stat-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-radius: var(--border-radius-lg, 16px);
  min-width: 0;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.3;
  display: block;
}

.stat-val {
  font-size: 1.65rem;
  font-weight: 800;
  font-family: var(--font-heading, inherit);
  line-height: 1.2;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.stat-val .stat-unit {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-body, inherit);
}

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 2px;
}

.stat-trend i {
  font-size: 0.75rem;
  opacity: 0.85;
}

.stat-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand-purple-subtle);
  color: var(--brand-purple-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.mini-apps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.app-tile {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.app-tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #ffffff;
}

.app-tile-icon.sayarati {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

.app-tile-icon.cashback {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.app-tile-icon.vouchers {
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
}

.app-tile-icon.dev {
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
}

.table-card {
  padding: 0;
  overflow: hidden;
}

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

.table-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-tab-btn {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.table-tab-btn.active {
  background: var(--brand-purple-subtle);
  color: var(--brand-purple-light);
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  background: transparent !important;
  color: var(--text-main) !important;
}

.table {
  --bs-table-bg: transparent !important;
  --bs-table-color: var(--text-main) !important;
  --bs-table-striped-color: var(--text-main) !important;
  --bs-table-active-color: var(--text-main) !important;
  --bs-table-hover-color: var(--text-main) !important;
  color: var(--text-main) !important;
  background-color: transparent !important;
}

.table > :not(caption) > * > * {
  background-color: transparent !important;
  color: var(--text-main) !important;
  border-bottom-color: var(--border-subtle, rgba(255, 255, 255, 0.1)) !important;
}

.custom-table th {
  background: var(--table-header-bg) !important;
  padding: 14px 24px;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--text-muted) !important;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color) !important;
}

.custom-table td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle) !important;
  font-size: 0.9rem;
  vertical-align: middle;
  color: var(--text-main) !important;
}

.tx-user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tx-icon-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.tx-icon-badge.in {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.tx-icon-badge.out {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
}

.status-tag.success {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.status-tag.danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.status-tag.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.status-tag.info {
  background: rgba(14, 165, 233, 0.15);
  color: #0ea5e9;
}

.status-tag.purple {
  background: var(--brand-purple-subtle);
  color: var(--brand-purple-light);
}

.status-tag.secondary {
  background: var(--bg-input);
  color: var(--text-muted);
}

.badge-code {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--brand-purple-light);
  border: 1px solid var(--border-color);
}

.badge-fee {
  display: inline-flex;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--brand-purple-subtle);
  color: var(--brand-purple-light);
  border: 1px solid var(--border-color);
}

.btn-action-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand-purple-subtle);
  color: var(--brand-purple-light);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 14px;
  transition: all 0.2s ease;
  cursor: pointer;
  text-decoration: none;
}

.btn-action-edit:hover {
  background: var(--brand-purple);
  color: #ffffff;
  border-color: var(--brand-purple);
}

.btn-action-fetch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 12px;
  transition: all 0.2s ease;
  cursor: pointer;
  text-decoration: none;
}

.btn-action-fetch:hover {
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.45);
}

.btn-fetch-inline {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-fetch-inline:hover {
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
}

.fees-tab-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer;
  text-decoration: none;
}

.fees-tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-input);
}

.fees-tab-btn.active {
  background: var(--brand-purple) !important;
  color: #ffffff !important;
  border-color: var(--brand-purple) !important;
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

.amount-val {
  font-weight: 800;
  font-family: var(--font-heading);
}

.amount-val.positive {
  color: #10b981;
}

.amount-val.negative {
  color: var(--text-main);
}

.subwallet-card-sm {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.subwallet-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand-purple-subtle);
  color: var(--brand-purple-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--modal-overlay);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-xl);
  width: 100%;
  max-width: 500px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  overflow: visible;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: visible;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--border-radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

@media (max-width: 992px) {
  .app-sidebar {
    transform: translateX(-100%);
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .app-main {
    margin-left: 0;
  }

  .toggle-sidebar-btn {
    display: block;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .hero-card-section {
    grid-template-columns: 1fr;
  }

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

/* --- RTL (RIGHT-TO-LEFT) ARABIC LAYOUT ENGINE --- */
[dir="rtl"] body {
  font-family: 'Cairo', 'Plus Jakarta Sans', var(--font-main);
  text-align: right;
}

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

[dir="rtl"] .app-main {
  margin-left: 0;
  margin-right: 270px;
}

[dir="rtl"] .nav-item {
  transform: none;
}

[dir="rtl"] .nav-item:hover {
  transform: translateX(-3px);
}

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

[dir="rtl"] .header-search input {
  padding: 10px 40px 10px 16px;
}

[dir="rtl"] .login-input {
  padding: 14px 44px 14px 16px;
}

[dir="rtl"] .login-input-wrapper i {
  left: auto;
  right: 16px;
}

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

[dir="rtl"] .badge-dot {
  right: auto;
  left: 6px;
}

@media (max-width: 992px) {
  [dir="rtl"] .app-sidebar {
    transform: translateX(100%);
  }

  [dir="rtl"] .app-sidebar.open {
    transform: translateX(0);
  }

  [dir="rtl"] .app-main {
    margin-right: 0;
  }
}

/* ==========================================
   GLOBAL ADAPTIVE CARD STYLES FOR ALL THEMES
   ========================================== */
.card {
  background-color: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-main) !important;
  border-radius: var(--border-radius-lg, 16px);
}

.card-header,
.card-footer {
  background-color: transparent !important;
  border-color: var(--border-color) !important;
  color: var(--text-main) !important;
}

.card-body {
  background-color: transparent !important;
  color: var(--text-main) !important;
}

/* ==========================================
   MODAL IMPROVEMENTS
   ========================================== */
.modal-dialog {
  display: flex;
  align-items: center;
  min-height: calc(100% - 3rem);
  margin: 1.5rem auto;
}

.modal-content {
  border-radius: 20px;
  border: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  max-height: 90vh;
  /* Do not exceed screen height */
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
}

.modal-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.modal-title {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
}

.modal-body {
  overflow-y: auto;
  padding: 1.5rem;
  flex: 1 1 auto;
}

.modal-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

/* HIGH-CONTRAST ACCESSIBILITY OVERRIDES (PURPLE & DARK MODES) */
[data-theme="purple"] input,
[data-theme="purple"] textarea,
[data-theme="purple"] select,
[data-theme="purple"] .login-input,
[data-theme="purple"] .form-control {
  color: #ffffff !important;
  background-color: rgba(255, 255, 255, 0.18) !important;
  border-color: rgba(255, 255, 255, 0.32) !important;
}

[data-theme="purple"] input::placeholder,
[data-theme="purple"] textarea::placeholder,
[data-theme="purple"] select::placeholder,
[data-theme="purple"] .login-input::placeholder,
[data-theme="purple"] .form-control::placeholder {
  color: rgba(255, 255, 255, 0.82) !important;
  opacity: 1 !important;
}

[data-theme="purple"] input:-webkit-autofill,
[data-theme="purple"] input:-webkit-autofill:hover,
[data-theme="purple"] input:-webkit-autofill:focus {
  -webkit-text-fill-color: #ffffff !important;
  -webkit-box-shadow: 0 0 0px 1000px #380752 inset !important;
  transition: background-color 5000s ease-in-out 0s;
}

[data-theme="purple"] .login-subtitle,
[data-theme="purple"] form label,
[data-theme="purple"] .form-label,
[data-theme="purple"] .text-muted,
[data-theme="purple"] .form-group label {
  color: #f3e8ff !important;
}

[data-theme="purple"] .login-input-wrapper i,
[data-theme="purple"] .input-group-text,
[data-theme="purple"] #password-toggle {
  color: #e9d5ff !important;
}

[data-theme="purple"] a:not(.btn) {
  color: #f3e8ff;
  text-decoration: underline;
}

[data-theme="purple"] a:not(.btn):hover {
  color: #ffffff;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder,
[data-theme="dark"] select::placeholder,
[data-theme="dark"] .login-input::placeholder,
[data-theme="dark"] .form-control::placeholder {
  color: #a1a1aa !important;
  opacity: 1 !important;
}

[data-theme="dark"] .login-subtitle,
[data-theme="dark"] form label,
[data-theme="dark"] .form-label,
[data-theme="dark"] .text-muted,
[data-theme="dark"] .form-group label {
  color: var(--text-muted, #a1a1aa) !important;
}

[data-theme="light"] .text-muted {
  color: var(--text-muted, #64748b) !important;
}

/* --- MODERN TOAST NOTIFICATIONS (BOTTOM CENTER DYNAMIC WIDTH) --- */
.toast-container-wrapper {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  width: auto;
  pointer-events: none;
}

[dir="rtl"] .toast-container-wrapper {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

.toast-card {
  pointer-events: auto;
  position: relative;
  width: max-content;
  max-width: min(640px, calc(100vw - 32px));
  background: var(--bg-surface-elevated, #ffffff);
  border-radius: 16px;
  padding: 14px 20px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.2));
  animation: toastSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: all 0.3s ease;
}

@keyframes toastSlideUp {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast-card.toast-exit {
  animation: toastSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastSlideDown {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(20px) scale(0.92);
  }
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 14px;
}

.toast-icon {
  font-size: 1.35rem;
  flex-shrink: 0;
  margin-top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-error .toast-icon {
  color: #ef4444;
}

.toast-success .toast-icon {
  color: #10b981;
}

.toast-warning .toast-icon {
  color: #f59e0b;
}

.toast-info .toast-icon, .toast-default .toast-icon {
  color: #3b82f6;
}

.toast-body-wrapper {
  flex: 1;
  min-width: 0;
}

.toast-message {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main, #ffffff);
  line-height: 1.4;
  word-break: break-word;
}

.toast-close-btn {
  background: transparent;
  border: none;
  color: var(--text-light, #e9d5ff);
  font-size: 1.05rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 6px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.toast-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

.toast-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  opacity: 0.5;
  animation: toastProgress 5s linear forwards;
}

.toast-error .toast-progress-bar {
  background: #ef4444;
}

.toast-success .toast-progress-bar {
  background: #10b981;
}

.toast-warning .toast-progress-bar {
  background: #f59e0b;
}

@keyframes toastProgress {
  from {
    width: 100%;
  }
  to {
    width: 0%;
  }
}

/* ==========================================================================
   MODAL COMPONENT & MULTI-THEME BACKDROP SYSTEM
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.active,
.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   WINDOW SCROLL LOCK & SLEEK MODAL SCROLLBAR
   Prevents double browser scrollbars when any modal opens
   ========================================================================== */
body.modal-open,
body:has(.modal.show),
body:has(.modal-backdrop.active),
html:has(.modal.show),
html:has(.modal-backdrop.active) {
  overflow: hidden !important;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--border-color, rgba(255, 255, 255, 0.15));
  border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--brand-purple-light, #7c3aed);
}

/* Ensure Bootstrap modal dialogs sit crisp and unblurred above backdrop */
.modal {
  z-index: 1050 !important;
}

.modal-dialog {
  z-index: 1055 !important;
  position: relative !important;
}

.modal-content {
  background: var(--bg-card, #ffffff) !important;
  color: var(--text-main, #0f172a) !important;
  border: 1px solid var(--border-color, #e2e8f0) !important;
  border-radius: var(--border-radius-xl, 20px) !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35) !important;
  position: relative !important;
  z-index: 1060 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  filter: none !important;
}

.modal-card {
  background: var(--bg-surface-elevated, #ffffff);
  color: var(--text-main, #0f172a);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--border-radius-xl, 24px);
  width: 100%;
  max-width: 480px;
  padding: 1.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  transform: translateY(20px) scale(0.96);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: visible;
}

.modal-backdrop.active .modal-card,
.modal-backdrop.show .modal-card {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.modal-title {
  font-family: var(--font-heading, sans-serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main, #0f172a);
  margin: 0;
}

.close-modal-btn {
  background: var(--bg-input, rgba(255, 255, 255, 0.1));
  color: var(--text-muted, #64748b);
  border: 1px solid var(--border-color, #e2e8f0);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.close-modal-btn:hover {
  background: var(--brand-purple-light, #7c3aed);
  color: #ffffff;
  transform: rotate(90deg);
}

.modal-card .form-group {
  margin-bottom: 1.25rem;
  position: relative;
  overflow: visible;
}

.modal-card label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #64748b);
  margin-bottom: 0.5rem;
}

.modal-card .form-control,
.modal-card input {
  background: var(--bg-input, #f1f5f9);
  color: var(--text-main, #0f172a);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--border-radius-md, 12px);
  padding: 0.75rem 1rem;
  font-size: 0.92rem;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Native selects inside modals — only style if NOT taken over by TomSelect */
.modal-card select:not(.tomselected):not(.ts-hidden-accessible) {
  background: var(--bg-input, #f1f5f9);
  color: var(--text-main, #0f172a);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--border-radius-md, 12px);
  padding: 0.75rem 1rem;
  font-size: 0.92rem;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modal-card .form-control:focus,
.modal-card select:not(.tomselected):not(.ts-hidden-accessible):focus,
.modal-card input:focus {
  border-color: var(--brand-purple-light, #7c3aed);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-purple-glow, rgba(124, 58, 237, 0.25));
}

/* ==========================================================================
   GLOBAL REMOVAL OF NUMBER INPUT SPIN BUTTONS / ARROWS
   ========================================================================== */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  margin: 0 !important;
  display: none !important;
}

input[type="number"] {
  -moz-appearance: textfield !important;
  appearance: textfield !important;
}

/* ==========================================================================
   INLINE FIELD VALIDATION
   Red border glow on invalid fields, error message below, modal shake.
   ========================================================================== */

/* Error state on inputs */
.field-error,
.form-control.field-error,
input.field-error,
select.field-error,
textarea.field-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

/* Error state on TomSelect wrapper */
.ts-wrapper.field-error .ts-control {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

/* Error message text below field */
.field-error-msg {
  display: block;
  color: #ef4444;
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 4px;
  padding-inline-start: 2px;
}

/* Light theme: darker red for contrast */
[data-theme="light"] .field-error-msg {
  color: #dc2626;
}

/* Modal shake animation on validation failure */
@keyframes modal-shake {
  0%, 100% { transform: translateX(0); }
  15%, 45%, 75% { transform: translateX(-4px); }
  30%, 60%, 90% { transform: translateX(4px); }
}

.modal-shake {
  animation: modal-shake 0.4s ease-in-out !important;
}

/* Input with trailing spinner icon (LTR & RTL aware via CSS logical properties) */
.input-with-spinner {
  position: relative !important;
  width: 100% !important;
}

.input-with-spinner .form-control {
  padding-inline-end: 38px !important;
}

.input-spinner {
  position: absolute !important;
  top: 50% !important;
  inset-inline-end: 12px !important;
  transform: translateY(-50%) !important;
  color: var(--brand-purple-light, #7c3aed) !important;
  pointer-events: none !important;
  z-index: 5 !important;
}

/* Recipient Verification Status Badge */
.recipient-verify-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.recipient-verify-badge.verified {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #4ade80;
}

.recipient-verify-badge.not-found {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
}

[data-theme="light"] .recipient-verify-badge.verified {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

[data-theme="light"] .recipient-verify-badge.not-found {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

/* ==========================================================================
   TOM SELECT - COMPLETE STANDALONE STYLING
   No base TomSelect CSS is loaded, so ALL layout + visual rules must be here.
   ========================================================================== */

/* Hide native select when TomSelect is active */
select.tomselected,
select.ts-hidden-accessible {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  width: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  position: absolute !important;
  opacity: 0 !important;
  overflow: hidden !important;
}

/* ── WRAPPER ──
   TomSelect copies the original <select>'s classes onto the wrapper,
   including "form-control". We must neutralise those inherited styles
   so the wrapper is just a transparent positioning container. */
.ts-wrapper,
.ts-wrapper.form-control,
.ts-wrapper.form-select,
.modal-card .ts-wrapper.form-control {
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  min-height: auto !important;
  position: relative !important;
  width: 100% !important;
  font-family: inherit !important;
  font-size: 0.92rem !important;
  display: block !important;
}

/* ── CONTROL (the visible input box) ── */
.ts-wrapper .ts-control,
.ts-wrapper .ts-control.has-items {
  background: var(--bg-input, rgba(255, 255, 255, 0.08)) !important;
  color: var(--text-main, #ffffff) !important;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.2)) !important;
  border-radius: var(--border-radius-md, 12px) !important;
  padding: 0.75rem 2.5rem 0.75rem 1rem !important;
  font-size: 0.92rem !important;
  font-family: inherit !important;
  line-height: 1.5 !important;
  min-height: 46px !important;
  display: flex !important;
  align-items: center !important;
  cursor: pointer !important;
  box-sizing: border-box !important;
  box-shadow: none !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
  position: relative !important;
}

[dir="rtl"] .ts-wrapper .ts-control,
[dir="rtl"] .ts-wrapper .ts-control.has-items {
  padding: 0.75rem 1rem 0.75rem 2.5rem !important;
}

/* Focus ring — hardcoded purple so it works on all themes */
.ts-wrapper.focus .ts-control,
.ts-wrapper.dropdown-active .ts-control {
  border-color: #7c3aed !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.25) !important;
}

/* Selected value text inside the control */
.ts-wrapper .ts-control > .item,
.ts-wrapper .ts-control > div.item,
.ts-wrapper .ts-control > div[data-ts-item] {
  color: var(--text-main, #ffffff) !important;
  font-size: 0.92rem !important;
  font-weight: 600 !important;
  line-height: 1.5 !important;
  margin: 0 !important;
  padding: 0 !important;
  background: none !important;
  background-color: transparent !important;
  border: none !important;
  box-shadow: none !important;
  display: inline !important;
}

/* Kill the hidden search input inside control */
.ts-wrapper .ts-control > input[type="text"],
.ts-wrapper .ts-control > input {
  position: absolute !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Caret arrow */
.ts-wrapper .ts-control::after {
  content: "" !important;
  position: absolute !important;
  top: 50% !important;
  right: 1rem !important;
  transform: translateY(-50%) !important;
  width: 0 !important;
  height: 0 !important;
  border-left: 5px solid transparent !important;
  border-right: 5px solid transparent !important;
  border-top: 5px solid var(--text-muted, #94a3b8) !important;
  border-bottom: none !important;
  transition: transform 0.2s ease !important;
  pointer-events: none !important;
}

[dir="rtl"] .ts-wrapper .ts-control::after {
  right: auto !important;
  left: 1rem !important;
}

.ts-wrapper.dropdown-active .ts-control::after {
  transform: translateY(-50%) rotate(180deg) !important;
}

/* ── DROPDOWN ──
   CRITICAL: position:absolute is required — no base TomSelect CSS
   is loaded, so without this the dropdown stays in document flow. */
.ts-wrapper .ts-dropdown,
.ts-dropdown {
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  background: var(--bg-surface-elevated, #1e0330) !important;
  backdrop-filter: blur(24px) !important;
  -webkit-backdrop-filter: blur(24px) !important;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.2)) !important;
  border-radius: var(--border-radius-md, 12px) !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5) !important;
  margin-top: 6px !important;
  padding: 6px !important;
  overflow: hidden !important;
  z-index: 100000 !important;
  box-sizing: border-box !important;
}

.ts-dropdown .ts-dropdown-content {
  max-height: 220px !important;
  overflow-y: auto !important;
  padding: 0 !important;
}

/* ── OPTION STATES ── */

/* Default option */
.ts-dropdown .option,
.ts-dropdown [data-selectable] {
  padding: 0.7rem 1rem !important;
  color: var(--text-main, #ffffff) !important;
  background: transparent !important;
  background-color: transparent !important;
  font-size: 0.9rem !important;
  font-weight: 500 !important;
  border-radius: 8px !important;
  margin-bottom: 2px !important;
  cursor: pointer !important;
  transition: background-color 0.15s ease !important;
}

/* ── TOMSELECT DROPDOWN CUSTOM SCROLLBAR ── */
.ts-dropdown .ts-dropdown-content,
.ts-dropdown-content {
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 58, 237, 0.5) transparent;
  max-height: 220px;
  overflow-y: auto !important;
  padding: 6px !important;
}

.ts-dropdown .ts-dropdown-content::-webkit-scrollbar,
.ts-dropdown-content::-webkit-scrollbar {
  width: 5px !important;
  height: 5px !important;
}

.ts-dropdown .ts-dropdown-content::-webkit-scrollbar-track,
.ts-dropdown-content::-webkit-scrollbar-track {
  background: transparent !important;
  border-radius: 10px !important;
}

.ts-dropdown .ts-dropdown-content::-webkit-scrollbar-thumb,
.ts-dropdown-content::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.45) !important;
  border-radius: 10px !important;
}

.ts-dropdown .ts-dropdown-content::-webkit-scrollbar-thumb:hover,
.ts-dropdown-content::-webkit-scrollbar-thumb:hover {
  background: #7c3aed !important;
}

.ts-dropdown .ts-dropdown-content::-webkit-scrollbar-button,
.ts-dropdown-content::-webkit-scrollbar-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* Hover */
.ts-dropdown .option:hover,
.ts-dropdown [data-selectable]:hover {
  background: rgba(139, 92, 246, 0.25) !important;
  background-color: rgba(139, 92, 246, 0.25) !important;
  color: #ffffff !important;
}

/* Keyboard-active (arrow keys) */
.ts-dropdown .option.active,
.ts-dropdown [data-selectable].active {
  background: rgba(139, 92, 246, 0.25) !important;
  background-color: rgba(139, 92, 246, 0.25) !important;
  color: #ffffff !important;
}

/* Currently selected value — hardcoded so purple theme doesn't resolve to #f3e8ff */
.ts-dropdown .option.selected,
.ts-dropdown .option[aria-selected="true"] {
  background: #7c3aed !important;
  background-color: #7c3aed !important;
  color: #ffffff !important;
  font-weight: 700 !important;
}

/* Selected + hovered */
.ts-dropdown .option.selected:hover,
.ts-dropdown .option.selected.active {
  background: #6d28d9 !important;
  background-color: #6d28d9 !important;
  color: #ffffff !important;
  font-weight: 700 !important;
}

/* ── LIGHT THEME ── */
[data-theme="light"] .ts-wrapper .ts-control,
[data-theme="light"] .ts-wrapper .ts-control.has-items {
  background: var(--bg-input, #f1f5f9) !important;
  color: var(--text-main, #0f172a) !important;
  border-color: var(--border-color, #e2e8f0) !important;
}

[data-theme="light"] .ts-wrapper .ts-control > .item {
  color: var(--text-main, #0f172a) !important;
}

[data-theme="light"] .ts-dropdown {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
}

[data-theme="light"] .ts-dropdown .option {
  color: #1e293b !important;
}

[data-theme="light"] .ts-dropdown .option:hover,
[data-theme="light"] .ts-dropdown .option.active {
  background: rgba(124, 58, 237, 0.1) !important;
  background-color: rgba(124, 58, 237, 0.1) !important;
  color: #7c3aed !important;
}

[data-theme="light"] .ts-dropdown .option.selected {
  background: #7c3aed !important;
  background-color: #7c3aed !important;
  color: #ffffff !important;
}

/* ==========================================================================
   BIDI / ARABIC TEXT DIRECTION FIXES
   Prevents special characters (+, -, @, (), .) from flipping in badges and dynamic text blocks.
   ========================================================================== */

input,
textarea,
select,
.form-control,
.contained-input-field,
.ts-control input,
.recipient-verify-badge,
.recipient-suggestion-detail,
.bidi-auto,
[dir="auto"] {
  unicode-bidi: plaintext !important;
}

/* ==========================================================================
   AUTO-INSERTED REQUIRED FIELD ASTERISK FLAG (ADD / EDIT TEMPLATES)
   ========================================================================== */
form:not(.view-form):not(.view-only) .form-group:has(:required) label::after,
form:not(.view-form):not(.view-only) .form-group:has([required]) label::after,
.modal-card form:not(.view-form):not(.view-only) .form-group:has(:required) label::after,
.modal-card form:not(.view-form):not(.view-only) .form-group:has([required]) label::after,
label.required-label::after {
  content: " *";
  color: #ef4444 !important;
  font-weight: 800 !important;
  display: inline-block;
  margin-inline-start: 3px !important;
}

[data-theme="light"] form:not(.view-form):not(.view-only) .form-group:has(:required) label::after,
[data-theme="light"] form:not(.view-form):not(.view-only) .form-group:has([required]) label::after,
[data-theme="light"] label.required-label::after {
  color: #dc2626 !important;
}

/* ==========================================================================
   GLOBAL RTL DIRECTIONAL ICON AUTO-FLIP
   Flips navigation arrows, chevrons, and directional icons horizontally in RTL mode.
   ========================================================================== */
[dir="rtl"] .fa-arrow-right,
[dir="rtl"] .fa-chevron-right,
[dir="rtl"] .fa-angle-right,
[dir="rtl"] .fa-caret-right,
[dir="rtl"] .fa-circle-arrow-right,
[dir="rtl"] .fa-long-arrow-right,
[dir="rtl"] .fa-arrow-right-long,
[dir="rtl"] .fa-arrow-left,
[dir="rtl"] .fa-chevron-left,
[dir="rtl"] .fa-angle-left,
[dir="rtl"] .fa-caret-left,
[dir="rtl"] .fa-circle-arrow-left,
[dir="rtl"] .fa-long-arrow-left,
[dir="rtl"] .fa-arrow-left-long,
[dir="rtl"] .fa-arrow-up-right-from-square,
[dir="rtl"] .rtl-flip {
  transform: scaleX(-1) !important;
  display: inline-block;
}

/* ==========================================================================
   GLOBAL ALIGNMENT & SPACING FOR LINKS, BUTTONS, & SECTION HEADERS
   Ensures text and icons align vertically on the exact same baseline with consistent gap
   ========================================================================== */

.see-all-link,
.section-header a:not(.icon-btn) {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  font-weight: 700 !important;
  font-size: 0.85rem !important;
  color: var(--brand-purple-light, #7c3aed) !important;
  text-decoration: none !important;
  line-height: 1 !important;
  vertical-align: middle !important;
  transition: opacity 0.2s ease, transform 0.2s ease !important;
}

.see-all-link:hover,
.section-header a:not(.icon-btn):hover {
  opacity: 0.85 !important;
}

.see-all-link i,
.section-header a i,
.btn-primary i,
.btn-secondary i,
.action-card-btn i {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0.85em !important;
  line-height: 1 !important;
  margin: 0 !important;
}

.nav-item-group {
  display: flex;
  flex-direction: column;
}
 
/* --- Bouton de niveau 1 (ex: "Mini Apps") --- */
.nav-item-toggle {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-main);
}
 
[dir="rtl"] .nav-item-toggle {
  text-align: right;
}
 
.nav-item-toggle .nav-arrow {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-light);
  transition: transform 0.25s ease;
}
 
[dir="rtl"] .nav-item-toggle .nav-arrow {
  margin-left: 0;
  margin-right: auto;
}
 
.nav-item-group.open > .nav-item-toggle .nav-arrow {
  transform: rotate(180deg);
}
 
.nav-item-group.open > .nav-item-toggle {
  color: var(--text-main);
  background: var(--bg-card-hover);
  border-radius: var(--border-radius-md);
}
 
/* --- Ligne "racine cliquable" : lien (icône+texte) + bouton flèche séparé ---
   Le lien navigue normalement vers la page du mini app.
   Le bouton flèche (à part) ne fait qu'ouvrir/fermer le sous-menu. --- */
.nav-item-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
 
.nav-item-row .nav-item-link {
  flex: 1;
  min-width: 0;
}
 
.nav-item-arrow-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  border-radius: var(--border-radius-md);
  transition: all 0.2s ease;
}
 
.nav-item-arrow-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}
 
.nav-item-arrow-btn .nav-arrow {
  font-size: 0.72rem;
  transition: transform 0.25s ease;
}
 
.nav-item-group.open > .nav-item-row .nav-item-arrow-btn .nav-arrow {
  transform: rotate(180deg);
}
 
.nav-item-group.open > .nav-item-row .nav-item-arrow-btn {
  color: var(--brand-purple-light);
  background: var(--brand-purple-subtle);
}
 
/* Variante niveau 2 (ex: "Développeur" si on veut aussi le rendre cliquable) */
.nav-subitem-row {
  display: flex;
  align-items: center;
  gap: 2px;
}
 
.nav-subitem-row .nav-subitem {
  flex: 1;
  min-width: 0;
}
 
.nav-subitem-arrow-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  border-radius: var(--border-radius-sm);
  transition: all 0.2s ease;
}
 
.nav-subitem-arrow-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}
 
.nav-subitem-arrow-btn .nav-arrow {
  font-size: 0.68rem;
  transition: transform 0.25s ease;
}
 
.nav-item-group.open > .nav-subitem-row .nav-subitem-arrow-btn .nav-arrow {
  transform: rotate(180deg);
}
 
/* --- Conteneur du sous-menu (niveau 1) --- */
.nav-submenu {
  max-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-inline-start: 20px;
  border-inline-start: 2px solid var(--border-subtle);
  margin-inline-start: 20px;
  transition: max-height 0.3s ease;
}
 
.nav-item-group.open > .nav-submenu {
  max-height: 600px;
  padding-top: 4px;
  padding-bottom: 4px;
}
 
/* --- Élément de sous-menu (lien ou bouton toggle niveau 2) --- */
.nav-subitem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--border-radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.86rem;
  font-family: var(--font-main);
  text-decoration: none;
  transition: all 0.2s ease;
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
 
[dir="rtl"] .nav-subitem {
  text-align: right;
}
 
.nav-subitem i:not(.nav-arrow) {
  font-size: 0.92rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
 
.nav-subitem:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}
 
.nav-subitem.active {
  background: var(--brand-purple-subtle);
  color: var(--brand-purple-light);
  font-weight: 700;
}
 
/* Flèche du sous-item de niveau 2 qui ouvre le niveau 3 */
.nav-subitem .nav-arrow {
  margin-left: auto;
  font-size: 0.68rem;
  transition: transform 0.25s ease;
}
 
[dir="rtl"] .nav-subitem .nav-arrow {
  margin-left: 0;
  margin-right: auto;
}
 
.nav-item-group.open > .nav-subitem .nav-arrow {
  transform: rotate(180deg);
}
 
.nav-item-group.open > .nav-subitem {
  background: var(--bg-card-hover);
  color: var(--text-main);
}
 
/* --- Sous-sous-menu (niveau 2, dans le 3ᵉ sous-module) --- */
.nav-submenu-level2 {
  padding-inline-start: 16px;
  margin-inline-start: 10px;
  border-inline-start: 2px solid var(--border-subtle);
}
 
.nav-subitem.level2 {
  font-size: 0.82rem;
  padding: 7px 12px;
}
 