﻿/* ================================================================
   style.css - Design Ultra Premium & Wizard
   ================================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  --primary:      #4F46E5;
  --primary-dark: #4338CA;
  --primary-light:#EEF2FF;
  
  --danger:       #EF4444;
  --danger-light: #FEF2F2;
  --success:      #10B981;
  --success-light:#ECFDF5;
  
  --gray-50:      #F9FAFB;
  --gray-100:     #F3F4F6;
  --gray-200:     #E5E7EB;
  --gray-300:     #D1D5DB;
  --gray-400:     #9CA3AF;
  --gray-500:     #6B7280;
  --gray-700:     #374151;
  --gray-900:     #111827;
  
  --bg:           #F4F7FC;
  --surface:      #FFFFFF;
  
  --radius-lg:    20px;
  --radius:       12px;
  --radius-sm:    8px;
  
  --shadow-sm:    0 1px 2px rgba(0,0,0,0.05);
  --shadow:       0 4px 6px -1px rgba(0,0,0,0.1);
  --shadow-lg:    0 10px 15px -3px rgba(0,0,0,0.1);
  
  --font:         'Inter', system-ui, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--gray-900); min-height: 100vh; -webkit-tap-highlight-color: transparent; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--font); border: none; background: none; }
input, select { font-family: var(--font); }

/* ================================================================
   CABECALHO
   ================================================================ */
.app-header {
  background: var(--surface); color: var(--gray-900); padding: 0 20px; height: 70px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow-sm);
}
.app-header .logo { font-size: 1.25rem; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.app-header .actions { display: flex; align-items: center; gap: 12px; }
.btn-icon { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--gray-500); font-size: 1.25rem; background: var(--gray-50); transition: all .2s; }
.btn-icon:hover { background: var(--gray-100); color: var(--gray-900); }

.main { padding: 24px 20px; max-width: 1000px; margin: 0 auto; padding-bottom: 100px; }

/* ================================================================
   CARDS E FILTROS
   ================================================================ */
.summary-section, .filter-section { margin-bottom: 24px; }
.summary-section h2, .filter-header h3 { font-size: 1.125rem; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

.cards-row { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 12px; margin-left: -20px; padding-left: 20px; scrollbar-width: none; }
.cards-row::-webkit-scrollbar { display: none; }
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; min-width: 160px; flex: 0 0 auto; box-shadow: var(--shadow); border: 1px solid var(--gray-100); position: relative; overflow: hidden; }
.card::before { content: ''; position: absolute; top: 0; left: 0; bottom: 0; width: 4px; background: var(--primary); }
.card.total-card::before { background: var(--success); }
.card .card-label { font-size: .875rem; color: var(--gray-500); font-weight: 600; margin-bottom: 8px; }
.card .card-value { font-size: 1.75rem; font-weight: 800; color: var(--gray-900); }
.card .card-sub   { font-size: .75rem; color: var(--gray-400); margin-top: 6px; font-weight: 500; }

.filter-section { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--gray-100); }
.filter-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.quick-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 8px 16px; border-radius: 999px; font-size: .875rem; font-weight: 600; border: 1px solid var(--gray-200); color: var(--gray-600); background: var(--surface); transition: all .2s; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.filter-controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 140px; }
.filter-group label { font-size: .875rem; color: var(--gray-700); font-weight: 600; }
.filter-group input, .filter-group select { padding: 10px 14px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: .95rem; background: var(--surface); outline: none; }
.filter-group input:focus, .filter-group select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.btn-filter { padding: 12px 24px; font-size: .95rem; border-radius: var(--radius-sm); background: var(--gray-900); color: #fff; font-weight: 600; height: 42px; }

/* ================================================================
   TABELA RESPONSIVA
   ================================================================ */
.table-toolbar { display: flex; align-items: center; justify-content: space-between; padding-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.table-toolbar h3 { font-size: 1.125rem; font-weight: 700; }
.btn-new { background: var(--primary); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 600; display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow); }

table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
thead th { padding: 12px 16px; text-align: left; font-size: .75rem; font-weight: 700; color: var(--gray-500); text-transform: uppercase; border-bottom: 2px solid var(--gray-200); }
tbody tr { background: var(--surface); box-shadow: var(--shadow-sm); border-radius: var(--radius); transition: transform .2s; }
tbody tr:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
tbody td { padding: 16px; font-size: 1rem; color: var(--gray-800); vertical-align: middle; }
tbody td:first-child { border-radius: var(--radius) 0 0 var(--radius); }
tbody td:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
tbody tr.selected { background: var(--primary-light); }

.cb-cell { width: 50px; text-align: center; }
.custom-cb { width: 22px; height: 22px; accent-color: var(--primary); cursor: pointer; }
.date-cell { color: var(--gray-500); font-weight: 500; }
.desc-cell { font-weight: 600; color: var(--gray-900); }
.person-badge { padding: 4px 12px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--primary-light); color: var(--primary-dark); }
.amount-cell { font-weight: 800; font-size: 1.1rem; color: var(--gray-900); }

