/* style.css - CleanCount PWA */

:root {
  --bg: #ffffff;
  --surface: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #4b5563;
  --primary: #ea580c;
  --primary-light: #dbeafe;
  --danger: #dc2626;
  --income: #15803d;
  --expense: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --surface: #1f2937;
    --border: #374151;
    --text: #f9fafb;
    --text-muted: #d1d5db;
    --primary-light: #1e3a5f;
    --danger: #f87171;
    --income: #4ade80;
    --expense: #f87171;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 70px;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 480px; margin: 0 auto; padding: 0 1rem; }

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.5rem 0;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0));
  z-index: 100;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.65rem;
  cursor: pointer;
  padding: 0.25rem 0.75rem;
  gap: 0.15rem;
  transition: color 0.2s;
}
.nav-btn .nav-icon { font-size: 1.3rem; }
.nav-btn.active { color: var(--primary); }

.nav-btn.add-btn {
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -1rem;
  box-shadow: 0 2px 8px rgba(37,99,235,0.4);
}
.nav-btn.add-btn .nav-icon { font-size: 1.8rem; line-height: 1; }

/* Screen Title */
.screen-title {
  font-size: 1.25rem;
  font-weight: 700;
  padding: 1rem 0 0.5rem;
}

/* Month Selector */
.month-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
}
.month-selector h2 { font-size: 1.1rem; font-weight: 600; }
.month-nav {
  border: none;
  background: var(--surface);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Summary Cards */
.summary-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.summary-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.75rem;
  box-shadow: var(--shadow);
}
.card-label { font-size: 0.75rem; color: var(--text-muted); }
.card-value { font-size: 1.25rem; font-weight: 700; margin-top: 0.25rem; }
.card-value.expense { color: var(--expense); }
.card-value.income { color: var(--income); }
.card-sub { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.15rem; }

/* Card */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.75rem; }

/* Charts */
.donut-chart, .bar-chart { width: 100%; max-width: 280px; margin: 0 auto; display: block; }

/* Legend */
.legend-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.85rem;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-name { flex: 1; }
.legend-amount { font-weight: 600; }
.legend-pct { color: var(--text-muted); font-size: 0.75rem; width: 3rem; text-align: right; }

/* Budget Envelopes */
.envelope { margin-bottom: 0.75rem; }
.envelope-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}
.envelope-cat { font-weight: 500; }
.envelope-amounts { color: var(--text-muted); }
.progress-bar-bg {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.progress-green { background: #22c55e; }
.progress-yellow { background: #eab308; }
.progress-red { background: #ef4444; }
.envelope-remaining { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }

/* Amount Display */
.amount-display {
  font-size: 2.5rem;
  font-weight: 700;
  text-align: center;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  min-height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Numpad */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.numpad-btn {
  padding: 0.9rem;
  font-size: 1.25rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.numpad-btn:active { background: var(--primary-light); }

/* Type Toggle */
.type-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}
.toggle {
  position: relative;
  width: 48px;
  height: 26px;
  display: inline-block;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--expense);
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.3s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--income); }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); }

/* Category Grid */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.cat-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.6rem 0.3rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  font-size: 0.7rem;
}
.cat-btn .cat-icon { font-size: 1.5rem; }
.cat-btn .cat-name { font-size: 0.65rem; text-align: center; line-height: 1.2; }
.cat-btn.selected {
  border-color: var(--cat-color, var(--primary));
  background: var(--primary-light);
}

/* Form Fields */
.field-label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.25rem; margin-top: 0.75rem; }
.field-input {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

/* Buttons */
.save-btn {
  width: 100%;
  padding: 0.85rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0.5rem;
}
.delete-btn, .danger {
  width: 100%;
  padding: 0.75rem;
  background: none;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
}
.small-btn {
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.search-input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
}
.filter-select {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
}

/* Transaction List */
.date-group { margin-bottom: 0.75rem; }
.date-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.5rem 0 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tx-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 0.4rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.tx-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.tx-info { flex: 1; min-width: 0; }
.tx-note { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-cat { font-size: 0.7rem; color: var(--text-muted); }
.tx-amount { font-weight: 700; font-size: 0.9rem; white-space: nowrap; }
.tx-amount.income { color: var(--income); }
.tx-amount.expense { color: var(--expense); }
.tx-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
}
.tx-delete:hover { color: var(--danger); }

/* Settings */
.budget-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.budget-cat { flex: 1; font-size: 0.85rem; }
.budget-input {
  width: 80px;
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  text-align: right;
}
.settings-actions { display: flex; flex-direction: column; gap: 0.5rem; }
.settings-btn {
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
}
.settings-btn.danger { border-color: var(--danger); color: var(--danger); }
.custom-cat-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.85rem;
}
.del-cat-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--danger);
  font-size: 1.1rem;
  cursor: pointer;
}
.add-cat-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  align-items: center;
}
.add-cat-form .field-input { margin-top: 0; }
.color-input { width: 44px !important; padding: 0.2rem !important; height: 36px; }

/* Reports */
.top-categories { margin-top: 0.5rem; }
.top-cat-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.85rem;
}
.top-rank { font-weight: 700; color: var(--text-muted); width: 1.5rem; }
.big-number { font-size: 2rem; font-weight: 700; text-align: center; padding: 1rem 0; }

/* Utility */
.muted { color: var(--text-muted); font-size: 0.85rem; }
.loading { text-align: center; padding: 2rem; color: var(--text-muted); }
.about p { font-size: 0.85rem; margin-bottom: 0.25rem; }

/* App Header with Pro Badge */
.app-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 0 0;
}
.app-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* PRO Badge */
.pro-badge {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  vertical-align: middle;
}

/* Premium Modal Overlay */
.premium-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.premium-modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 360px;
  width: 100%;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  text-align: center;
}

.premium-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.premium-modal-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}

.premium-modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.premium-modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.premium-feature-list {
  list-style: none;
  text-align: left;
  margin: 0 0 1rem 0;
  padding: 0;
}

.premium-feature-item {
  font-size: 0.85rem;
  padding: 0.3rem 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.premium-check {
  color: var(--income);
  font-weight: 700;
  flex-shrink: 0;
}

/* Buy Button */
.premium-buy-btn {
  width: 100%;
  padding: 0.8rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 0.5rem;
  transition: background 0.2s;
}
.premium-buy-btn:active { background: #1d4ed8; }

.premium-onetime {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.premium-restore-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.25rem;
}

/* Blurred Preview for Gated Screens */
.premium-teaser-wrapper {
  position: relative;
}

.premium-blur-content {
  filter: blur(3px);
  opacity: 0.6;
  pointer-events: none;
  user-select: none;
}

.premium-gate-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.premium-gate-content {
  background: var(--surface);
  border-radius: 16px;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  max-width: 300px;
  width: 90%;
}

.premium-gate-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.premium-gate-content h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.premium-gate-content p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* Premium blur class for general use */
.premium-blur {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

/* Settings premium card */
.premium-settings-card .settings-actions {
  align-items: center;
}

/* Responsive */
@media (max-width: 380px) {
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .summary-cards { grid-template-columns: 1fr; }
}

@media (min-width: 481px) {
  #app { padding: 0 2rem; }
}
