/* ============================================================
   app.css — Estilos customizados (complementam Tailwind)
   ============================================================ */

/* Variáveis */
:root {
  --color-primary: #2563eb;
  --color-primary-light: #3b82f6;
  --color-success: #22c55e;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  --transition: 200ms ease;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Safe area para iPhone X+ */
.safe-area-bottom { padding-bottom: env(safe-area-inset-bottom, 0); }

/* ── Scrollbar personalizada ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Nav links — estado ativo ── */
.nav-link.active,
.nav-link[aria-current="page"] {
  background-color: #eff6ff;
  color: var(--color-primary);
  font-weight: 600;
}

.bottom-nav-link.active {
  color: var(--color-primary);
}

.bottom-nav-link.active span:first-child {
  filter: drop-shadow(0 0 4px rgba(37, 99, 235, 0.4));
}

/* ── Cards ── */
.card {
  background: white;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  padding: 1.25rem;
}

.card-hover {
  transition: box-shadow var(--transition), transform var(--transition);
}

.card-hover:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  transform: translateY(-1px);
}

/* ── Barra de progresso ── */
.progress-bar-track {
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
  height: 8px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 600ms ease;
}

.progress-bar-fill.safe   { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.progress-bar-fill.warn   { background: linear-gradient(90deg, #f59e0b, #d97706); }
.progress-bar-fill.danger { background: linear-gradient(90deg, #ef4444, #dc2626); }

/* ── Badges de status ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-pendente    { background: #f1f5f9; color: #64748b; }
.badge-em_andamento{ background: #dbeafe; color: #1d4ed8; }
.badge-concluida   { background: #dcfce7; color: #15803d; }

/* ── Toast notifications ── */
.toast {
  pointer-events: auto;
  background: white;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: 360px;
  border-left: 4px solid;
  animation: toast-in 250ms ease forwards;
}

.toast.toast-success { border-color: var(--color-success); }
.toast.toast-error   { border-color: var(--color-danger); }
.toast.toast-info    { border-color: var(--color-primary); }
.toast.toast-warn    { border-color: var(--color-warning); }

.toast.toast-out { animation: toast-out 250ms ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}

/* ── Animação checkmark (ao salvar gasto) ── */
.checkmark-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

.checkmark-svg {
  width: 64px;
  height: 64px;
}

.checkmark-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 3;
  stroke: #22c55e;
  fill: none;
  animation: checkmark-stroke 400ms cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-check {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  stroke-width: 3;
  stroke: #22c55e;
  fill: none;
  animation: checkmark-stroke 300ms cubic-bezier(0.65, 0, 0.45, 1) 400ms forwards;
}

@keyframes checkmark-stroke {
  100% { stroke-dashoffset: 0; }
}

/* ── Animação de número (count-up) ── */
.count-up {
  transition: all 400ms ease;
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 640px) {
  .modal {
    align-items: center;
    padding: 1rem;
  }
}

.modal-box {
  background: white;
  border-radius: 1.25rem 1.25rem 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 1.5rem;
  animation: modal-slide-up 250ms ease;
}

@media (min-width: 640px) {
  .modal-box {
    border-radius: 1.25rem;
    animation: modal-fade-in 200ms ease;
  }
}

@keyframes modal-slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes modal-fade-in {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ── Input styles ── */
.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.75rem;
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: white;
}

.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Input de valor (grande, para mobile) */
.valor-input {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  padding: 1rem;
  letter-spacing: -0.5px;
}

/* ── Toggle (pago por) ── */
.toggle-group {
  display: flex;
  background: #f1f5f9;
  border-radius: 0.75rem;
  padding: 3px;
  gap: 2px;
}

.toggle-option {
  flex: 1;
  padding: 8px 12px;
  border-radius: 0.625rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  color: #64748b;
  user-select: none;
}

.toggle-option.active {
  background: white;
  color: var(--color-primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

/* ── Skeleton loader ── */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.4s infinite;
  border-radius: 6px;
}

@keyframes skeleton-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Tabela de gastos ── */
.gastos-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.gastos-table th {
  background: #f8fafc;
  padding: 10px 12px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #e2e8f0;
}

.gastos-table td {
  padding: 12px 12px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem;
  color: #1e293b;
  vertical-align: middle;
}

.gastos-table tr:hover td {
  background: #f8fafc;
}

.gastos-table tr:last-child td {
  border-bottom: none;
}

/* ── Fase card ── */
.fase-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1.25rem;
  transition: box-shadow var(--transition);
}

.fase-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.fase-card.concluida { border-color: #86efac; background: #f0fdf4; }
.fase-card.em_andamento { border-color: #93c5fd; }

/* ── Timeline (log) ── */
.timeline-item {
  display: flex;
  gap: 1rem;
  padding-bottom: 1.5rem;
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 40px;
  bottom: 0;
  width: 2px;
  background: #e2e8f0;
}

.timeline-item:last-child::before { display: none; }

.timeline-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  border: 2px solid white;
  box-shadow: 0 0 0 2px #e2e8f0;
}

.timeline-dot.criou   { background: #dbeafe; }
.timeline-dot.editou  { background: #fef3c7; }
.timeline-dot.deletou { background: #fee2e2; }

/* ── Utilitários extras ── */
.text-brl { font-variant-numeric: tabular-nums; }

.btn-primary {
  background: var(--color-primary);
  color: white;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  border: none;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary:hover  { background: var(--color-primary-dark, #1d4ed8); box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  border: none;
  cursor: pointer;
  transition: background var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-secondary:hover { background: #e2e8f0; }

.btn-danger {
  background: #fef2f2;
  color: #dc2626;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid #fecaca;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 0.875rem;
}

.btn-danger:hover { background: #fee2e2; }

/* Animação de celebração ao concluir fase */
@keyframes bounce-in {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); }
}

.bounce-in { animation: bounce-in 400ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }

/* Fade in suave para views */
.view-enter {
  animation: view-fade 200ms ease forwards;
}

@keyframes view-fade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Highlight ao atualizar número */
@keyframes highlight-pulse {
  0%   { color: inherit; }
  30%  { color: #2563eb; }
  100% { color: inherit; }
}

.number-updated { animation: highlight-pulse 800ms ease; }
