/* ==========================================================================
   Tarazino - Luxury White & Purple Aesthetic Design System
   Inspired by landkhooneh.com: Pure White, Royal Purple, Crisp Typography & Squircles
   ========================================================================== */

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Black.ttf') format('truetype');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

img, svg {
  max-width: 100%;
}

#tarazis-splash img,
header img,
#modal-onboarding img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

:root {
  --font-sans: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  --bg-app: #F8F9FE;
  --bg-card: #FFFFFF;
  --bg-card-elevated: #FAF8FF;
  
  --purple-deep: #1E1338;
  --purple-text: #2D1F4B;
  --purple-muted: #6B5E85;
  
  --purple-primary: #7C1ED4;
  --purple-vibrant: #9333EA;
  --purple-accent: #A855F7;
  --purple-soft: #FAF5FF;
  --purple-border: #E9D5FF;
  --purple-border-light: #F3E8FF;
  
  --purple-gradient: linear-gradient(135deg, #7C1ED4 0%, #9333EA 50%, #A855F7 100%);
  --purple-gradient-subtle: linear-gradient(135deg, #FAF5FF 0%, #F5EDFF 100%);
  --purple-glow: rgba(124, 30, 212, 0.22);
  
  --radius-sm: 14px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --radius-xl: 36px;
  --radius-full: 9999px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

input, textarea {
  user-select: auto;
}

body, input, textarea, select, button, .font-sans {
  font-family: var(--font-sans);
  font-feature-settings: "ss01" 1, "locl" 1;
  -webkit-font-feature-settings: "ss01" 1, "locl" 1;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: #F8F9FE !important;
  color: var(--purple-text);
  direction: rtl;
  text-align: right;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* Absolute Scrollbar Annihilation (Eliminates the purple line / scrollbar completely on all platforms) */
*, *::before, *::after {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

*::-webkit-scrollbar {
  display: none !important;
  width: 0px !important;
  height: 0px !important;
  background: transparent !important;
  opacity: 0 !important;
}

*::-webkit-scrollbar-thumb {
  display: none !important;
  background: transparent !important;
}

*::-webkit-scrollbar-track {
  display: none !important;
  background: transparent !important;
}

/* Scroll Lock on Modals (Locks scrolling WITHOUT jumping or resetting scroll position) */
body.modal-open {
  overflow: hidden !important;
  touch-action: none !important;
  overscroll-behavior: none !important;
}

/* Safe Area Insets for Notch & Status Bar & Bottom Navigation (No giant void, zero notch overlap) */
.main-content-container {
  padding-top: 0px !important;
  padding-bottom: max(84px, calc(70px + env(safe-area-inset-bottom, 14px))) !important;
}

/* Footer Links & Text */
footer a,
.footer-link {
  text-decoration: none !important;
}

/* White & Purple Cards */
.oneui-card {
  background: var(--bg-card);
  border: 1px solid var(--purple-border-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px -2px rgba(124, 30, 212, 0.05), 0 1px 3px 0 rgba(0, 0, 0, 0.02);
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

.oneui-card:hover {
  border-color: var(--purple-border);
  box-shadow: 0 8px 24px -4px rgba(124, 30, 212, 0.08);
}

.oneui-btn-primary {
  background: var(--purple-gradient);
  color: #FFFFFF;
  border-radius: var(--radius-full);
  font-weight: 700;
  box-shadow: 0 6px 20px var(--purple-glow);
  transition: all 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.oneui-btn-primary:active {
  transform: scale(0.96);
  box-shadow: 0 2px 8px var(--purple-glow);
}

/* Now Bar Pill (کپسول هوشمند زنده) */
.now-bar {
  background: var(--purple-gradient-subtle);
  border: 1px solid var(--purple-border);
  border-radius: var(--radius-full);
  box-shadow: 0 6px 20px -4px rgba(124, 30, 212, 0.08);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.now-bar:active {
  transform: scale(0.98);
}

/* Keypad Grid for Fast Expense Entry */
.keypad-btn {
  background: #FFFFFF;
  border: 1px solid var(--purple-border-light);
  border-radius: var(--radius-md);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--purple-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 54px;
  box-shadow: 0 2px 6px rgba(124, 30, 212, 0.04);
  transition: all 0.12s ease;
}

.keypad-btn:active {
  transform: scale(0.92);
  background: var(--purple-soft);
  border-color: var(--purple-primary);
}

/* Category squircle chips */
.category-chip {
  border-radius: var(--radius-md);
  border: 1px solid var(--purple-border-light);
  background: #FFFFFF;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.category-chip.selected {
  border-color: var(--purple-primary);
  background: var(--purple-soft);
  box-shadow: 0 0 12px rgba(124, 30, 212, 0.15);
}

/* Custom Styled Dropdown (حل مشکل دراپ‌داون ساده) */
.custom-select-trigger {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: #FFFFFF;
  border: 1.5px solid var(--purple-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px -2px rgba(124, 30, 212, 0.06);
}

.custom-select-trigger:hover,
.custom-select-trigger.active {
  border-color: var(--purple-primary);
  box-shadow: 0 0 0 3px rgba(124, 30, 212, 0.12);
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #FFFFFF;
  border: 1.5px solid var(--purple-border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 36px rgba(30, 19, 56, 0.15);
  z-index: 70;
  max-height: 240px;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.custom-select-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.custom-select-option {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-bottom: 1px solid var(--purple-border-light);
  transition: background 0.15s ease;
}

.custom-select-option:last-child {
  border-bottom: none;
}

.custom-select-option:hover,
.custom-select-option.selected {
  background: var(--purple-soft);
}

/* Virtual Credit Card Mini Preview */
.virtual-card {
  border-radius: var(--radius-md);
  padding: 14px;
  color: #FFFFFF;
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 20px -2px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease;
}

.virtual-card:hover {
  transform: translateY(-2px);
}

.virtual-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
  pointer-events: none;
}

/* ======================================================== */
/* ======================================================== */
/* FLAGSHIP DOCKED ONE UI 8.5 NAVIGATION BAR (True Glassmorphism Dock) */
/* ======================================================== */
.bottom-nav {
  position: fixed;
  bottom: max(14px, env(safe-area-inset-bottom, 14px));
  left: 16px;
  right: 16px;
  width: calc(100% - 32px);
  max-width: 440px;
  height: 66px;
  margin: 0 auto;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0.40) 100%) !important;
  backdrop-filter: blur(35px) saturate(220%) contrast(105%) !important;
  -webkit-backdrop-filter: blur(35px) saturate(220%) contrast(105%) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.8) !important;
  border-top: 2px solid rgba(255, 255, 255, 0.95) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.45) !important;
  border-radius: 36px !important;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 6px 10px;
  z-index: 45;
  box-shadow: 0 16px 40px -4px rgba(124, 30, 212, 0.14), 0 4px 12px rgba(0, 0, 0, 0.03), inset 0 1.5px 2px rgba(255, 255, 255, 0.95), inset 0 -1px 2px rgba(124, 30, 212, 0.04) !important;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 50px;
  color: #64748B;
  font-size: 0.72rem;
  font-weight: 700;
  gap: 2px;
  padding: 4px 8px;
  border-radius: 24px;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  position: relative;
  border: none;
  background: transparent;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.nav-tab .nav-icon {
  width: 20px;
  height: 20px;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-tab span {
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  letter-spacing: -0.01em;
}

/* Luxury Modern Frosted Glass Active Capsule */
.nav-tab.active {
  background: rgba(124, 30, 212, 0.12) !important;
  color: #7C1ED4 !important;
  border: 1px solid rgba(124, 30, 212, 0.2) !important;
  box-shadow: 0 4px 14px rgba(124, 30, 212, 0.08), inset 0 1px 1px rgba(255, 255, 255, 0.9) !important;
  transform: scale(1.02);
}

.nav-tab.active .nav-icon {
  color: #7C1ED4 !important;
  background: transparent !important;
  padding: 0;
  transform: scale(1.08);
}

.nav-tab.active span {
  color: #7C1ED4 !important;
  font-weight: 900 !important;
}

/* Inactive Hover & Tap Effect */
.nav-tab:not(.active):hover {
  color: #7C1ED4;
  background: rgba(124, 30, 212, 0.04);
}

.nav-tab:not(.active):active {
  transform: scale(0.95);
  background: rgba(124, 30, 212, 0.06);
}

/* Virtual Cards Persian Typography */
.virtual-card,
.virtual-card * {
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif !important;
  font-feature-settings: "ss01" 1, "locl" 1 !important;
}

/* Modal Bottom Sheets - Zero Shadow when Closed (Fixes bottom dark bar bug) */
.modal-bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 600px;
  margin: 0 auto;
  background: #FFFFFF;
  border-radius: 34px 34px 0 0;
  border-top: 1px solid var(--purple-border);
  z-index: 60;
  transform: translateY(100%);
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
  box-shadow: none !important;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, visibility 0.32s;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-bottom-sheet.open {
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
  opacity: 1;
  box-shadow: 0 -12px 36px rgba(124, 30, 212, 0.16) !important;
}

.modal-bottom-sheet.modal-fullscreen {
  height: 100%;
  max-height: 100vh;
  max-height: 100dvh;
  border-radius: 0;
  top: 0;
  bottom: 0;
  z-index: 80;
}

.z-70 { z-index: 70 !important; }
.z-80 { z-index: 80 !important; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 19, 56, 0.4);
  backdrop-filter: blur(6px);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.sheet-handle {
  width: 44px;
  height: 5px;
  background: #D8B4FE;
  border-radius: 999px;
  margin: 12px auto 6px auto;
}

/* Animations */
.animate-pulse-subtle {
  animation: pulse-subtle 3s infinite ease-in-out;
}

@keyframes pulse-subtle {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.85;
    transform: scale(0.98);
  }
}

/* Landkhooneh Luxury Royal Purple Primary Action Button (Fixed Hover) */
.btn-tarazis-primary {
  background: linear-gradient(135deg, #7C1ED4 0%, #6815B6 100%) !important;
  color: #FFFFFF !important;
  box-shadow: 0 4px 14px rgba(124, 30, 212, 0.3) !important;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
  border: none !important;
  text-decoration: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-tarazis-primary:hover {
  background: linear-gradient(135deg, #6815B6 0%, #520F92 100%) !important;
  box-shadow: 0 6px 20px rgba(124, 30, 212, 0.45) !important;
  color: #FFFFFF !important;
  transform: translateY(-1px);
}

.btn-tarazis-primary:active {
  transform: scale(0.97) translateY(0) !important;
  box-shadow: 0 2px 8px rgba(124, 30, 212, 0.2) !important;
}

/* Loan Filter Tabs */
.loan-filter-btn {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.loan-filter-btn.active {
  background: #7C1ED4 !important;
  color: #FFFFFF !important;
  box-shadow: 0 3px 12px rgba(124, 30, 212, 0.3) !important;
}

/* Custom Account Type Pill */
.acc-type-pill {
  transition: all 0.18s ease;
}

.acc-type-pill.active {
  background: #7C1ED4 !important;
  color: #FFFFFF !important;
  border-color: #7C1ED4 !important;
  box-shadow: 0 2px 8px rgba(124, 30, 212, 0.25) !important;
}

/* ======================================================== */
/* FLUID TAB TRANSITIONS (One UI 7 / iOS 18 Micro-Spring)  */
/* ======================================================== */
.tab-content {
  display: none !important;
  opacity: 0 !important;
  will-change: opacity, transform;
}

.tab-content.active:not(.hidden) {
  display: flex !important;
  opacity: 1 !important;
  animation: tabFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes tabFadeIn {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.99);
    filter: blur(4px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

/* ======================================================== */
/* HIGH-Z-INDEX ULTRA TOAST (Always Above Modals, No Wrap) */
/* ======================================================== */
#oneui-toast {
  top: 14px !important;
  z-index: 99999999 !important;
  max-width: min(92vw, 420px) !important;
  white-space: normal !important;
  text-align: center !important;
  line-height: 1.5 !important;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

body.dark-mode #oneui-toast {
  color: #FAF5FF !important;
}

/* Amount Input Formatting (Natural Persian Input Caret Alignment) */
.amount-input-field {
  font-family: 'Vazirmatn', sans-serif !important;
  direction: ltr !important;
  text-align: center !important;
}

/* ======================================================== */
/* CINEMATIC FLAGSHIP SPLASH SCREEN                         */
/* ======================================================== */
#tarazis-splash {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: linear-gradient(180deg, #FDFBFF 0%, #F5F1FD 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.5s;
}

#tarazis-splash.hidden-splash {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ======================================================== */
/* ULTRA-LUXURY OLED OBSIDIAN DARK MODE (FINTECH FLAGSHIP)  */
/* ======================================================== */
body.dark-mode {
  background-color: #0B0814 !important;
  color: #F8F5FF !important;
}

body.dark-mode .bg-\[\#F8F9FE\],
body.dark-mode [class*="bg-[#F8F9FE]"] {
  background-color: #0B0814 !important;
}

body.dark-mode .bg-white {
  background-color: #140E24 !important;
}

body.dark-mode .bg-slate-50,
body.dark-mode .bg-slate-100 {
  background-color: #1A1230 !important;
}

body.dark-mode .bg-purple-50,
body.dark-mode .bg-purple-50\/70,
body.dark-mode .bg-purple-50\/80 {
  background-color: rgba(147, 51, 234, 0.15) !important;
}

body.dark-mode .bg-purple-100 {
  background-color: rgba(147, 51, 234, 0.25) !important;
}

/* Custom Select & Dropdowns in Dark Mode */
body.dark-mode .custom-select-menu {
  background-color: #171028 !important;
  border: 1px solid rgba(168, 85, 247, 0.35) !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75) !important;
}

body.dark-mode .custom-select-item {
  color: #FAF5FF !important;
}

body.dark-mode .custom-select-item:hover {
  background-color: rgba(147, 51, 234, 0.25) !important;
}

body.dark-mode .custom-select-trigger,
body.dark-mode .custom-dropdown-btn {
  background-color: #1A1230 !important;
  border-color: rgba(168, 85, 247, 0.28) !important;
  color: #FAF5FF !important;
}

/* Luxury Cards */
body.dark-mode .oneui-card {
  background: #140E24 !important;
  border: 1px solid rgba(168, 85, 247, 0.18) !important;
  box-shadow: 0 10px 32px -4px rgba(0, 0, 0, 0.65) !important;
}

/* Header & Floating Bar */
body.dark-mode #top-header-bar > div {
  background-color: rgba(20, 14, 36, 0.95) !important;
  border-color: rgba(168, 85, 247, 0.25) !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.5) !important;
}

body.dark-mode #header-theme-toggle {
  background-color: #1C1333 !important;
  border-color: rgba(168, 85, 247, 0.3) !important;
  color: #FDE047 !important;
}

body.dark-mode #header-user-name {
  color: #FAF5FF !important;
}

body.dark-mode #top-header-bar p,
body.dark-mode #header-date {
  color: #D8B4FE !important;
}

/* Now Bar */
body.dark-mode .now-bar,
body.dark-mode #now-bar {
  background: rgba(26, 18, 46, 0.95) !important;
  border: 1px solid rgba(168, 85, 247, 0.35) !important;
  color: #FAF5FF !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.6) !important;
}

body.dark-mode .now-bar span {
  color: #FAF5FF !important;
}

body.dark-mode .now-bar .text-emerald-600 {
  color: #6EE7B7 !important;
}

body.dark-mode .now-bar .text-amber-500 {
  color: #FCD34D !important;
}

/* Text Overrides for High Contrast & Readability */
body.dark-mode .text-\[\#1E1338\],
body.dark-mode [class*="text-[#1E1338]"],
body.dark-mode .text-purple-950,
body.dark-mode .text-slate-900,
body.dark-mode .text-slate-800,
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode .now-bar span:not(.text-emerald-600):not(.text-amber-500),
body.dark-mode #dash-net-balance,
body.dark-mode #dash-total-expense,
body.dark-mode #dash-total-income {
  color: #FAF5FF !important;
}

body.dark-mode .text-purple-900,
body.dark-mode .text-slate-700 {
  color: #E2D9F3 !important;
}

body.dark-mode .text-purple-700 {
  color: #C084FC !important;
}

body.dark-mode .text-purple-600 {
  color: #A855F7 !important;
}

body.dark-mode .text-slate-500,
body.dark-mode .text-slate-600 {
  color: #C4B5FD !important;
}

body.dark-mode .text-slate-400 {
  color: #A79BC2 !important;
}

/* Borders */
body.dark-mode .border-purple-50,
body.dark-mode .border-purple-100,
body.dark-mode .border-purple-200,
body.dark-mode .border-slate-100,
body.dark-mode .border-slate-200 {
  border-color: rgba(168, 85, 247, 0.2) !important;
}

/* High-Contrast Badges & Status Chips */
body.dark-mode .bg-emerald-50,
body.dark-mode .bg-emerald-100 {
  background-color: rgba(16, 185, 129, 0.18) !important;
  color: #6EE7B7 !important;
  border-color: rgba(16, 185, 129, 0.3) !important;
}

body.dark-mode .text-emerald-700,
body.dark-mode .text-emerald-800 {
  color: #6EE7B7 !important;
}

body.dark-mode .bg-rose-50,
body.dark-mode .bg-rose-100 {
  background-color: rgba(239, 68, 68, 0.18) !important;
  color: #FCA5A5 !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
}

body.dark-mode .text-rose-700,
body.dark-mode .text-rose-800 {
  color: #FCA5A5 !important;
}

body.dark-mode .bg-amber-50,
body.dark-mode .bg-amber-100 {
  background-color: rgba(245, 158, 11, 0.18) !important;
  color: #FCD34D !important;
  border-color: rgba(245, 158, 11, 0.3) !important;
}

body.dark-mode .text-amber-700,
body.dark-mode .text-amber-800 {
  color: #FCD34D !important;
}

/* Form Controls & Inputs */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background-color: #1A1230 !important;
  color: #FAF5FF !important;
  border-color: rgba(168, 85, 247, 0.28) !important;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: #7E709A !important;
}

body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
  background-color: #20163C !important;
  border-color: #C084FC !important;
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2) !important;
}

/* Modals & Bottom Sheets */
body.dark-mode .modal-bottom-sheet {
  background-color: #140E24 !important;
  border-top-color: rgba(168, 85, 247, 0.35) !important;
  color: #FAF5FF !important;
  box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.8) !important;
}

body.dark-mode #modal-onboarding {
  background-color: #0F091C !important;
}

body.dark-mode #modal-onboarding h2,
body.dark-mode #modal-onboarding h3 {
  color: #FAF5FF !important;
}

