@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #4f46e5;
  --secondary: #ec4899;
  --accent: #8b5cf6;
  --background: #f8fafc;
  --text-dark: #1e293b;
  --text-light: #64748b;
  --white: #ffffff;
  --glass: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.4);
  --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.05);
  --border-radius: 20px;
}

[data-theme="dark"] {
  --primary: #6366f1;
  --background: #0f172a;
  --text-dark: #f1f5f9;
  --text-light: #94a3b8;
  --white: #1e293b;
  --glass: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--background);
  color: var(--text-dark);
  line-height: 1.5;
  padding-bottom: 80px;
  /* Space for bottom nav */
  max-width: 500px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  transition: background-color 0.3s ease, color 0.3s ease;
}

[data-theme="dark"] select,
[data-theme="dark"] input,
[data-theme="dark"] textarea {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

[data-theme="dark"] .dropdown-option:hover {
  background: #334155;
}

[data-theme="dark"] .dropdown-options {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .dropdown-selected {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .option-icon {
  background: #334155;
  color: var(--primary);
}

[data-theme="dark"] .cat-icon-wrapper {
  background: #1e293b;
}

[data-theme="dark"] .item-icon {
  background: #1e293b;
}

[data-theme="dark"] .chip {
  background: #1e293b;
  color: #94a3b8;
}

[data-theme="dark"] .stat-item {
  background: #1e293b;
}

header {
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background-color: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  border-bottom: 1px solid var(--glass-border);
  padding-top: max(24px, env(safe-area-inset-top));
}

[data-theme="dark"] header {
  background-color: rgba(15, 23, 42, 0.9);
}

.title {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

main {
  padding: 16px;
}

/* CARDS */
.card {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--glass-border);
}

.account-card {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.account-card::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

.card-title {
  font-size: 14px;
  opacity: 0.8;
  font-weight: 500;
  margin-bottom: 8px;
}

.card-balance {
  font-size: 32px;
  font-weight: 700;
}

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

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.list-item {
  display: flex;
  align-items: center;
  padding: 14px;
  background: var(--white);
  border-radius: var(--border-radius);
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
  border: 1px solid var(--glass-border);
}

.list-item:active {
  transform: scale(0.98);
}

.item-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
  background: #f1f5f9;
}

.item-details {
  flex: 1;
}

.item-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-dark);
}

.item-subtitle {
  font-size: 13px;
  color: var(--text-light);
}

.item-amount {
  font-weight: 700;
  font-size: 16px;
}

.amount-expense {
  color: #ef4444;
}

.amount-income {
  color: #10b981;
}

.list-item [data-lucide="chevron-right"] {
  color: var(--text-light);
  opacity: 0.5;
}

[data-theme="dark"] .list-item [data-lucide="chevron-right"] {
  color: var(--text-light);
  opacity: 0.8;
}

/* BOTTOM NAVIGATION */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 500px;
  background: var(--glass);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  display: flex;
  justify-content: space-around;
  padding: 14px 0;
  border-top: 1px solid var(--glass-border);
  z-index: 1000;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}

[data-theme="dark"] .bottom-nav {
  background-color: rgba(15, 23, 42, 0.9);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-light);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  flex: 1;
}

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

.nav-item i {
  font-size: 20px;
}

/* ADD BUTTON */
.add-fab {
  position: fixed;
  bottom: 85px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.3);
  z-index: 1000;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.add-fab:active {
  transform: scale(0.9);
}

/* FORMS */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-light);
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 16px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

input:focus,
select:focus {
  border-color: var(--primary);
}

.btn {
  padding: 14px 24px;
  border-radius: 14px;
  border: none;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
}

.btn-primary:active {
  transform: scale(0.97);
}

/* UTILS */
.mt-2 {
  margin-top: 8px;
}

.mt-4 {
  margin-top: 16px;
}

.mb-4 {
  margin-bottom: 16px;
}

.text-center {
  text-align: center;
}

/* MODAL / OVERLAY */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  padding: 20px;
  justify-content: center;
  align-items: flex-end;
}

.overlay.active {
  display: flex;
}

.side-panel {
  width: 100%;
  max-width: 460px;
  background: var(--white);
  border-radius: 24px 24px 0 0;
  padding: 24px;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

/* Stats Dashboard */
.chart-container {
  height: 200px;
  margin-bottom: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-item {
  background: var(--white);
  padding: 16px;
  border-radius: var(--border-radius);
  border: 1px solid var(--glass-border);
}

.stat-label {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.stat-value {
  font-weight: 700;
  font-size: 18px;
}

/* Category grid for selection */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.cat-select-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.cat-icon-wrapper {
  width: 50px;
  height: 50px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  border: 2px solid transparent;
}

.cat-select-item.selected .cat-icon-wrapper {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.1);
}

.cat-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-light);
}

/* Login Page specific */
.login-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: 80px;
}

.login-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

.login-subtitle {
  color: var(--text-light);
  margin-bottom: 32px;
}

