/* ============================================================
   FINANÇAS PESSOAIS — CSS COMPLETO COM DARK MODE
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== VARIÁVEIS DE TEMA ===== */
:root[data-theme="light"] {
  --bg-body:        #f0f2f5;
  --bg-card:        #ffffff;
  --bg-item:        #f8f9fa;
  --text-primary:   #333333;
  --text-secondary: #666666;
  --text-muted:     #888888;
  --text-heading:   #2c3e50;
  --border:         #dddddd;
  --shadow:         rgba(0,0,0,0.07);
  --chart-bg:       #f8f9fa;
  --input-bg:       #ffffff;
  --modal-bg:       rgba(0,0,0,0.5);
}

:root[data-theme="dark"] {
  --bg-body:        #1a1a2e;
  --bg-card:        #16213e;
  --bg-item:        #0f3460;
  --text-primary:   #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-muted:     #888888;
  --text-heading:   #e8e8e8;
  --border:         #2a2a4a;
  --shadow:         rgba(0,0,0,0.3);
  --chart-bg:       #0f3460;
  --input-bg:       #1a1a3e;
  --modal-bg:       rgba(0,0,0,0.7);
}

body {
  font-family: 'Segoe UI', sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  transition: background 0.3s, color 0.3s;
}

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

/* ===== HEADER ===== */
header {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 24px;
  position: relative;
}

header h1 {
  font-size: 1.8rem;
  color: var(--text-heading);
}