body.dark-mode #modal-onboarding p {
  color: #D8B4FE !important;
}

body.dark-mode .sheet-handle {
  background-color: rgba(168, 85, 247, 0.4) !important;
}

/* Transaction and List Items */
body.dark-mode .cat-stat-card {
  background-color: #171028 !important;
  border-color: rgba(168, 85, 247, 0.2) !important;
}

body.dark-mode .cat-stat-card:hover {
  background-color: #1F1535 !important;
  border-color: rgba(168, 85, 247, 0.4) !important;
}

/* Chart Styles in Dark Mode */
body.dark-mode #donut-center-title {
  color: #A79BC2 !important;
}

body.dark-mode #donut-center-amount {
  color: #FAF5FF !important;
}

body.dark-mode #donut-center-badge {
  background: rgba(147, 51, 234, 0.3) !important;
  color: #D8B4FE !important;
}

body.dark-mode circle[stroke="#F3E8FF"] {
  stroke: rgba(168, 85, 247, 0.15) !important;
}

body.dark-mode #weekly-active-detail {
  background: rgba(147, 51, 234, 0.18) !important;
  border-color: rgba(168, 85, 247, 0.3) !important;
}

body.dark-mode #weekly-active-detail span {
  color: #FAF5FF !important;
}

/* Glassmorphic Bottom Navigation Dock */
body.dark-mode .bottom-nav {
  background: rgba(18, 12, 32, 0.82) !important;
  backdrop-filter: blur(32px) saturate(200%) !important;
  -webkit-backdrop-filter: blur(32px) saturate(200%) !important;
  border: 1.5px solid rgba(168, 85, 247, 0.28) !important;
  border-top: 2px solid rgba(192, 132, 252, 0.35) !important;
  box-shadow: 0 16px 44px -4px rgba(0, 0, 0, 0.8), inset 0 1px 1px rgba(255, 255, 255, 0.1) !important;
}

