/* Hesab PWA - Modern Mobile-First RTL Stylesheet */
:root {
  --primary: #1976d2;
  --primary-dark: #115293;
  --primary-light: #e3f2fd;
  --success: #2e7d32;
  --success-light: #e8f5e9;
  --danger: #d32f2f;
  --danger-light: #ffebee;
  --warning: #ed6c02;
  --warning-light: #fff3e0;
  --info: #0288d1;
  --info-light: #e1f5fe;

  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Vazirmatn", "IRANSans", Tahoma, sans-serif;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.08);

  --nav-height: 60px;
  --header-height: 54px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text-main);
  direction: rtl;
  text-align: start;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-block-end: calc(var(--nav-height) + env(safe-area-inset-bottom, 16px));
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: var(--primary);
  color: #ffffff;
  height: var(--header-height);
  padding-inline: 1rem;
  padding-block-start: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.app-header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

.header-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* Main Container */
.app-main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin-inline: auto;
  padding-inline: 1rem;
  padding-block: 1rem;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  inset-inline-start: 0;
  inset-inline-end: 0;
  z-index: 50;
  background-color: var(--surface);
  border-block-start: 1px solid var(--border);
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-block-end: env(safe-area-inset-bottom, 0px);
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  gap: 3px;
  transition: color 0.15s ease;
}

.nav-item.active {
  color: var(--primary);
  font-weight: 700;
}

.nav-icon {
  font-size: 1.25rem;
  line-height: 1;
}

/* Floating Action Button (FAB) */
.fab-btn {
  position: fixed;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 16px) + 12px);
  inset-inline-end: 1.25rem;
  z-index: 45;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.fab-btn:active {
  transform: scale(0.92);
}

/* Card and UI Containers */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-block-end: 0.85rem;
  box-shadow: var(--shadow-sm);
}

/* Segmented Control / Tabs */
.tabs-container {
  display: flex;
  background-color: #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-block-end: 1rem;
  gap: 2px;
}

.tab-btn {
  flex: 1;
  padding-block: 0.45rem;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.tab-btn.active {
  background-color: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Transaction List and Items */
.date-group {
  margin-block-end: 1.25rem;
}

.date-header {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-block-end: 0.5rem;
  padding-inline: 0.25rem;
  display: flex;
  justify-content: space-between;
}

.tx-item {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-block-end: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  transition: transform 0.1s ease;
}

.tx-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
}

.tx-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.tx-amount-col {
  text-align: end;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.tx-amount {
  font-size: 1rem;
  font-weight: 700;
  direction: ltr;
}

.tx-amount.payment {
  color: var(--danger);
}

.tx-amount.receipt {
  color: var(--success);
}

.tx-amount.transfer {
  color: var(--info);
}

.tx-badge {
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
}

.tx-badge.payment { background-color: var(--danger-light); color: var(--danger); }
.tx-badge.receipt { background-color: var(--success-light); color: var(--success); }
.tx-badge.transfer { background-color: var(--info-light); color: var(--info); }

/* Accounts List & Groups */
.account-group-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-block-end: 0.75rem;
  overflow: hidden;
}

.account-group-header {
  padding: 0.85rem 1rem;
  background-color: #f8fafc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-block-end: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.92rem;
}

.account-item {
  padding: 0.85rem 1rem;
  border-block-end: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.account-item:last-child {
  border-block-end: none;
}

.account-item.sub-account {
  padding-inline-start: 2rem;
  background-color: #fafbfd;
  border-inline-start: 3px solid var(--primary-light);
}

.account-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.account-balance {
  font-weight: 700;
  font-size: 0.95rem;
  direction: ltr;
}

/* Modals & Dialogs */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.modal-sheet {
  background: var(--surface);
  width: 100%;
  max-width: 600px;
  max-height: 88vh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 1.25rem;
  padding-block-end: calc(1.25rem + env(safe-area-inset-bottom, 16px));
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.open .modal-sheet {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-block-end: 1rem;
  padding-block-end: 0.75rem;
  border-block-end: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
}

/* Forms and Inputs */
.form-group {
  margin-block-end: 1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-block-end: 0.35rem;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.75rem 0.85rem;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
  background-color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  background-color: var(--surface);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.form-row {
  display: flex;
  gap: 0.75rem;
}

.form-row > .form-group {
  flex: 1;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
  gap: 0.5rem;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

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

.btn-secondary {
  background-color: #e2e8f0;
  color: var(--text-main);
}

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
}

/* Operations Screen Quick Cards */
.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-block-end: 1rem;
}

.quick-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 0.85rem;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.quick-card:active {
  transform: scale(0.96);
}

.quick-icon {
  font-size: 1.75rem;
  margin-block-end: 0.2rem;
}

.quick-title {
  font-size: 0.9rem;
  font-weight: 700;
}

/* Empty States */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  margin-block-end: 0.5rem;
  color: var(--text-light);
}

.empty-title {
  font-size: 1rem;
  font-weight: 600;
  margin-block-end: 0.35rem;
}

.empty-desc {
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + 12px);
  inset-inline: 1rem;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  gap: 0.5rem;
}

.toast {
  background-color: #1e293b;
  color: #ffffff;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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