.btn-theme {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-theme:hover {
  transform: rotate(20deg) scale(1.1);
  border-color: #f39c12;
}

/* ===== HEADER ACTIONS ===== */
.header-actions {
  position: absolute;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.btn-logout {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-logout:hover {
  border-color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
}

/* ===== TOAST / NOTIFICAÇÕES ===== */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 4px 20px var(--shadow);
  font-size: 0.9rem;
  opacity: 0;
  transform: translateX(100px);
  transition: all 0.4s ease;
  pointer-events: auto;
  max-width: 360px;
  border-left: 4px solid #aaa;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-success { border-left-color: #27ae60; }
.toast-warning { border-left-color: #f39c12; }
.toast-error   { border-left-color: #e74c3c; }
.toast-info    { border-left-color: #2980b9; }

/* ===== NAVEGAÇÃO POR MÊS ===== */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
  background: var(--bg-card);
  padding: 14px 20px;
  border-radius: 12px;
  box-shadow: 0 2px 8px var(--shadow);
}

.month-nav button {
  background: #2c3e50;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.month-nav button:hover { background: #1a252f; }

.month-nav .btn-all {
  background: #7f8c8d;
  font-size: 0.85rem;
  padding: 6px 12px;
}

.month-nav .btn-all:hover { background: #636e72; }

#current-month-label {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--text-heading);
  min-width: 180px;
  text-align: center;
}

/* ===== SALDO INICIAL DO MÊS ===== */
.opening-balance-section {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px var(--shadow);
  border-left: 4px solid #f39c12;
}

.opening-balance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.opening-balance-header h2 { margin-bottom: 0; font-size: 1rem; }

.opening-value { font-size: 1.3rem; font-weight: bold; }
.opening-value.positive { color: #27ae60; }
.opening-value.negative { color: #e74c3c; }

.opening-balance-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.btn-carry {
  padding: 8px 14px;
  background: #f39c12;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: bold;
  transition: background 0.2s;
}

.btn-carry:hover { background: #e67e22; }

.manual-balance {
  display: flex;
  gap: 6px;
  align-items: center;
}

.manual-balance input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  width: 160px;
  background: var(--input-bg);
  color: var(--text-primary);
}

.btn-manual {
  padding: 8px 14px;
  background: #2980b9;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: bold;
  transition: background 0.2s;
}

.btn-manual:hover { background: #2471a3; }

/* ===== SUMMARY ===== */
.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.card {
  padding: 16px;
  border-radius: 12px;
  color: white;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card span   { font-size: 0.85rem; opacity: 0.85; }
.card strong { font-size: 1.25rem; }
.green  { background: #27ae60; }
.red    { background: #e74c3c; }
.blue   { background: #2980b9; }
.yellow { background: #f39c12; }

/* ===== ORÇAMENTO / METAS ===== */
.budget-section {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px var(--shadow);
}

.budget-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.budget-form input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--input-bg);
  color: var(--text-primary);
  flex: 1;
  min-width: 140px;
}

#btn-add-budget {
  padding: 8px 16px;
  background: #27ae60;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.9rem;
  transition: background 0.2s;
}

#btn-add-budget:hover { background: #219a52; }

.budget-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.budget-item {
  background: var(--bg-item);
  border-radius: 10px;
  padding: 12px 16px;
}

.budget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.budget-header strong {
  font-size: 0.95rem;
  color: var(--text-heading);
}

.budget-header small {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.btn-delete-sm {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-delete-sm:hover {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s ease;
}

.budget-ok      { background: #27ae60; }
.budget-warning { background: #f39c12; }
.budget-danger  { background: #e74c3c; }

.budget-remaining {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.budget-remaining.negative {
  color: #e74c3c;
  font-weight: bold;
}

/* ===== SECTIONS GERAIS ===== */
.form-section, .filter-section,
.list-section, .charts-section,
.export-section, .recurring-section {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px var(--shadow);
}

h2 { margin-bottom: 16px; font-size: 1.1rem; color: var(--text-heading); }

/* ===== FORM ===== */
form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

form input, form select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  width: 100%;
  background: var(--input-bg);
  color: var(--text-primary);
}

.recurrence-row {
  grid-column: span 2;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding: 6px 0;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #2980b9;
  cursor: pointer;
}

.form-buttons {
  grid-column: span 2;
  display: flex;
  gap: 10px;
}

.form-buttons button[type="submit"],
#btn-submit {
  flex: 1;
  padding: 10px;
  background: #2c3e50;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

.form-buttons button[type="submit"]:hover { background: #1a252f; }

.btn-cancel {
  padding: 10px 20px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-cancel:hover { background: #c0392b; }

/* ===== RECORRENTES ===== */
.recurring-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recurring-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--bg-item);
  border-left: 4px solid #2980b9;
  transition: opacity 0.3s;
}

.recurring-item.inactive {
  opacity: 0.5;
  border-left-color: #aaa;
}

.recurring-info { display: flex; flex-direction: column; gap: 2px; }
.recurring-info strong { font-size: 0.95rem; color: var(--text-heading); }
.recurring-info small  { color: var(--text-muted); font-size: 0.8rem; }

.recurring-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.recurring-right span { font-weight: bold; font-size: 1rem; }

.btn-toggle-rec {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  transition: transform 0.2s;
}

.btn-toggle-rec:hover { transform: scale(1.2); }

.badge-recurring {
  font-size: 0.75rem;
  vertical-align: super;
}

/* ===== FILTROS ===== */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filters select,
.filters input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--input-bg);
  color: var(--text-primary);
}

.filters input[type="text"] {
  flex: 1;
  min-width: 150px;
}

.filters button {
  padding: 8px 16px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.filters button:hover { background: #c0392b; }

/* ===== LISTA ===== */
#transaction-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.transaction-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--bg-item);
  border-left: 4px solid #ccc;
  transition: transform 0.15s, box-shadow 0.15s;
}

.transaction-item:hover {
  transform: translateX(4px);
  box-shadow: 0 2px 8px var(--shadow);
}

.transaction-item.income     { border-left-color: #27ae60; }
.transaction-item.expense    { border-left-color: #e74c3c; }
.transaction-item.investment { border-left-color: #2980b9; }

.transaction-info { display: flex; flex-direction: column; gap: 2px; }
.transaction-info strong { font-size: 0.95rem; color: var(--text-heading); }
.transaction-info small  { color: var(--text-muted); font-size: 0.8rem; }

.tag-list {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.tag {
  background: #2980b933;
  color: #2980b9;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: bold;
}

[data-theme="dark"] .tag {
  background: #2980b955;
  color: #5dade2;
}

.transaction-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.transaction-right span            { font-weight: bold; font-size: 1rem; }
.transaction-right span.income     { color: #27ae60; }
.transaction-right span.expense    { color: #e74c3c; }
.transaction-right span.investment { color: #2980b9; }

.btn-edit, .btn-delete {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  transition: color 0.2s;
  padding: 4px;
}

.btn-edit:hover { color: #f39c12; }
.btn-delete:hover { color: #e74c3c; }

.empty-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
  display: none;
}

/* ===== CHARTS ===== */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.chart-box {
  background: var(--chart-bg);
  border-radius: 10px;
  padding: 16px;
}

.chart-box h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-align: center;
}

.chart-full { grid-column: span 2; }

/* ===== EXPORT / BACKUP ===== */
.export-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.export-buttons button,
.btn-restore-label {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  background: #2c3e50;
  color: white;
  transition: background 0.2s;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.export-buttons button:hover,
.btn-restore-label:hover { background: #1a252f; }

.btn-backup { background: #27ae60 !important; }
.btn-backup:hover { background: #219a52 !important; }

.btn-restore-label { background: #8e44ad; }
.btn-restore-label:hover { background: #732d91; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--modal-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 28px 32px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  max-width: 360px;
  width: 90%;
}

.modal-box p {
  font-size: 1.05rem;
  margin-bottom: 20px;
  color: var(--text-heading);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-yes {
  padding: 8px 24px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.95rem;
}

.btn-no {
  padding: 8px 24px;
  background: #bdc3c7;
  color: #2c3e50;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.95rem;
}

.btn-yes:hover { background: #c0392b; }
.btn-no:hover  { background: #95a5a6; }

/* ===== LOGIN PAGE ===== */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-body);
  padding: 20px;
}

.login-box {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 30px var(--shadow);
}

.login-box h1 {
  text-align: center;
  color: var(--text-heading);
  margin-bottom: 30px;
  font-size: 1.6rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form h2 {
  text-align: center;
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.auth-form input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--input-bg);
  color: var(--text-primary);
  transition: border 0.2s;
}

.auth-form input:focus {
  outline: none;
  border-color: #2980b9;
}

.auth-form button {
  padding: 12px;
  background: #2c3e50;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

.auth-form button:hover { background: #1a252f; }

.auth-switch {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.auth-switch a {
  color: #2980b9;
  text-decoration: none;
  font-weight: bold;
}

.auth-switch a:hover { text-decoration: underline; }

.auth-error {
  color: #e74c3c;
  text-align: center;
  font-size: 0.85rem;
  min-height: 20px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .summary        { grid-template-columns: 1fr 1fr; }
  .card strong    { font-size: 1.05rem; }
  form            { grid-template-columns: 1fr; }
  .form-buttons   { grid-column: span 1; flex-direction: column; }
  .recurrence-row { grid-column: span 1; }
  .charts-grid    { grid-template-columns: 1fr; }
  .chart-full     { grid-column: span 1; }
  .month-nav      { flex-wrap: wrap; gap: 8px; }
  #current-month-label { min-width: auto; }
  .opening-balance-actions { flex-direction: column; }
  .manual-balance { width: 100%; }
  .manual-balance input { flex: 1; }
  .budget-form    { flex-direction: column; }
  .export-buttons { flex-direction: column; }

  #toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
  }

  .toast { max-width: 100%; }

  /* Login & Header responsivo */
  .header-actions { position: static; margin-top: 10px; }
  header { flex-direction: column; gap: 8px; }
  .user-badge { display: none; }
}
/* ===== LOADING OVERLAY ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