body.dark-mode .nav-tab {
  color: #9488B0 !important;
}

body.dark-mode .nav-tab:hover {
  color: #E2D9F3 !important;
}

body.dark-mode .nav-tab.active {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.35) 0%, rgba(124, 30, 212, 0.2) 100%) !important;
  color: #FAF5FF !important;
  border: 1px solid rgba(192, 132, 252, 0.35) !important;
}

body.dark-mode .nav-tab.active .nav-icon,
body.dark-mode .nav-tab.active span {
  color: #FAF5FF !important;
}

body.dark-mode #tarazis-splash {
  background: #0B0814 !important;
}

/* ---------------------------------------------------- */
/* ADVANCED DARK MODE COMPONENT REFINEMENTS & CONTRAST  */
/* ---------------------------------------------------- */

/* Category Chips in Modal & Forms */
body.dark-mode .category-chip {
  background-color: #171028 !important;
  border-color: rgba(168, 85, 247, 0.22) !important;
  color: #FAF5FF !important;
}
body.dark-mode .category-chip:hover {
  background-color: #22163E !important;
  border-color: rgba(168, 85, 247, 0.45) !important;
}
body.dark-mode .category-chip.selected {
  background-color: rgba(147, 51, 234, 0.32) !important;
  border-color: #C084FC !important;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.3) !important;
}
body.dark-mode .category-chip span {
  color: #FAF5FF !important;
}

