/*
Theme Name:  Spendly
Theme URI:   https://yoursite.com/spendly
Author:      Spendly
Author URI:  https://yoursite.com
Description: A personal daily expense tracker WordPress theme built with Ghanaian Cedis (₵). Track expenses, income, budgets and analytics — all stored locally in the browser. No plugin required.
Version:     1.0.0
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 8.0
License:     GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: spendly
Tags:        finance, expense-tracker, budgeting, personal-finance, one-column, full-width-template
*/

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

:root {
  --bg:       #F8F7F4;
  --surface:  #FFFFFF;
  --surface2: #F1F0ED;
  --border:   #E8E6E1;
  --text:     #1A1917;
  --muted:    #9CA3AF;
  --accent:   #6366F1;
  --green:    #22C55E;
  --red:      #EF4444;
  --amber:    #F59E0B;
  --radius:   16px;
  --shadow:   0 4px 24px rgba(0,0,0,0.06);
}

body.dark {
  --bg:       #0F1117;
  --surface:  #1A1D27;
  --surface2: #242737;
  --border:   #2D3148;
  --text:     #E8E6E1;
  --muted:    #6B7280;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
  overflow-x: hidden;
}

/* Hide default WP admin bar interference */
#wpadminbar { position: fixed !important; }
body.admin-bar #spendly-app { padding-top: 32px; }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #6366F133; border-radius: 4px; }

.serif { font-family: 'DM Serif Display', serif; }
.hidden { display: none !important; }

/* ── Header ─────────────────────────────────────────────────────── */
#spendly-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

body.admin-bar #spendly-header { top: 32px; }

.header-brand { display: flex; align-items: center; gap: 10px; }

.brand-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.brand-name {
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
  letter-spacing: -0.3px;
}

.header-actions { display: flex; gap: 8px; }

.icon-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.icon-btn:hover { opacity: 0.75; }

/* ── Nav ─────────────────────────────────────────────────────────── */
#spendly-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  overflow-x: auto;
  padding: 0 16px;
  scrollbar-width: none;
}
#spendly-nav::-webkit-scrollbar { display: none; }

.nav-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 400;
  padding: 14px 14px;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s, border-color 0.2s;
  opacity: 0.7;
}
.nav-btn:hover { opacity: 1; }
.nav-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
  opacity: 1;
}
.nav-icon { font-size: 15px; }

/* ── Main ────────────────────────────────────────────────────────── */
#spendly-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 110px;
  animation: fadeIn 0.3s ease;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
}

.card-hover { transition: transform 0.2s, box-shadow 0.2s; cursor: default; }
.card-hover:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(99,102,241,0.1); }

/* ── Balance Hero ────────────────────────────────────────────────── */
.balance-hero {
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 60%, #A78BFA 100%);
  border-radius: var(--radius);
  border: none;
  padding: 28px 24px;
  color: #fff;
  margin-bottom: 20px;
}

.balance-label { font-size: 12px; font-weight: 500; opacity: 0.8; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 6px; }
.balance-amount { font-family: 'DM Serif Display', serif; font-size: 42px; letter-spacing: -1px; margin-bottom: 16px; word-break: break-all; }
.balance-stats { display: flex; gap: 24px; flex-wrap: wrap; }
.balance-stat-label { font-size: 10px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.06em; }
.balance-stat-value { font-size: 16px; font-weight: 600; margin-top: 2px; }

/* ── Quick Stats Grid ─────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { padding: 16px; }
.stat-header { display: flex; justify-content: space-between; align-items: flex-start; }
.stat-label { font-size: 11px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-icon { font-size: 16px; }
.stat-value { font-size: 20px; font-weight: 700; margin-top: 8px; }

/* ── Charts ──────────────────────────────────────────────────────── */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 560px) { .charts-row { grid-template-columns: 1fr; } }

.section-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 12px; }