.actions-cell { white-space: nowrap; }
.btn-edit, .btn-del { padding: 8px 16px; border-radius: var(--radius-sm); font-size: .875rem; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn-edit { background: var(--gray-100); color: var(--gray-700); margin-right: 8px; }
.btn-del  { background: var(--danger-light); color: var(--danger); }

@media (max-width: 768px) {
  thead { display: none; }
  table, tbody { display: block; width: 100%; }
  tbody tr { display: flex; flex-direction: column; padding: 16px 16px 16px 50px; margin-bottom: 16px; position: relative; }
  tbody td { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--gray-100); }
  tbody td::before { content: attr(data-label); font-weight: 600; color: var(--gray-500); font-size: 0.85rem; text-transform: uppercase; }
  .cb-cell { position: absolute; top: 16px; left: 16px; padding: 0 !important; border: none !important; display: block !important; }
  .cb-cell::before, .actions-cell::before { display: none; }
  .actions-cell { flex-direction: row; justify-content: flex-end; gap: 8px; border: none !important; }
}

/* ================================================================
   SOMA FLUTUANTE
   ================================================================ */
.sum-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: rgba(17, 24, 39, 0.9); backdrop-filter: blur(12px); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; box-shadow: 0 -10px 25px -5px rgba(0,0,0,0.1); transition: all .3s ease;
}
.sum-bar .sum-label { font-size: .875rem; color: var(--gray-300); font-weight: 500; }
.sum-bar .sum-value { font-size: 1.75rem; font-weight: 800; color: var(--success); }
.sum-bar.has-selection { background: rgba(79, 70, 229, 0.95); }
.sum-bar.has-selection .sum-value { color: #fff; }

/* ================================================================
   MODAL & WIZARD (ASSISTENTE DE PASSOS)
   ================================================================ */
.modal-overlay, .confirm-overlay {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(17, 24, 39, 0.6); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open, .confirm-overlay.open { display: flex; animation: fadeIn .2s ease; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); padding: 40px;
  width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: slideUp .3s ease;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-header h2 { font-size: 1.25rem; font-weight: 800; color: var(--gray-900); }
.btn-close { color: var(--gray-400); font-size: 1.5rem; line-height: 1; }

.modal-step { display: none; animation: fadeIn .3s ease; }
.modal-step.active { display: block; }

.wizard-indicator { display: flex; justify-content: center; gap: 8px; margin-bottom: 24px; }
.wiz-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--gray-200); transition: all .3s; }
.wiz-dot.active { background: var(--primary); transform: scale(1.3); }

.big-label { display: block; font-size: 1.25rem; font-weight: 800; color: var(--gray-900); margin-bottom: 12px; }
.mt-4 { margin-top: 24px; }
.mt-5 { margin-top: 32px; }

.big-input {
  width: 100%; padding: 18px 20px; font-size: 1.15rem; font-weight: 600;
  border: 2px solid var(--gray-200); border-radius: var(--radius);
  background: var(--gray-50); outline: none; transition: all .2s; color: var(--gray-900);
}
.big-input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px var(--primary-light); }