/* Custom Select Dropdowns & Trigger */
body.dark-mode .custom-select-trigger {
  background-color: #171028 !important;
  border-color: rgba(168, 85, 247, 0.35) !important;
  color: #FAF5FF !important;
}
body.dark-mode .custom-select-trigger span {
  color: #FAF5FF !important;
}
body.dark-mode .custom-select-menu {
  background-color: #150E24 !important;
  border: 1.5px solid rgba(168, 85, 247, 0.4) !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.85) !important;
}
body.dark-mode .custom-select-option {
  background-color: #150E24 !important;
  color: #FAF5FF !important;
  border-bottom-color: rgba(168, 85, 247, 0.15) !important;
}
body.dark-mode .custom-select-option:hover,
body.dark-mode .custom-select-option.selected {
  background: rgba(147, 51, 234, 0.3) !important;
  color: #FAF5FF !important;
}
body.dark-mode .custom-select-option span {
  color: #FAF5FF !important;
}

/* Header TARAZBAN Brand Pill */
body.dark-mode .header-tarazban-badge {
  background-color: rgba(147, 51, 234, 0.28) !important;
  color: #E9D5FF !important;
  border-color: rgba(168, 85, 247, 0.45) !important;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.15) !important;
}

/* Loan Progress Card & Track in Loans Tab */
body.dark-mode .loan-progress-box {
  background-color: #171028 !important;
  border-color: rgba(168, 85, 247, 0.25) !important;
}
body.dark-mode .loan-progress-box span,
body.dark-mode .loan-progress-box strong {
  color: #FAF5FF !important;
}
body.dark-mode .loan-progress-track {
  background-color: rgba(147, 51, 234, 0.2) !important;
  border-color: rgba(168, 85, 247, 0.35) !important;
}

