/* ============================================
   FINTRACK — Controlador de Gastos
   style.css
   ============================================ */

/* ---- RESET & VARIÁVEIS ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:          #0e0e10;
  --surface:     #18181c;
  --surface2:    #212126;
  --border:      rgba(255,255,255,0.08);
  --border2:     rgba(255,255,255,0.14);
  --text:        #f0f0ee;
  --muted:       #888885;

  --accent:      #c8f542;
  --accent-dim:  rgba(200,245,66,0.12);
  --red:         #ff5c5c;
  --red-dim:     rgba(255,92,92,0.12);
  --blue:        #5c9fff;
  --blue-dim:    rgba(92,159,255,0.12);
  --amber:       #ffb84d;
  --amber-dim:   rgba(255,184,77,0.12);
  --teal:        #4dffd4;
  --teal-dim:    rgba(77,255,212,0.12);
  --pink:        #ff7eb3;
  --pink-dim:    rgba(255,126,179,0.12);
  --purple:      #a78bfa;

  --font-head: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --radius:    12px;
  --radius-sm: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  min-height: 100vh;
}

/* ============================================
   HEADER
   ============================================ */
header {
  padding: 2rem 2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.03em;
}

.logo span {
  color: var(--accent);
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.month-nav button {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.month-nav button:hover {
  background: var(--border2);
}

#month-label {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 600;
  min-width: 160px;
  text-align: center;
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */
.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: calc(100vh - 85px);
}

.main {
  padding: 1.5rem 2rem;
  border-right: 1px solid var(--border);
}

.sidebar {
  padding: 1.5rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ============================================
   CARDS DE RESUMO
   ============================================ */
.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 1.5rem;
}

.sum-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
}

.sum-card .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.sum-card .value {
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 700;
}

.sum-card.receita .value { color: var(--accent); }
.sum-card.despesa .value { color: var(--red); }
.sum-card.saldo   .value { color: var(--blue); }

/* Acessibilidade: esconde visualmente mas mantém para leitores de tela e validadores */
.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;
}

/* ============================================
   BARRA DE FILTROS
   ============================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input[type="text"] {
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
  height: 34px;
  width: 100%;
}

.filter-bar select:focus,
.filter-bar input:focus {
  border-color: var(--accent);
}

.filter-input-wrap {
  flex: 1;
  min-width: 140px;
}

.filter-select-wrap {
  min-width: 160px;
}

/* ============================================
   TABELA DE TRANSAÇÕES
   ============================================ */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 8px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-weight: 400;
}

.th-right  { text-align: right; }
.th-center { text-align: center; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:hover {
  background: var(--surface);
}

tbody td {
  padding: 10px 12px;
}

/* Badge de categoria */
.cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Badge de tipo */
.tipo-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.tipo-receita { background: var(--accent-dim); color: var(--accent); }
.tipo-despesa { background: var(--red-dim);    color: var(--red); }

/* Valor colorido */
.valor-receita { color: var(--accent); font-weight: 500; }
.valor-despesa { color: var(--red);    font-weight: 500; }

/* Botões de ação */
.action-btn {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  margin: 0 2px;
}

.action-btn:hover       { color: var(--text);   background: var(--surface2); }
.action-btn.del:hover   { border-color: var(--red);    color: var(--red); }
.action-btn.edit:hover  { border-color: var(--accent); color: var(--accent); }

.empty {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
  font-size: 13px;
}

.empty--hidden     { display: none; }
.btn-cancel--hidden { display: none; }

.select-wrap {
  width: 100%;
}

.select-wrap select {
  width: 100%;
}

/* ============================================
   FORMULÁRIO (SIDEBAR)
   ============================================ */
.form-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.form-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 1rem;
}

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

.form-group label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}

.form-group input,
.form-group select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
}

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

/* Toggle receita / despesa */
.tipo-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tipo-btn {
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.tipo-btn.active-receita {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.tipo-btn.active-despesa {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}

/* Botões do formulário */
.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #0e0e10;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: opacity 0.15s;
  margin-top: 4px;
}

.btn-primary:hover {
  opacity: 0.85;
}

.btn-cancel {
  width: 100%;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 9px;
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  margin-top: 6px;
  transition: all 0.15s;
}

.btn-cancel:hover {
  color: var(--text);
}

/* ============================================
   GRÁFICO (SIDEBAR)
   ============================================ */
.chart-section {
  border-top: 1px solid var(--border);
  padding-top: 1.2rem;
}

.section-title {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
}

.chart-wrap {
  position: relative;
  height: 200px;
  margin-bottom: 1rem;
}

/* Legenda de categorias */
.cat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.cat-row .cat-info {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}

.cat-row .cat-val {
  font-weight: 500;
}

/* ============================================
   RESPONSIVIDADE
   ============================================ */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .main {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .summary {
    grid-template-columns: 1fr 1fr;
  }

  .sum-card.saldo {
    grid-column: span 2;
  }
}

@media (max-width: 500px) {
  .summary {
    grid-template-columns: 1fr;
  }

  .sum-card.saldo {
    grid-column: span 1;
  }

  header {
    padding: 1.2rem;
  }

  .main {
    padding: 1rem;
  }
}