/* --- Modern Dark Theme & Glassmorphism Design System --- */

:root {
  --bg-gradient: radial-gradient(circle at top, #1e1e30, #0d0d15);
  --card-bg: rgba(25, 25, 40, 0.6);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b0;
  --text-muted: #6e6e80;
  
  --accent-purple: #9b5de5;
  --accent-purple-glow: rgba(155, 93, 229, 0.15);
  --accent-green: #00f5d4;
  --accent-green-glow: rgba(0, 245, 212, 0.15);
  --accent-blue: #00bbf9;
  --accent-blue-glow: rgba(0, 187, 249, 0.15);
  --accent-orange: #f15bb5;
  --accent-orange-glow: rgba(241, 91, 181, 0.15);
  --accent-danger: #ff4757;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Glassmorphism helpers */
.glass-effect {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Utilities */
.hidden {
  display: none !important;
}
.warning-text {
  color: var(--accent-danger) !important;
}
.success-text {
  color: var(--accent-green) !important;
}
.placeholder-text {
  text-align: center;
  color: var(--text-secondary);
  padding: 2.5rem;
  font-size: 1rem;
}

/* Buttons */
.btn {
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 1.2rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition-smooth);
}
.btn-primary {
  background: var(--accent-purple);
  color: #fff;
}
.btn-primary:hover {
  background: #aa75eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(155, 93, 229, 0.4);
}
.btn-success {
  background: var(--accent-green);
  color: #000;
  font-weight: 700;
}
.btn-success:hover {
  background: #3fffe3;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 245, 212, 0.4);
}
.btn-danger {
  background: var(--accent-danger);
  color: #fff;
}
.btn-danger:hover {
  background: #ff6b7b;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 71, 87, 0.4);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--text-secondary);
  color: var(--text-primary);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--text-primary);
}
.btn-sm {
  font-size: 0.8rem;
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
}
.btn-block {
  width: 100%;
}

/* Auth / Login Wrapper */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 2.5rem;
  border-radius: 16px;
  background: rgba(25, 25, 40, 0.8);
  border: 1px solid var(--card-border);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(15px);
}
.logo-area {
  text-align: center;
  margin-bottom: 2rem;
}
.logo-icon {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  display: inline-block;
  animation: float 4s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.logo-area h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.logo-area p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Forms grouping */
.form-group {
  margin-bottom: 1.25rem;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 500;
}
input[type="text"],
input[type="number"],
input[type="password"],
select {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: rgba(10, 10, 20, 0.5);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}
input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-purple);
  box-shadow: 0 0 10px rgba(155, 93, 229, 0.2);
}
.error-text {
  color: var(--accent-danger);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Main Dashboard Wrapper */
.dashboard-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Header */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 2rem;
  border-radius: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  margin-bottom: 1.5rem;
  backdrop-filter: blur(10px);
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.brand-icon {
  font-size: 1.8rem;
}
.header-brand h1 {
  font-size: 1.3rem;
  font-weight: 700;
}
.header-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.program-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.program-selector-wrapper label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  white-space: nowrap;
}
#global-program-select {
  padding: 0.4rem 1.5rem 0.4rem 0.5rem;
  font-size: 0.85rem;
  width: auto;
  min-width: 180px;
}

/* Stats Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  backdrop-filter: blur(10px);
  transition: var(--transition-smooth);
}
.card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}
.stat-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.stat-icon {
  font-size: 2.2rem;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon.purple { background: var(--accent-purple-glow); border: 1px solid rgba(155,93,229,0.3); }
.stat-icon.green { background: var(--accent-green-glow); border: 1px solid rgba(0,245,212,0.3); }
.stat-icon.blue { background: var(--accent-blue-glow); border: 1px solid rgba(0,187,249,0.3); }
.stat-icon.orange { background: var(--accent-orange-glow); border: 1px solid rgba(241,91,181,0.3); }

.stat-info h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 0.25rem;
}
.stat-info p {
  font-size: 1.35rem;
  font-weight: 900;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}
.chart-card {
  padding: 1.5rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 0.8rem;
  margin-bottom: 1.25rem;
}
.card-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}
.chart-wrapper {
  position: relative;
  width: 100%;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Balances Section */
.balances-card {
  margin-bottom: 1.5rem;
}
.balances-list-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.balance-item-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
}
.balance-item-box .person-names {
  display: flex;
  flex-direction: column;
}
.balance-item-box .sender-name {
  font-weight: 700;
  color: #ff6b7b;
}
.balance-item-box .receiver-name {
  font-weight: 700;
  color: #3fffe3;
}
.balance-item-box .arrow-indicator {
  color: var(--text-muted);
  margin: 0.1rem 0;
  font-size: 0.75rem;
}
.balance-item-box .balance-amount {
  font-size: 1.05rem;
  font-weight: 900;
}

/* User Transactions Card styling */
.user-transactions-card {
  margin-bottom: 1.5rem;
}
.user-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.user-selector-wrapper select {
  font-family: var(--font-family);
  background: rgba(0, 0, 0, 0.4);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
  padding: 0.4rem 1.2rem;
  border-radius: 8px;
  outline: none;
  font-size: 0.9rem;
}
.user-transactions-list-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.user-transaction-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: var(--transition-smooth);
}
.user-transaction-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}
.user-transaction-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.user-transaction-title {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}
.user-transaction-details {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.user-transaction-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.user-transaction-amount {
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Data Tables Section */
.data-section-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 1100px) {
  .data-section-grid {
    grid-template-columns: 1fr;
  }
}
.search-bar-wrapper {
  margin-bottom: 1rem;
}
.search-bar-wrapper input {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.85rem;
}
th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  padding: 0.75rem 1rem;
  font-weight: 700;
  border-bottom: 1px solid var(--card-border);
}
td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}
tr:hover td {
  background: rgba(255, 255, 255, 0.01);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-purple { background: rgba(155,93,229,0.2); color: #aa75eb; }
.badge-blue { background: rgba(0,187,249,0.2); color: #3cd0ff; }
.badge-green { background: rgba(0,245,212,0.2); color: #3fffe3; }
.badge-orange { background: rgba(241,91,181,0.2); color: #ff85cb; }
.badge-red { background: rgba(255,71,87,0.2); color: #ff6b7b; }

/* Table Action Buttons */
.table-actions {
  display: flex;
  gap: 0.4rem;
}
.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem;
  border-radius: 4px;
  transition: var(--transition-smooth);
}
.btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Modals Dialog styling */
.glass-dialog {
  margin: auto;
  border: 1px solid var(--card-border);
  background: rgba(20, 20, 35, 0.95);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 540px;
  color: var(--text-primary);
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
}
.glass-dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(5px);
}
.glass-dialog-confirm {
  max-width: 400px;
}
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 0.75rem;
}
.dialog-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}
.close-dialog-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  border-top: 1px solid var(--card-border);
  padding-top: 1rem;
}

/* Radio Group */
.radio-group {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.5rem;
}
.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.radio-label input {
  accent-color: var(--accent-purple);
}

/* Custom Shares List panel */
.custom-shares-panel {
  margin-top: 1.25rem;
  border: 1px solid rgba(255,255,255,0.06);
  padding: 1rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.01);
}
.custom-shares-panel h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}
.shares-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 180px;
  overflow-y: auto;
  padding-left: 0.25rem;
}
.share-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.share-member-row label {
  font-size: 0.9rem;
  white-space: nowrap;
}
.share-member-row input {
  width: 140px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}
.shares-summary-row {
  display: flex;
  justify-content: space-between;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--card-border);
  font-size: 0.8rem;
}