/* Empty State Cards */
body.dark-mode .empty-state-card {
  background-color: #171028 !important;
  border-color: rgba(168, 85, 247, 0.3) !important;
  color: #C4B5FD !important;
}
body.dark-mode .empty-state-card span {
  color: #C4B5FD !important;
}
body.dark-mode .empty-state-card button {
  color: #E9D5FF !important;
}

/* Category Icon Picker in Settings */
body.dark-mode .cat-picker-item {
  background-color: #171028 !important;
  border-color: rgba(168, 85, 247, 0.25) !important;
}
body.dark-mode .cat-picker-item:hover {
  background-color: #22163E !important;
  border-color: rgba(168, 85, 247, 0.45) !important;
}
body.dark-mode .cat-picker-item .w-9 {
  color: #C4B5FD !important;
}

/* Explanatory Guide Box (Settings Budget Guide) */
body.dark-mode .guide-info-card {
  background: linear-gradient(135deg, rgba(30, 19, 56, 0.95), rgba(20, 14, 36, 0.95)) !important;
  border-color: rgba(168, 85, 247, 0.3) !important;
  color: #FAF5FF !important;
}
body.dark-mode .guide-info-card p {
  color: #D8B4FE !important;
}
body.dark-mode .guide-info-card strong {
  color: #FAF5FF !important;
}
body.dark-mode .guide-info-card div {
  color: #FAF5FF !important;
}
body.dark-mode .guide-info-card span {
  color: #FAF5FF !important;
}