.pie-container { display: flex; gap: 12px; align-items: center; }
.pie-legend { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-name { font-size: 11px; color: var(--muted); flex: 1; }
.legend-val { font-size: 11px; font-weight: 600; }

.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 80px; padding: 0 4px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.bar-fill { width: 100%; border-radius: 4px; background: linear-gradient(180deg, #6366F1cc, #6366F166); min-height: 4px; transition: height 0.5s ease; }
.bar-label { font-size: 9px; opacity: 0.6; white-space: nowrap; }

/* ── Transactions ─────────────────────────────────────────────────── */
.tx-item { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 10px; transition: background 0.15s; }
.tx-item:hover { background: var(--surface2); }
.tx-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.tx-info { flex: 1; min-width: 0; }
.tx-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.tx-amount { font-weight: 700; color: var(--red); font-size: 15px; flex-shrink: 0; }
.tx-delete { background: none; border: none; color: var(--muted); font-size: 14px; padding: 4px 6px; border-radius: 6px; cursor: pointer; line-height: 1; transition: color 0.15s; }
.tx-delete:hover { color: var(--red); }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-count { font-size: 12px; color: var(--accent); }

/* ── Filter Bar ──────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 13px; }
.filter-bar input { flex: 2; min-width: 160px; }
.filter-bar select { flex: 1; min-width: 130px; }

.export-btn { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: opacity 0.2s; }
.export-btn:hover { opacity: 0.75; }

.tx-list-header { display: flex; justify-content: space-between; padding: 8px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.tx-total-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.tx-total-val { font-size: 12px; font-weight: 600; color: var(--red); }

/* ── Analytics ───────────────────────────────────────────────────── */
.analytics-top { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 480px) { .analytics-top { grid-template-columns: 1fr; } }
.analytics-hero-val { font-family: 'DM Serif Display', serif; font-size: 28px; margin: 8px 0; }
.analytics-delta { font-size: 12px; margin-top: 4px; }
.delta-up { color: var(--red); }
.delta-down { color: var(--green); }
.cat-breakdown { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.cat-bars { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 180px; }
.cat-bar-info { display: flex; justify-content: space-between; margin-bottom: 3px; }
.cat-bar-name { font-size: 12px; }
.cat-bar-pct { font-size: 12px; font-weight: 600; }
.cat-bar-track { height: 5px; border-radius: 3px; background: var(--surface2); }
.cat-bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.insights { display: flex; flex-direction: column; gap: 10px; }
.insight-item { border-radius: 0 8px 8px 0; padding: 10px 14px; font-size: 13px; border-left-width: 3px; border-left-style: solid; }
.insight-daily { background: var(--surface2); border-radius: 8px; padding: 10px 14px; font-size: 13px; }

/* ── Budgets ─────────────────────────────────────────────────────── */
.budget-hint { font-size: 13px; color: var(--muted); }
.budget-item { padding: 16px; }
.budget-row { display: flex; align-items: center; gap: 10px; }
.budget-icon { font-size: 20px; }
.budget-info { flex: 1; }
.budget-name { font-weight: 600; font-size: 14px; }
.budget-spent-label { font-size: 12px; color: var(--muted); }
.budget-over { color: var(--red) !important; }
.budget-edit-group { display: flex; gap: 6px; align-items: center; }
.budget-edit-group input { width: 90px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 13px; }
.btn-save { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
.btn-cancel { background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px 8px; font-size: 12px; cursor: pointer; }
.btn-edit { background: var(--surface2); border: 1px solid var(--border); color: var(--muted); border-radius: 8px; padding: 6px 12px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.budget-track-wrap { margin-top: 10px; height: 7px; border-radius: 4px; background: var(--surface2); overflow: hidden; }
.budget-track-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease, background 0.3s; }

/* ── FABs ────────────────────────────────────────────────────────── */
#spendly-fabs { position: fixed; bottom: 28px; right: 24px; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; z-index: 200; }

.fab-income { background: var(--green); color: #fff; border: none; border-radius: 14px; padding: 10px 16px; font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: 0 4px 16px rgba(34,197,94,0.3); transition: transform 0.2s, box-shadow 0.2s; }
.fab-income:hover { transform: scale(1.06); box-shadow: 0 8px 24px rgba(34,197,94,0.4); }

.fab-main { background: linear-gradient(135deg, #6366F1, #8B5CF6); color: #fff; border: none; border-radius: 16px; width: 58px; height: 58px; font-size: 28px; font-weight: 300; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 20px rgba(99,102,241,0.4); transition: transform 0.2s, box-shadow 0.2s; }
.fab-main:hover { transform: scale(1.08); box-shadow: 0 8px 28px rgba(99,102,241,0.5); }

/* ── Modal ───────────────────────────────────────────────────────── */
#spendly-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 0.2s ease;
}

#spendly-modal-sheet {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 36px;
  width: 100%; max-width: 520px;
  animation: slideUp 0.3s ease;
  max-height: 92vh; overflow-y: auto;
}

#spendly-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
#spendly-modal-title { font-family: 'DM Serif Display', serif; font-size: 22px; }

.modal-close-btn { background: var(--surface2); border: none; color: var(--muted); border-radius: 50%; width: 30px; height: 30px; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; display: block; margin-bottom: 6px; }
.form-input, .form-select { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 14px; outline: none; transition: border-color 0.2s; }
.form-input:focus, .form-select:focus { border-color: var(--accent); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.category-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.cat-pill { background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 20px; padding: 5px 12px; font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.18s; }
.cat-pill:hover { opacity: 0.85; }
.cat-pill.active { color: #fff; border-color: transparent; }
.form-btn-row { display: flex; gap: 10px; margin-top: 18px; }
.btn-cancel-form { flex: 1; background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-submit-expense { flex: 2; background: linear-gradient(135deg, #6366F1, #8B5CF6); border: none; border-radius: 12px; padding: 12px; color: #fff; font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 700; cursor: pointer; }
.btn-submit-expense:hover { opacity: 0.9; }
.btn-submit-income { flex: 2; background: var(--green); border: none; border-radius: 12px; padding: 12px; color: #fff; font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 700; cursor: pointer; }
.btn-submit-income:hover { opacity: 0.9; }
.btn-submit-settings { width: 100%; background: linear-gradient(135deg, #6366F1, #8B5CF6); border: none; border-radius: 12px; padding: 12px; color: #fff; font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 700; cursor: pointer; }
.settings-data-section { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 4px; }
.settings-data-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.settings-data-info { font-size: 12px; color: var(--muted); }

/* ── Toast ───────────────────────────────────────────────────────── */
#spendly-toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  color: #fff; border-radius: 12px; padding: 10px 20px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 999; animation: slideIn 0.3s ease;
  display: flex; align-items: center; gap: 12px;
  max-width: 90vw; white-space: nowrap;
}
#spendly-toast.success { background: #22C55E; }
#spendly-toast.warn    { background: #F59E0B; }
#spendly-toast.undo    { background: #374151; }
.toast-undo-btn { background: rgba(255,255,255,0.25); border: none; color: #fff; border-radius: 8px; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: 'DM Sans', sans-serif; }

/* ── Utilities ───────────────────────────────────────────────────── */
.empty-state { color: var(--muted); font-size: 13px; text-align: center; padding: 28px 0; }
.flex-col { display: flex; flex-direction: column; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }

/* ── Animations ──────────────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(-50%) translateY(12px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes viewIn  { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.view-anim { animation: viewIn 0.3s ease; }

/* ── WP Widget areas (footer) ────────────────────────────────────── */
#spendly-wp-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
#spendly-wp-footer a { color: var(--accent); text-decoration: none; }

/* ── Custom Categories ────────────────────────────────────────────── */
.new-cat-form { display: flex; flex-direction: column; gap: 14px; }

.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  max-height: 120px;
  overflow-y: auto;
  padding: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.emoji-btn {
  background: none;
  border: 2px solid transparent;
  border-radius: 8px;
  font-size: 20px;
  width: 36px; height: 36px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1;
}
.emoji-btn:hover  { background: var(--border); }
.emoji-btn.active { border-color: var(--accent); background: var(--accent)22; }

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.color-swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  outline: none;
}
.color-swatch:hover  { transform: scale(1.15); }
.color-swatch.active { border-color: var(--text); transform: scale(1.15); }

.cat-row { cursor: default; }

/* ── Sync indicator spin ──────────────────────────────────────────── */
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
#syncIndicator:not(:empty) { display: inline-block; animation: spin 1s linear infinite; }

/* ── Login screen ────────────────────────────────────────────────── */
.login-prompt { max-width: 480px; margin: 40px auto; }
