/* ═══════════════════════════════════════════════════
   BILL TRACKER — style.css
   5 themes: dark | light | midnight | ocean | forest
═══════════════════════════════════════════════════ */

/* ── THEME TOKENS ── */
[data-theme="dark"] {
  --bg:         #0a0f1e;
  --bg2:        #111827;
  --bg3:        #1f2937;
  --border:     #2d3748;
  --text:       #f1f5f9;
  --text-muted: #94a3b8;
  --accent:     #6366f1;
  --accent-dim: #4338ca;
  --red:        #ef4444;
  --amber:      #f59e0b;
  --green:      #22c55e;
  --card-bg:    #111827;
  --meta-color: #0a0f1e;
}
[data-theme="light"] {
  --bg:         #f8fafc;
  --bg2:        #ffffff;
  --bg3:        #e2e8f0;
  --border:     #cbd5e1;
  --text:       #0f172a;
  --text-muted: #64748b;
  --accent:     #6366f1;
  --accent-dim: #4338ca;
  --red:        #dc2626;
  --amber:      #d97706;
  --green:      #16a34a;
  --card-bg:    #ffffff;
  --meta-color: #f8fafc;
}
[data-theme="midnight"] {
  --bg:         #020617;
  --bg2:        #0f172a;
  --bg3:        #1e293b;
  --border:     #334155;
  --text:       #e2e8f0;
  --text-muted: #7c8fa3;
  --accent:     #818cf8;
  --accent-dim: #6366f1;
  --red:        #f87171;
  --amber:      #fbbf24;
  --green:      #4ade80;
  --card-bg:    #0f172a;
  --meta-color: #020617;
}
[data-theme="ocean"] {
  --bg:         #042f4b;
  --bg2:        #063a5c;
  --bg3:        #0d4f7d;
  --border:     #1a6595;
  --text:       #e0f2fe;
  --text-muted: #7ecaed;
  --accent:     #38bdf8;
  --accent-dim: #0ea5e9;
  --red:        #fb7185;
  --amber:      #fcd34d;
  --green:      #34d399;
  --card-bg:    #063a5c;
  --meta-color: #042f4b;
}
[data-theme="forest"] {
  --bg:         #052e16;
  --bg2:        #064e3b;
  --bg3:        #065f46;
  --border:     #047857;
  --text:       #d1fae5;
  --text-muted: #6ee7b7;
  --accent:     #10b981;
  --accent-dim: #059669;
  --red:        #f87171;
  --amber:      #fcd34d;
  --green:      #34d399;
  --card-bg:    #064e3b;
  --meta-color: #052e16;
}

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background 0.25s, color 0.25s;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── HEADER ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-logo {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--accent);
}

/* ── NOTIFICATION BANNER ── */
.notif-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-dim);
  color: #fff;
  padding: 10px 16px;
  font-size: 0.85rem;
}
.notif-banner span { flex: 1; }

/* ── TAB BAR ── */
.tab-bar {
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
  overflow-x: auto;
  gap: 4px;
}
.tab-btn {
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
}
.tab-btn.active, .tab-btn:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── TAB PANELS ── */
.tab-panel {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  flex: 1;
}
.tab-panel.active { display: flex; }

/* ── SUMMARY CARDS ── */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.summary-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
}
.summary-card .card-label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.summary-card .card-value { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.summary-card.highlight-red .card-value { color: var(--red); }
.summary-card.highlight-amber .card-value { color: var(--amber); }

/* ── FILTER BAR ── */
.filter-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.filter-btn {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.filter-btn.active, .filter-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── BILL LIST ── */
.bill-list { display: flex; flex-direction: column; gap: 8px; }

.bill-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}
.bill-item.paid { opacity: 0.6; }
.bill-item.due-soon { border-left: 3px solid var(--amber); }
.bill-item.overdue { border-left: 3px solid var(--red); }

.bill-name { font-weight: 600; font-size: 0.95rem; }
.bill-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.bill-amount { font-size: 1.1rem; font-weight: 700; text-align: right; }
.bill-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; }

/* ── ACTION ROW ── */
.action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

/* ── PAYDAY GRID ── */
.payday-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── CARD ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 0.95rem; font-weight: 600; }
.card > div:not(.card-header) { padding: 14px 16px; }

/* ── INCOME / EVENT LIST ITEMS ── */
.income-item, .event-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.income-item:last-child, .event-item:last-child { border-bottom: none; }
.item-name { font-weight: 600; }
.item-sub { font-size: 0.75rem; color: var(--text-muted); }

/* ── COMPARISON GRID ── */
.comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.comparison-month {
  background: var(--bg3);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.comparison-month .month-label { font-size: 0.75rem; color: var(--text-muted); }
.comparison-month .month-value { font-weight: 700; font-size: 1rem; }

/* ── SUMMARY LIST ── */
.summary-list { display: flex; flex-direction: column; gap: 8px; }
.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.summary-row:last-child { border-bottom: none; }

/* ── HISTORY ── */
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.history-item:last-child { border-bottom: none; }

/* ── THEME PICKER ── */
.theme-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 16px;
}
.theme-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.theme-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── SETTINGS ── */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
}
.setting-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.about-block {
  padding: 14px 16px;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.about-block strong { color: var(--text); display: block; margin-bottom: 4px; }
.version { margin-top: 6px; font-size: 0.75rem; }

/* ── BUTTONS ── */
.btn-primary {
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-dim); }

.btn-ghost {
  padding: 10px 20px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

.btn-sm {
  padding: 6px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-sm:hover { background: var(--accent-dim); }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.2s;
}
.btn-icon:hover { color: var(--text); }

.btn-danger {
  padding: 5px 10px;
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
}
.btn-success {
  padding: 5px 10px;
  background: transparent;
  color: var(--green);
  border: 1px solid var(--green);
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
}
.btn-edit {
  padding: 5px 10px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
}

/* ── EMPTY STATE ── */
.empty-state {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 20px;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(4px);
}
@media (min-width: 600px) {
  .modal-overlay { align-items: center; padding: 16px; }
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 90dvh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}
@media (min-width: 600px) {
  .modal { border-radius: 20px; }
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg2);
  z-index: 5;
}
.modal-header h2 { font-size: 1.1rem; }
.modal-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-footer {
  padding: 14px 20px 24px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}
.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}
.modal-body input,
.modal-body select,
.modal-body textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.2s;
}
.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.modal-body textarea { resize: vertical; }
.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
  color: var(--text) !important;
  font-weight: 400 !important;
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 200;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  animation: fadeInOut 2.5s ease forwards;
}
@keyframes fadeInOut {
  0%   { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── UTILITY ── */
.hidden { display: none !important; }

/* ── AUTOPAY BADGE ── */
.badge {
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  margin-left: 6px;
}
.badge-autopay { background: var(--green); color: #000; }
.badge-onetime { background: var(--amber); color: #000; }

/* ── RESPONSIVE ── */
@media (min-width: 700px) {
  .payday-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .full-width { grid-column: 1 / -1; }
  .summary-cards { gap: 14px; }
}

/* ── iOS INSTALL BANNER ── */
.ios-install-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  font-size: 0.82rem;
  color: var(--text);
}
.ios-install-banner span { flex: 1; }