/* Active User Session Row in Settings */
body.dark-mode .settings-session-row {
  background: linear-gradient(135deg, rgba(30, 19, 56, 0.95), rgba(20, 14, 36, 0.95)) !important;
  border-color: rgba(168, 85, 247, 0.3) !important;
}
body.dark-mode .settings-session-row span,
body.dark-mode .settings-session-row p {
  color: #FAF5FF !important;
}

/* Settings Action Buttons (بارگذاری داده‌های پیش‌فرض، دانلود، بازیابی) */
body.dark-mode .btn-demo-data {
  background-color: rgba(147, 51, 234, 0.28) !important;
  color: #FAF5FF !important;
  border-color: rgba(168, 85, 247, 0.45) !important;
  box-shadow: 0 4px 14px rgba(124, 30, 212, 0.25) !important;
}
body.dark-mode .btn-demo-data:hover {
  background-color: rgba(147, 51, 234, 0.45) !important;
  color: #FFFFFF !important;
  border-color: #C084FC !important;
}
body.dark-mode .btn-reset-data {
  background-color: rgba(225, 29, 72, 0.2) !important;
  color: #FECDD3 !important;
  border-color: rgba(244, 63, 94, 0.4) !important;
}
body.dark-mode .btn-reset-data:hover {
  background-color: rgba(225, 29, 72, 0.35) !important;
  color: #FFFFFF !important;
  border-color: #FB7185 !important;
}
body.dark-mode .btn-settings-action {
  background-color: #171028 !important;
  border-color: rgba(168, 85, 247, 0.25) !important;
  color: #FAF5FF !important;
}
body.dark-mode .btn-settings-action:hover {
  background-color: #22163E !important;
  border-color: rgba(168, 85, 247, 0.45) !important;
  color: #FFFFFF !important;
}
body.dark-mode .btn-settings-action span {
  color: #FAF5FF !important;
}

/* Walkthrough Modal in Dark Mode */
body.dark-mode #modal-walkthrough {
  background: #0E081D !important;
  color: #FAF5FF !important;
}
body.dark-mode #modal-walkthrough h2 {
  color: #FAF5FF !important;
}
body.dark-mode #modal-walkthrough p {
  color: #D8B4FE !important;
}
body.dark-mode .walkthrough-img-container {
  background-color: #171028 !important;
  border-color: rgba(168, 85, 247, 0.35) !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6) !important;
}
body.dark-mode .dark-glass-badge {
  background-color: rgba(26, 18, 46, 0.95) !important;
  border-color: rgba(168, 85, 247, 0.4) !important;
  color: #FAF5FF !important;
}
body.dark-mode .dark-glass-badge span {
  color: #FAF5FF !important;
}
body.dark-mode .dark-glass-card {
  background-color: #171028 !important;
  border-color: rgba(168, 85, 247, 0.25) !important;
}
body.dark-mode .dark-glass-card span {
  color: #FAF5FF !important;
}
body.dark-mode .dark-glass-card p {
  color: #D8B4FE !important;
}
body.dark-mode #walkthrough-btn-prev {
  background-color: #1A1230 !important;
  border-color: rgba(168, 85, 247, 0.3) !important;
  color: #FAF5FF !important;
}
body.dark-mode #walkthrough-btn-prev:hover {
  background-color: #241842 !important;
  color: #FFFFFF !important;
}
body.dark-mode .dark-glass-bg {
  background-color: rgba(20, 14, 36, 0.95) !important;
  border-color: rgba(168, 85, 247, 0.35) !important;
}
body.dark-mode .dark-glass-bg span {
  color: #FAF5FF !important;
}