.wizard-footer { display: flex; gap: 12px; }
.btn-wizard-next, .btn-wizard-save, .btn-wizard-back {
  padding: 20px; border-radius: var(--radius); font-weight: 800; font-size: 1.15rem;
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: all .2s;
}
.btn-wizard-next, .btn-wizard-save { flex: 2; background: var(--primary); color: #fff; box-shadow: var(--shadow); }
.btn-wizard-save { background: var(--success); }
.btn-wizard-back { flex: 1; background: var(--gray-100); color: var(--gray-700); font-weight: 700; font-size: 1.05rem; }

/* Grid de pessoas (Passo 3) */
.item-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.expense-item { background: var(--bg); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 24px; margin-bottom: 16px; position: relative; }
.remove-item { position: absolute; top: 12px; right: 16px; color: var(--danger); font-weight: 600; }
.new-person-row { display: flex; gap: 8px; margin-top: 8px; }
.btn-save-person { background: var(--gray-900); color: #fff; border-radius: var(--radius-sm); font-weight: 600; white-space: nowrap; }
.btn-add-item { width: 100%; padding: 18px; border-radius: var(--radius); border: 2px dashed var(--primary); color: var(--primary); font-weight: 600; font-size: 1.05rem; background: var(--primary-light); margin-bottom: 32px; display: flex; align-items: center; justify-content: center; gap: 8px;}

@media (max-width: 600px) {
  .item-grid { grid-template-columns: 1fr; }
  .modal { border-radius: 24px 24px 0 0; align-self: flex-end; padding: 32px 20px; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}

/* ================================================================
   TOAST & ANIMATIONS & EXTRAS
   ================================================================ */
.toast-container { position: fixed; top: 80px; right: 20px; z-index: 500; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--gray-900); color: #fff; padding: 14px 20px; border-radius: var(--radius); font-weight: 600; display: flex; align-items: center; gap: 12px; animation: slideIn .3s ease; }
.toast.success { border-left: 5px solid var(--success); }
.toast.error   { border-left: 5px solid var(--danger); }

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideIn { from { transform: translateX(50px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.loading { display: flex; justify-content: center; padding: 40px; width: 100%; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   IMPRESSAO / PDF
   ================================================================ */
.print-only { display: none; }
@media print {
  @page { margin: 1.5cm; size: auto; }
  body { background: #fff !important; color: #000 !important; }
  .app-header, .filter-section, .table-toolbar, .sum-bar, 
  .modal-overlay, .confirm-overlay, .toast-container,
  .summary-section, .cb-cell, .actions-cell { display: none !important; }
  .print-only { display: block !important; text-align: center; margin-bottom: 20px; font-size: 1.2rem; font-weight: bold; border-bottom: 2px solid #ccc; padding-bottom: 10px; }
  .main { padding: 0 !important; margin: 0 !important; max-width: 100% !important; }
  table, tbody { display: table !important; width: 100% !important; }
  thead { display: table-header-group !important; }
  thead th { border-bottom: 2px solid #000 !important; color: #000 !important; padding: 8px !important; }
  tbody tr { display: table-row !important; box-shadow: none !important; border: none !important; page-break-inside: avoid; }
  tbody td { display: table-cell !important; border-bottom: 1px solid #ccc !important; padding: 8px !important; color: #000 !important; }
  tbody td::before { display: none !important; }
}
/* ================================================================
   BOTAO INSTALAR APP (TOPO)
   ================================================================ */
.btn-install {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--success);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: var(--shadow);
  transition: all .2s;
  cursor: pointer;
}
.btn-install:hover {
  background: #059669;
  transform: translateY(-1px);
}
.btn-install i {
  font-size: 1.2rem;
}

/* ================================================================
   MODAL DE CONFIRMACAO DE EXCLUSAO (ACESSIBILIDADE / IDOSOS)
   ================================================================ */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(17, 24, 39, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.confirm-overlay.open {
  display: flex !important;
  animation: fadeIn .2s ease;
}

.confirm-box {
  background: #ffffff !important;
  border-radius: 24px !important;
  padding: 36px 28px !important;
  max-width: 440px !important;
  width: 100% !important;
  text-align: center !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.1) !important;
  border: 1px solid var(--gray-200) !important;
  animation: slideUp .25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.confirm-box h3 {
  font-size: 1.4rem !important;
  font-weight: 800 !important;
  color: var(--danger) !important;
  margin-bottom: 12px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
}
.confirm-box h3 i {
  font-size: 1.6rem !important;
}

.confirm-box p {
  color: var(--gray-700) !important;
  font-size: 1.1rem !important;
  font-weight: 600 !important;
  margin-bottom: 28px !important;
  line-height: 1.4 !important;
}

.confirm-btns {
  display: flex !important;
  gap: 14px !important;
  width: 100% !important;
}

.btn-confirm-cancel {
  flex: 1 !important;
  padding: 16px !important;
  border-radius: var(--radius) !important;
  background: var(--gray-100) !important;
  color: var(--gray-700) !important;
  font-weight: 700 !important;
  font-size: 1.05rem !important;
  border: 2px solid var(--gray-300) !important;
  cursor: pointer !important;
  transition: all .2s !important;
}
.btn-confirm-cancel:hover {
  background: var(--gray-200) !important;
}

.btn-confirm-ok {
  flex: 1 !important;
  padding: 16px !important;
  border-radius: var(--radius) !important;
  background: var(--danger) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  font-size: 1.05rem !important;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.4) !important;
  cursor: pointer !important;
  transition: all .2s !important;
  border: none !important;
}
.btn-confirm-ok:hover {
  background: #dc2626 !important;
  transform: translateY(-1px) !important;
}

/* ================================================================
   TELA DE LOGIN
   ================================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
}

.login-card {
  background: #ffffff;
  border-radius: 28px;
  padding: 44px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.login-logo {
  margin-bottom: 28px;
}

.login-logo .icon {
  font-size: 54px;
  color: var(--primary);
  margin-bottom: 12px;
  display: inline-block;
}

.login-logo h1 {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -0.025em;
}

.login-logo p {
  color: var(--gray-500);
  font-size: 0.95rem;
  margin-top: 6px;
  font-weight: 500;
}

.step-indicator {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray-200);
  transition: all .3s ease;
}

.step-dot.active {
  background: var(--primary);
  width: 28px;
  border-radius: 999px;
}

.step {
  display: none;
  text-align: left;
}

.step.active {
  display: block;
  animation: fadeIn .3s ease;
}

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

.form-group label {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 10px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 16px 18px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 1.05rem;
  color: var(--gray-900);
  background: var(--gray-50);
  outline: none;
  transition: all .2s ease;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px var(--primary-light);
}

.date-row {
  display: grid;
  grid-template-columns: 1fr 1.6fr 1fr;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 24px;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 800;
  transition: all .2s ease;
  cursor: pointer;
  border: none;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-500);
  font-weight: 700;
  font-size: 0.95rem;
  margin-top: 14px;
  padding: 12px;
}

.btn-ghost:hover {
  color: var(--gray-800);
  background: var(--gray-100);
}

.login-error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 20px;
  display: none;
}

.login-error.show {
  display: block;
  animation: slideIn .25s ease;
}
