/* BON - Mobile-first minimal budget tracker */

:root {
  --bg: #0f0f0f;
  --bg-card: #1a1a1a;
  --bg-input: #252525;
  --text: #f5f5f5;
  --text-muted: #888;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #333;
  --radius: 12px;
  --radius-sm: 8px;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Layout ───────────────────────────────────────────────────────────────── */

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 80px; /* Space for nav */
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.header h1 {
  font-size: 24px;
  font-weight: 700;
}

.period-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Cards ────────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-title {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── Budget Progress ──────────────────────────────────────────────────────── */

.budget-total {
  text-align: center;
  padding: 24px 16px;
  margin-bottom: 16px;
}

.budget-amount {
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
}

.budget-amount.positive { color: var(--success); }
.budget-amount.warning { color: var(--warning); }
.budget-amount.negative { color: var(--danger); }

.budget-label {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 8px;
}

.category-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.category-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.category-icon {
  font-size: 20px;
}

.category-amounts {
  text-align: right;
  font-size: 14px;
}

.category-spent {
  font-weight: 600;
}

.category-budget {
  color: var(--text-muted);
  font-size: 12px;
}

.progress-bar {
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-fill.ok { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.over { background: var(--danger); }

/* ─── Expense List ─────────────────────────────────────────────────────────── */

.expense-list {
  list-style: none;
}

.expense-item {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.expense-item:last-child {
  border-bottom: none;
}

.expense-icon {
  font-size: 24px;
  width: 40px;
  text-align: center;
}

.expense-details {
  flex: 1;
  min-width: 0;
}

.expense-desc {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.expense-amount {
  font-weight: 600;
  font-size: 16px;
}

/* ─── Forms ────────────────────────────────────────────────────────────────── */

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

.form-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--accent);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.amount-input {
  font-size: 32px;
  font-weight: 700;
  text-align: center;
  padding: 20px;
}

/* ─── Category Buttons ─────────────────────────────────────────────────────── */

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.category-btn {
  background: var(--bg-input);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.category-btn:hover {
  background: var(--bg-card);
}

.category-btn.selected {
  border-color: var(--accent);
  background: var(--bg-card);
}

.category-btn .icon {
  font-size: 28px;
  display: block;
  margin-bottom: 6px;
}

.category-btn .name {
  font-size: 13px;
  font-weight: 500;
}

/* ─── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

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

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
}

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

.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
}

/* ─── FAB (Floating Action Button) ─────────────────────────────────────────── */

.fab {
  position: fixed;
  bottom: 88px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

/* ─── Bottom Navigation ────────────────────────────────────────────────────── */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 99;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  gap: 4px;
  transition: color 0.2s;
}

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

.nav-item svg {
  width: 24px;
  height: 24px;
}

/* ─── Login Page ───────────────────────────────────────────────────────────── */

.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-logo {
  font-size: 48px;
  margin-bottom: 8px;
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 32px;
}

.login-form {
  width: 100%;
  max-width: 320px;
}

.login-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  text-align: center;
  display: none;
}

.login-error.show {
  display: block;
}

/* ─── Receipt Upload ───────────────────────────────────────────────────────── */

.receipt-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.receipt-upload:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.05);
}

.receipt-upload.has-file {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.05);
}

.receipt-upload input {
  display: none;
}

.receipt-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.receipt-text {
  color: var(--text-muted);
  font-size: 14px;
}

.receipt-preview {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

/* ─── Stats Page ───────────────────────────────────────────────────────────── */

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin-bottom: 12px;
}

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

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.chart-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.chart-title {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ─── Swipe to delete ──────────────────────────────────────────────────────── */

.swipe-container {
  position: relative;
  overflow: hidden;
}

.swipe-action {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  background: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transform: translateX(100%);
  transition: transform 0.2s;
}

/* ─── Utilities ────────────────────────────────────────────────────────────── */

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ─── Loading ──────────────────────────────────────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Empty State ──────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ─── Toggle ───────────────────────────────────────────────────────────────── */

.toggle-group {
  display: flex;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.toggle-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: var(--accent);
  color: white;
}

/* ─── Modal ────────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

.modal-body {
  padding: 16px;
}

/* ─── Settings ─────────────────────────────────────────────────────────────── */

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.settings-label {
  font-weight: 500;
}

.settings-value {
  color: var(--text-muted);
}