/* ======================================================== */
/* DARK MODE MODAL CONTAINERS & PILLS (IMAGES 1 & 2 FIX)    */
/* ======================================================== */
body.dark-mode #acc-type-pills-container,
body.dark-mode #cat-icon-picker-grid,
body.dark-mode #pay-inst-account-list {
  background-color: #171028 !important;
  border-color: rgba(168, 85, 247, 0.28) !important;
}

body.dark-mode #acc-type-pills-container > div:not(.bg-purple-600) {
  background-color: #21153A !important;
  border-color: rgba(168, 85, 247, 0.28) !important;
  color: #F3E8FF !important;
}
body.dark-mode #acc-type-pills-container > div:not(.bg-purple-600):hover {
  background-color: #2D1D4F !important;
  border-color: #A855F7 !important;
}
body.dark-mode #acc-type-pills-container > div:not(.bg-purple-600) button {
  color: #F3E8FF !important;
}

body.dark-mode .cat-picker-item {
  background-color: #21153A !important;
  border-color: rgba(168, 85, 247, 0.28) !important;
}
body.dark-mode .cat-picker-item:hover {
  background-color: #2D1D4F !important;
  border-color: #A855F7 !important;
}
body.dark-mode .cat-picker-item svg {
  color: #D8B4FE !important;
}
body.dark-mode .cat-picker-item input:checked + div {
  background-color: #9333EA !important;
  color: #FFFFFF !important;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.4) !important;
}

/* Notes in Transactions & Loans (Dark Mode) */
body.dark-mode .tx-card-note,
body.dark-mode .loan-card-note {
  background-color: rgba(147, 51, 234, 0.15) !important;
  border-color: rgba(168, 85, 247, 0.25) !important;
  color: #DDD6FE !important;
}
body.dark-mode .tx-card-note svg,
body.dark-mode .loan-card-note svg {
  color: #C084FC !important;
}

/* ======================================================== */
/* COMPREHENSIVE DARK MODE REFINEMENTS & CONTRAST FIXES     */
/* ======================================================== */

/* 1. White Line Above Footer & Separator Borders (Image 9) */
body.dark-mode footer,
body.dark-mode footer.border-t,
body.dark-mode hr,
body.dark-mode .border-purple-100,
body.dark-mode .border-purple-100\/70,
body.dark-mode .border-purple-100\/60,
body.dark-mode .border-purple-200\/60,
body.dark-mode .border-purple-50 {
  border-color: rgba(168, 85, 247, 0.16) !important;
}
body.dark-mode footer span.text-\[\#1E1338\] {
  color: #FAF5FF !important;
}
body.dark-mode footer .text-purple-800,
body.dark-mode footer .text-purple-700 {
  color: #C084FC !important;
}
body.dark-mode footer a {
  color: #D8B4FE !important;
}

/* 2. Accounts Card '+ افزودن کارت' Button Contrast (Image 2 Fix) */
body.dark-mode button[onclick*="openAddAccountModal"],
body.dark-mode button[onclick*="openAccountModal"],
body.dark-mode .btn-add-card-header {
  background-color: rgba(147, 51, 234, 0.4) !important;
  color: #FAF5FF !important;
  border: 1px solid rgba(192, 132, 252, 0.6) !important;
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.3) !important;
}
body.dark-mode button[onclick*="openAddAccountModal"]:hover {
  background-color: rgba(147, 51, 234, 0.6) !important;
  color: #FFFFFF !important;
  border-color: #C084FC !important;
}
body.dark-mode .empty-state-card button {
  color: #D8B4FE !important;
}

/* 3. Walkthrough Slide 3 Skip Permission Button (Image 3 Fix) */
#walkthrough-btn-skip-perm {
  background-color: rgba(241, 245, 249, 0.9);
  color: #475569;
  border: 1px solid rgba(203, 213, 225, 0.8);
}
body.dark-mode #walkthrough-btn-skip-perm {
  background-color: #1A1230 !important;
  color: #D8B4FE !important;
  border: 1px solid rgba(168, 85, 247, 0.35) !important;
}
body.dark-mode #walkthrough-btn-skip-perm:hover {
  background-color: #241842 !important;
  color: #FAF5FF !important;
  border-color: rgba(168, 85, 247, 0.55) !important;
}

/* 4. Frosted Glassmorphic Toast Notification */
#oneui-toast {
  backdrop-filter: blur(28px) saturate(190%) !important;
  -webkit-backdrop-filter: blur(28px) saturate(190%) !important;
}

/* 4. Slide 3 Permission Badges (Image 6) */
body.dark-mode .dark-glass-card span[class*="bg-indigo-50"],
body.dark-mode .dark-glass-card span[class*="bg-purple-50"],
body.dark-mode .dark-glass-card span[class*="bg-"] {
  background-color: rgba(147, 51, 234, 0.32) !important;
  color: #FAF5FF !important;
  border-color: rgba(192, 132, 252, 0.5) !important;
}
body.dark-mode .dark-glass-card .text-slate-900 {
  color: #FAF5FF !important;
}
body.dark-mode .dark-glass-card .text-slate-500 {
  color: #DDD6FE !important;
}

