/* SpenderBender — Premium Dark UI */

/* === Tokens === */
:root {
  --bg-deep: #0a0a1a;
  --bg-surface: #12122a;
  --bg-card: #1a1a3e;
  --bg-input: #1e1e45;
  --bg-hover: #25255a;

  --text-primary: #f0f0ff;
  --text-secondary: #8888bb;
  --text-muted: #555588;

  --accent: #7c5cfc;
  --accent-glow: rgba(124, 92, 252, 0.35);
  --accent-bright: #a78bfa;

  --green: #34d399;
  --green-glow: rgba(52, 211, 153, 0.2);
  --amber: #fbbf24;
  --amber-glow: rgba(251, 191, 36, 0.2);
  --red: #f87171;
  --red-glow: rgba(248, 113, 113, 0.2);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 30px var(--accent-glow);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === Screens === */
.screen {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 0 16px;
}

/* === Setup Screen === */
.setup-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 32px 0;
  text-align: center;
}

.setup-logo {
  font-size: 64px;
  margin-bottom: 12px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.app-title {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.title-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 6px;
  margin-bottom: 36px;
}

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

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

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

.currency-presets {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.currency-btn {
  flex: 1;
  padding: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  border: 2px solid var(--bg-hover);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.currency-btn.active {
  border-color: var(--accent);
  background: rgba(124, 92, 252, 0.15);
  color: var(--accent-bright);
  box-shadow: 0 0 12px var(--accent-glow);
}

.currency-btn:hover:not(.active) {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.input-field {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.2s var(--ease-out);
}

.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

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

.currency-input {
  max-width: 80px;
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.budget-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.budget-currency-label {
  position: absolute;
  left: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
}

.budget-input {
  padding-left: 36px;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.btn-glow {
  background: linear-gradient(135deg, var(--accent), #6c4ce0);
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.btn-glow:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 40px var(--accent-glow);
}

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

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 2px solid var(--bg-hover);
}

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

.btn-large {
  width: 100%;
  padding: 16px 24px;
  font-size: 1.1rem;
  border-radius: var(--radius-md);
  margin-top: 8px;
}

/* === Dashboard === */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 8px;
}

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

.btn-icon {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-full);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s var(--ease-out);
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* === Allowance Hero (Progress Ring) === */
.allowance-hero {
  display: flex;
  justify-content: center;
  padding: 16px 0 20px;
}

.progress-ring-container {
  position: relative;
  width: 200px;
  height: 200px;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: var(--bg-card);
  stroke-width: 10;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--green);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 553;
  stroke-dashoffset: 553;
  transition: stroke-dashoffset 0.8s var(--ease-out), stroke 0.4s ease;
  filter: drop-shadow(0 0 8px var(--green-glow));
}

.progress-ring-fill.color-green {
  stroke: var(--green);
  filter: drop-shadow(0 0 8px var(--green-glow));
}

.progress-ring-fill.color-amber {
  stroke: var(--amber);
  filter: drop-shadow(0 0 8px var(--amber-glow));
}

.progress-ring-fill.color-red {
  stroke: var(--red);
  filter: drop-shadow(0 0 8px var(--red-glow));
}

.allowance-inner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.allowance-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.allowance-amount {
  display: flex;
  align-items: baseline;
  gap: 2px;
  transition: color 0.4s ease;
}

.allowance-amount.color-green { color: var(--green); }
.allowance-amount.color-amber { color: var(--amber); }
.allowance-amount.color-red { color: var(--red); }

.allowance-currency {
  font-size: 1.3rem;
  font-weight: 700;
}

.allowance-number {
  font-family: var(--font-mono);
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1;
}

.over-budget-msg {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--red);
  margin-top: 4px;
  text-align: center;
}

/* === Stats Row === */
.stats-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.stat-card {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.stat-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* === Numpad === */
.numpad-section {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  margin-bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.numpad-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  padding: 8px 0 16px;
}

.numpad-currency {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-muted);
}

.numpad-value {
  font-family: var(--font-mono);
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  min-width: 60px;
  text-align: center;
  transition: color 0.15s ease;
}

.numpad-value.has-value {
  color: #fff;
}

.expense-desc-input {
  margin-bottom: 8px;
  background: var(--bg-card);
  font-size: 0.9rem;
  text-align: center;
}

.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.numpad-key {
  position: relative;
  height: 52px;
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s var(--ease-out);
  user-select: none;
  -webkit-user-select: none;
}

.numpad-key:active {
  transform: scale(0.93);
  background: var(--bg-hover);
}

.numpad-back {
  color: var(--text-secondary);
}

.numpad-back:active {
  color: var(--red);
}

.numpad-confirm {
  grid-column: span 3;
  height: 52px;
  background: linear-gradient(135deg, var(--accent), #6c4ce0);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-glow);
  transition: all 0.2s var(--ease-out);
}

.numpad-confirm:active {
  transform: scale(0.97);
  box-shadow: 0 0 50px var(--accent-glow);
}

.numpad-confirm.flash-green {
  background: var(--green) !important;
  box-shadow: 0 0 30px var(--green-glow) !important;
}

/* === Messages === */
.error-msg {
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 8px;
  text-align: center;
}

.success-msg {
  color: var(--green);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 8px;
  text-align: center;
  animation: fadeInUp 0.3s var(--ease-out);
}

.warning-msg {
  color: var(--amber);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 8px;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Expense History === */
.expense-history {
  padding-bottom: 32px;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.expense-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 32px 0;
}

.expense-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  animation: slideIn 0.25s var(--ease-out);
  border: 1px solid rgba(255, 255, 255, 0.03);
}

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

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

.expense-item-amount {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.expense-item-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-item-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.btn-delete {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  opacity: 0.4;
  transition: all 0.2s ease;
  filter: grayscale(1);
}

.btn-delete:hover {
  opacity: 1;
  filter: grayscale(0);
  transform: scale(1.1);
}

/* === Loading === */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 26, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

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

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

/* === Error Overlay === */
.error-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 26, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 200;
}

.error-overlay p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  text-align: center;
  max-width: 280px;
}

/* === Modal === */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 26, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-soft);
}

.modal-content h2 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions .btn {
  flex: 1;
}

/* === Number input arrows removal === */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* === Responsive === */
@media (max-width: 380px) {
  .stats-row {
    gap: 6px;
  }
  .stat-card {
    padding: 10px 4px;
  }
  .stat-value {
    font-size: 0.85rem;
  }
  .numpad-key {
    height: 46px;
    font-size: 1.2rem;
  }
}

@media (min-width: 768px) {
  .screen {
    max-width: 440px;
  }
}
