/* FinanceApp - Mobile-First CSS */

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f1f5f9;
  overscroll-behavior: none;
}

#app {
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  background: #f1f5f9;
  position: relative;
}

/* ── HEADER ── */
.app-header {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  padding: 20px 20px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(99,102,241,0.3);
}

.app-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
}

.app-header .subtitle {
  font-size: 13px;
  opacity: 0.8;
  margin-bottom: 16px;
}

/* ── MONTH SELECTOR ── */
.month-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.month-tabs::-webkit-scrollbar { display: none; }

.month-tab {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 20px 20px 0 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
  border: none;
  transition: all 0.2s;
}
.month-tab.active {
  background: #f1f5f9;
  color: #6366f1;
}

/* ── MAIN CONTENT ── */
.main-content {
  padding: 16px;
  padding-bottom: 100px;
}

/* ── SUMMARY CARDS ── */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card {
  background: white;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.summary-card.full-width {
  grid-column: 1 / -1;
}
.summary-card .label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
  margin-bottom: 4px;
}
.summary-card .value {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
}
.summary-card .value.income { color: #10b981; }
.summary-card .value.expense { color: #ef4444; }
.summary-card .value.positive { color: #10b981; }
.summary-card .value.negative { color: #ef4444; }
.summary-card .icon {
  font-size: 24px;
  margin-bottom: 8px;
}

/* ── SECTION ── */
.section {
  background: white;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
}

/* ── TRANSACTION ITEM ── */
.tx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.15s;
}
.tx-item:last-child { border-bottom: none; }
.tx-item:active { background: #f8fafc; border-radius: 8px; }

.tx-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.tx-info { flex: 1; min-width: 0; }
.tx-desc {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-cat {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}
.tx-amount {
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}
.tx-amount.income { color: #10b981; }
.tx-amount.expense { color: #ef4444; }

/* ── CATEGORY BAR ── */
.cat-bar-item {
  margin-bottom: 12px;
}
.cat-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.cat-bar-label {
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cat-bar-value {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
}
.cat-bar-track {
  height: 8px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
}
.cat-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s ease;
}

/* ── FAB BUTTON ── */
.fab-container {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 200;
}
.fab {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border: none;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(99,102,241,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}
.fab:active { transform: scale(0.92); }

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: white;
  display: flex;
  border-top: 1px solid #e2e8f0;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  gap: 4px;
  cursor: pointer;
  border: none;
  background: none;
  transition: all 0.2s;
  text-decoration: none;
}
.nav-item i {
  font-size: 20px;
  color: #94a3b8;
  transition: color 0.2s;
}
.nav-item span {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.nav-item.active i { color: #6366f1; }
.nav-item.active span { color: #6366f1; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-sheet {
  background: white;
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  margin: 12px auto 0;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
}
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f1f5f9;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-body {
  padding: 20px;
}

/* ── FORM ELEMENTS ── */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 15px;
  color: #1e293b;
  background: #f8fafc;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: #6366f1;
  background: white;
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}
.form-textarea {
  resize: none;
  height: 80px;
}

/* ── TYPE TOGGLE ── */
.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.type-btn {
  padding: 12px;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  background: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.type-btn.income.active {
  border-color: #10b981;
  background: #ecfdf5;
  color: #10b981;
}
.type-btn.expense.active {
  border-color: #ef4444;
  background: #fef2f2;
  color: #ef4444;
}
.type-btn:not(.active) { color: #94a3b8; }

/* ── SUBMIT BUTTON ── */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.btn-primary:active { transform: scale(0.98); opacity: 0.9; }

.btn-danger {
  padding: 8px 16px;
  background: #fef2f2;
  color: #ef4444;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  padding: 8px 16px;
  background: #f1f5f9;
  color: #475569;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* ── CHART CONTAINER ── */
.chart-container {
  position: relative;
  height: 200px;
  width: 100%;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #94a3b8;
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ── TOAST ── */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease;
  white-space: nowrap;
}
.toast.success { background: #10b981; }
.toast.error { background: #ef4444; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── BUDGET PROGRESS ── */
.budget-item {
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}
.budget-item:last-child { border-bottom: none; }
.budget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.budget-label { font-size: 14px; font-weight: 600; color: #1e293b; }
.budget-amounts { font-size: 12px; color: #94a3b8; }
.budget-bar { height: 8px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.budget-fill { height: 100%; border-radius: 4px; transition: width 0.6s; }
.budget-fill.ok { background: #10b981; }
.budget-fill.warn { background: #f59e0b; }
.budget-fill.over { background: #ef4444; }

/* ── SCROLLABLE TABS ── */
.tab-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 16px 12px;
  scrollbar-width: none;
  margin: 0 -16px;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-pill {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #f1f5f9;
  color: #64748b;
  border: none;
  transition: all 0.2s;
}
.tab-pill.active {
  background: #6366f1;
  color: white;
}

/* ── PAGE TRANSITIONS ── */
.page { animation: pageIn 0.25s ease; }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── SWIPE DELETE ── */
.tx-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-right: 4px;
}

/* ── LOADING ── */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ── CATEGORY CHIPS ── */
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.category-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
}
.category-chip.selected {
  border-color: #6366f1;
  background: #eef2ff;
}
.category-chip .emoji { font-size: 22px; }
.category-chip .cat-name { font-size: 11px; font-weight: 600; color: #475569; text-align: center; }

/* ── AMOUNT INPUT ── */
.amount-display {
  text-align: center;
  padding: 20px 0 10px;
}
.amount-big {
  font-size: 42px;
  font-weight: 800;
  color: #1e293b;
  letter-spacing: -2px;
}
.amount-big.income { color: #10b981; }
.amount-big.expense { color: #ef4444; }

/* ── STATS ── */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}
.stat-row:last-child { border-bottom: none; }
.stat-label { font-size: 14px; color: #64748b; }
.stat-value { font-size: 14px; font-weight: 700; color: #1e293b; }

/* ── BADGE ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge.income { background: #ecfdf5; color: #10b981; }
.badge.expense { background: #fef2f2; color: #ef4444; }

@media (min-width: 480px) {
  #app { box-shadow: 0 0 40px rgba(0,0,0,0.1); }
  .bottom-nav, .fab-container { max-width: 480px; }
}
