/* =============================================
   FINTRACK — Personal Finance Tracker
   Style System
   ============================================= */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a0d1a;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);

  --text-primary: #f0f2ff;
  --text-secondary: #8b90b8;
  --text-muted: #4e5278;

  --income: #22d3a5;
  --income-dim: rgba(34, 211, 165, 0.15);
  --income-glow: rgba(34, 211, 165, 0.3);

  --expense: #f05d7a;
  --expense-dim: rgba(240, 93, 122, 0.15);
  --expense-glow: rgba(240, 93, 122, 0.3);

  --accent: #7c6ff7;
  --accent-dim: rgba(124, 111, 247, 0.2);
  --accent-glow: rgba(124, 111, 247, 0.4);

  --gold: #f5c542;
  --gold-dim: rgba(245, 197, 66, 0.15);

  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 8px;

  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.3);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* --- Background Blobs --- */
.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
  animation: blobFloat 8s ease-in-out infinite;
}

.blob-1 {
  width: 600px;
  height: 600px;
  background: var(--accent);
  top: -200px;
  right: -100px;
  animation-delay: 0s;
}

.blob-2 {
  width: 400px;
  height: 400px;
  background: var(--income);
  bottom: 10%;
  left: -100px;
  animation-delay: -3s;
}

.blob-3 {
  width: 300px;
  height: 300px;
  background: var(--expense);
  top: 40%;
  right: 30%;
  animation-delay: -5s;
}

@keyframes blobFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 13, 26, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.logo-icon {
  font-size: 1.4rem;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--income));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.month-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.btn-icon {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
  color: var(--text-secondary);
}

.btn-icon:hover {
  background: var(--expense-dim);
  border-color: var(--expense);
  transform: scale(1.05);
}

/* --- Main Layout --- */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* --- Glass Card --- */
.glass-card {
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  transition: border-color var(--transition);
}

.glass-card:hover {
  border-color: var(--border-strong);
}

/* --- Summary Cards --- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.card {
  border-radius: var(--radius);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  cursor: default;
  transition: transform var(--transition), box-shadow var(--transition);
}

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

.card-decoration {
  position: absolute;
  right: 1.2rem;
  bottom: 0.8rem;
  font-size: 4rem;
  opacity: 0.07;
  line-height: 1;
  pointer-events: none;
  transition: opacity var(--transition);
}

.card:hover .card-decoration {
  opacity: 0.12;
}

.card-balance {
  background: linear-gradient(135deg, rgba(124, 111, 247, 0.25), rgba(124, 111, 247, 0.08));
  border: 1px solid rgba(124, 111, 247, 0.3);
  box-shadow: 0 8px 32px rgba(124, 111, 247, 0.15);
}

.card-income {
  background: linear-gradient(135deg, rgba(34, 211, 165, 0.2), rgba(34, 211, 165, 0.06));
  border: 1px solid rgba(34, 211, 165, 0.25);
  box-shadow: 0 8px 32px rgba(34, 211, 165, 0.12);
}

.card-expense {
  background: linear-gradient(135deg, rgba(240, 93, 122, 0.2), rgba(240, 93, 122, 0.06));
  border: 1px solid rgba(240, 93, 122, 0.25);
  box-shadow: 0 8px 32px rgba(240, 93, 122, 0.12);
}

.card-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.card-amount {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 0.4rem;
}

.card-balance .card-amount { color: var(--accent); }
.card-income .card-amount { color: var(--income); }
.card-expense .card-amount { color: var(--expense); }

.card-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* --- Savings Progress --- */
.savings-section {
  padding: 1.25rem 1.75rem;
}

.savings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.savings-percent {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--income);
}

.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 0.6rem;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--income));
  border-radius: 100px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px var(--income-glow);
}

.savings-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* --- Section Title --- */
.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* --- Two Column Layout --- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* --- Form Section --- */
.form-section h2 {
  margin-bottom: 1.25rem;
}

.toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
}

.toggle-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.6rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition);
}

.toggle-btn.active[data-type="income"] {
  background: var(--income-dim);
  color: var(--income);
  box-shadow: 0 0 12px var(--income-glow);
}