/* Account selector chips */
.chip-container {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}

.chip-container::-webkit-scrollbar {
  display: none;
}

.chip {
  padding: 8px 16px;
  background: #f1f5f9;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}

.chip.active {
  background: var(--primary);
  color: white;
}

/* Custom Dropdown */
.custom-dropdown {
  position: relative;
  width: 100%;
}

.dropdown-selected {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--background);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropdown-selected:hover {
  border-color: var(--primary);
}

.selected-details {
  display: flex;
  flex-direction: column;
}

#selectedAccountName {
  font-weight: 600;
  font-size: 15px;
}

#selectedAccountBalance {
  font-size: 12px;
  color: var(--text-light);
}

.dropdown-options {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--glass-border);
  z-index: 1000;
  display: none;
  max-height: 250px;
  overflow-y: auto;
  padding: 8px;
}

.dropdown-options.show {
  display: block;
  animation: slideInDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-option {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 4px;
}

.dropdown-option:last-child {
  margin-bottom: 0;
}

.dropdown-option:hover {
  background: var(--background);
  opacity: 0.8;
}

.option-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--background);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  color: var(--primary);
}

.option-details {
  display: flex;
  flex-direction: column;
}

.option-name {
  font-weight: 500;
  font-size: 14px;
}

.option-balance {
  font-size: 11px;
  color: var(--text-light);
}

/* Segmented Control */
.segmented-control {
  display: flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 24px;
}

[data-theme="dark"] .segmented-control {
  background: #1e293b;
}

.segmented-item {
  flex: 1;
  text-align: center;
  padding: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s ease;
  color: var(--text-light);
}

.segmented-item.active {
  background: var(--white);
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .segmented-item.active {
  background: #334155;
  color: white;
}

/* PREMIUM MODALS & ALERTS */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--white);
  padding: 32px;
  border-radius: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  border: 1px solid var(--glass-border);
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.alert-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.alert-success .alert-icon {
  background: #ecfdf5;
  color: #10b981;
}

.alert-error .alert-icon {
  background: #fee2e2;
  color: #ef4444;
}

.alert-warning .alert-icon {
  background: #fffbeb;
  color: #f59e0b;
}

.alert-info .alert-icon {
  background: #eff6ff;
  color: #3b82f6;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.modal-body {
  font-size: 15px;
  color: var(--text-light);
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  gap: 12px;
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-dark);
  border: 1px solid var(--border-color);
}

/* CUSTOM DROPDOWN IMPROVEMENTS */
.custom-select {
  position: relative;
  width: 100%;
}

.select-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.select-trigger:hover {
  border-color: var(--primary);
}

.select-options {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--white);
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  z-index: 100;
  display: none;
  overflow: hidden;
  padding: 4px;
}

.select-options.show {
  display: block;
}

.select-option {
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.2s;
}

.select-option:hover {
  background: var(--bg-secondary);
}

.select-option.selected {
  background: var(--primary)10;
  color: var(--primary);
  font-weight: 600;
}

[data-theme="dark"] .modal-content,
[data-theme="dark"] .select-trigger,
[data-theme="dark"] .select-options {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .btn-secondary {
  background: #334155;
  color: #f1f5f9;
}

/* Flatpickr Premium Overrides */
.flatpickr-calendar {
  background: var(--white) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border) !important;
  box-shadow: var(--shadow) !important;
  border-radius: 20px !important;
  font-family: 'Outfit', sans-serif !important;
  padding: 8px;
  animation: modal-fade-in 0.3s ease-out;
}

[data-theme="dark"] .flatpickr-calendar {
  background: rgba(30, 41, 59, 0.9) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected.prevMonthDay,
.flatpickr-day.selected.nextMonthDay,
.flatpickr-day.startRange.prevMonthDay,
.flatpickr-day.startRange.nextMonthDay,
.flatpickr-day.endRange.prevMonthDay,
.flatpickr-day.endRange.nextMonthDay {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
  border-radius: 10px;
}

.flatpickr-day:hover {
  background: var(--primary)10 !important;
  border-radius: 10px;
}

.flatpickr-months .flatpickr-month {
  color: var(--text-dark) !important;
  height: 48px;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
  font-weight: 600 !important;
}

.flatpickr-weekday {
  color: var(--text-light) !important;
  font-weight: 600 !important;
  font-size: 13px !important;
}

.flatpickr-day {
  color: var(--text-dark) !important;
  font-weight: 500;
}

.flatpickr-day.today {
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}

.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover,
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay,
.flatpickr-day.notAllowed,
.flatpickr-day.notAllowed.prevMonthDay,
.flatpickr-day.notAllowed.nextMonthDay {
  color: var(--text-light) !important;
  opacity: 0.3;
}

.flatpickr-calendar.arrowTop:after,
.flatpickr-calendar.arrowTop:before {
  border-bottom-color: var(--glass-border) !important;
}

[data-theme="dark"] .flatpickr-current-month input.cur-year {
  color: var(--text-dark) !important;
}