/* 5. Budget Progress Bar Track (Image 7) */
body.dark-mode .bg-slate-200\/80,
body.dark-mode .bg-slate-200,
body.dark-mode .bg-slate-100 {
  background-color: #201438 !important;
  border: 1px solid rgba(168, 85, 247, 0.2) !important;
}

/* 6. Hardware Acceleration for High Refresh Rate (120Hz) Performance */
.oneui-card,
.modal-bottom-sheet,
.category-chip,
.bottom-nav,
.tab-content {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Smart SMS Paste Preview Dark Mode */
body.dark-mode #sms-paste-preview {
  background-color: rgba(26, 17, 50, 0.85) !important;
  border-color: rgba(168, 85, 247, 0.3) !important;
}
body.dark-mode #sms-paste-preview span {
  color: #E2E8F0 !important;
}
body.dark-mode #sms-preview-bank {
  color: #C084FC !important;
}
body.dark-mode #sms-preview-amount {
  color: #34D399 !important;
}

/* ==========================================================================
   EXPLICIT LIGHT MODE & DARK MODE ROBUST CONTRAST SYSTEM
   Guarantees zero modal blackouts in day mode and zero white flash in dark mode
   ========================================================================== */

/* 1. Day / Light Mode Modal Containers & Lists (Fixes Images 3, 4, 5, 9, 10) */
body:not(.dark-mode) .modal-bottom-sheet,
html:not(.dark) .modal-bottom-sheet {
  background-color: #FFFFFF !important;
  color: #1E1338 !important;
}

body:not(.dark-mode) #acc-type-pills-container,
html:not(.dark) #acc-type-pills-container {
  background-color: rgba(248, 250, 252, 0.95) !important;
  border-color: #E9D5FF !important;
}

body:not(.dark-mode) #acc-type-pills-container > div:not(.bg-purple-600),
html:not(.dark) #acc-type-pills-container > div:not(.bg-purple-600) {
  background-color: #FFFFFF !important;
  color: #1E1338 !important;
  border-color: #E9D5FF !important;
}

body:not(.dark-mode) #acc-type-pills-container > div:not(.bg-purple-600) button,
html:not(.dark) #acc-type-pills-container > div:not(.bg-purple-600) button {
  color: #475569 !important;
}

body:not(.dark-mode) #cat-icon-picker-grid,
html:not(.dark) #cat-icon-picker-grid {
  background-color: rgba(248, 250, 252, 0.95) !important;
  border-color: #E9D5FF !important;
}

body:not(.dark-mode) #modal-pay-installment .rounded-2xl,
html:not(.dark) #modal-pay-installment .rounded-2xl {
  background-color: rgba(250, 245, 255, 0.95) !important;
  border-color: #E9D5FF !important;
  color: #1E1338 !important;
}

body:not(.dark-mode) #pay-inst-account-list,
html:not(.dark) #pay-inst-account-list {
  background-color: transparent !important;
}

/* 2. Dark Mode Dropdown Menu & Category Chips (Fixes Image 2) */
body.dark-mode .custom-select-menu,
.dark .custom-select-menu {
  background-color: #160F26 !important;
  border-color: rgba(168, 85, 247, 0.4) !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75) !important;
}

body.dark-mode .custom-select-option,
.dark .custom-select-option {
  background-color: #160F26 !important;
  color: #FAF5FF !important;
  border-bottom-color: rgba(168, 85, 247, 0.15) !important;
}

body.dark-mode .custom-select-option:hover,
body.dark-mode .custom-select-option.selected,
.dark .custom-select-option:hover,
.dark .custom-select-option.selected {
  background-color: rgba(147, 51, 234, 0.35) !important;
  color: #FAF5FF !important;
}

body.dark-mode .custom-select-option span,
.dark .custom-select-option span {
  color: #FAF5FF !important;
}

body.dark-mode .category-chip,
.dark .category-chip {
  background-color: #171028 !important;
  border-color: rgba(168, 85, 247, 0.25) !important;
  color: #FAF5FF !important;
}

body.dark-mode .category-chip:hover,
.dark .category-chip:hover {
  background-color: #22163E !important;
  border-color: rgba(168, 85, 247, 0.5) !important;
}

body.dark-mode .category-chip.selected,
.dark .category-chip.selected {
  background-color: rgba(147, 51, 234, 0.35) !important;
  border-color: #C084FC !important;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.35) !important;
}

body.dark-mode .category-chip span,
.dark .category-chip span {
  color: #FAF5FF !important;
}

/* 3. Status Bar & Safe Area Protection (Fixes Images 4 & 6) */
.main-content-container {
  padding-top: 0px !important;
  padding-bottom: max(88px, calc(72px + env(safe-area-inset-bottom, 14px))) !important;
}

.dir-ltr {
  direction: ltr !important;
  text-align: left !important;
}