.toggle-btn.active[data-type="expense"] {
  background: var(--expense-dim);
  color: var(--expense);
  box-shadow: 0 0 12px var(--expense-glow);
}

.toggle-btn:hover:not(.active) {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-group input,
.form-group select {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  padding: 0.7rem 1rem;
  transition: var(--transition);
  outline: none;
  appearance: none;
}

.form-group input::placeholder { color: var(--text-muted); }
.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  background: rgba(124, 111, 247, 0.07);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-group select option {
  background: #1a1d2e;
  color: var(--text-primary);
}

.btn-submit {
  width: 100%;
  margin-top: 0.5rem;
  background: linear-gradient(135deg, var(--accent), #9b6ff7);
  border: none;
  border-radius: var(--radius-xs);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.85rem 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition);
  letter-spacing: 0.01em;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--accent-glow);
  filter: brightness(1.1);
}

.btn-submit:active {
  transform: translateY(0);
}

.btn-icon-right {
  transition: transform var(--transition);
}

.btn-submit:hover .btn-icon-right {
  transform: translateX(4px);
}

.form-error {
  font-size: 0.82rem;
  color: var(--expense);
  margin-top: 0.5rem;
  min-height: 1.2em;
  text-align: center;
}

/* --- Donut Chart --- */
.chart-section h2 {
  margin-bottom: 1.25rem;
}

.chart-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.25rem;
}

#donutChart {
  display: block;
}

.donut-center {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.donut-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.donut-value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  padding: 0.3rem 0;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-name { color: var(--text-secondary); }

.legend-amount {
  font-weight: 600;
  color: var(--text-primary);
}

.chart-empty-state {
  text-align: center;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.chart-empty-state span {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.5rem;
}

/* --- Transaction List --- */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.filter-group {
  display: flex;
  gap: 0.4rem;
}

.filter-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: 100px;
  cursor: pointer;
  transition: var(--transition);
}

.filter-btn.active,
.filter-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--text-primary);
}

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

.empty-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.empty-sub {
  font-size: 0.82rem !important;
  color: var(--text-muted) !important;
  margin-top: 0.35rem;
}

/* --- Transaction Items --- */
.tx-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.tx-list::-webkit-scrollbar {
  width: 4px;
}
.tx-list::-webkit-scrollbar-track {
  background: transparent;
}
.tx-list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 100px;
}

.tx-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  transition: var(--transition);
  animation: slideIn 0.3s ease forwards;
  cursor: default;
}

.tx-item:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: translateX(4px);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.tx-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.tx-item.income .tx-icon {
  background: var(--income-dim);
}

.tx-item.expense .tx-icon {
  background: var(--expense-dim);
}

.tx-info {
  flex: 1;
  min-width: 0;
}

.tx-desc {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.tx-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.tx-amount {
  font-size: 0.9rem;
  font-weight: 700;
  text-align: right;
}

.tx-item.income .tx-amount { color: var(--income); }
.tx-item.expense .tx-amount { color: var(--expense); }

.tx-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.25rem;
  border-radius: 4px;
  transition: var(--transition);
  opacity: 0;
  line-height: 1;
}

.tx-item:hover .tx-delete {
  opacity: 1;
}

.tx-delete:hover {
  color: var(--expense);
  background: var(--expense-dim);
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(20, 24, 40, 0.95);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.5rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  backdrop-filter: blur(20px);
  z-index: 999;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: #12152a;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  transform: scale(0.92);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.show .modal {
  transform: scale(1);
}

.modal-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.modal-body {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.btn-cancel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.7rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-cancel:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.btn-confirm {
  background: var(--expense-dim);
  border: 1px solid var(--expense);
  border-radius: var(--radius-xs);
  color: var(--expense);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.7rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-confirm:hover {
  background: var(--expense);
  color: #fff;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .card-amount {
    font-size: 1.4rem;
  }

  .main {
    padding: 1.25rem 1rem 3rem;
  }

  .tx-delete {
    opacity: 1;
  }
}

@media (max-width: 480px) {
  .list-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
