/**
 * Sistema Financeiro - Mobile First
 * Cordova-ready, touch-friendly
 */

:root {
    --nav-height: 72px;
    --safe-bottom: env(safe-area-inset-bottom, 0);
    --verde: #198754;
    --vermelho: #dc3545;
    --amarelo: #ffc107;
}

* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    scroll-behavior: auto;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
    background: #f0f2f5;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.app-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 12px;
}

/* Telas */
.tela {
    display: none;
    animation: fadeIn 0.2s ease;
}
.tela.ativa {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Cards */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 12px;
}
.card-header {
    font-weight: 600;
    border-bottom: 1px solid #eee;
    padding: 12px 16px;
    background: #fff;
    border-radius: 12px 12px 0 0;
}

/* Status e cores */
.status-pago { background-color: rgba(25, 135, 84, 0.12); border-left: 4px solid var(--verde); }
.status-aberto { background-color: rgba(220, 53, 69, 0.12); border-left: 4px solid var(--vermelho); }
.status-futuro { background-color: rgba(255, 193, 7, 0.2); border-left: 4px solid var(--amarelo); }

.badge-equilibrado { background: #0d6efd; }
.badge-superavit { background: var(--verde); }
.badge-deficit { background: var(--vermelho); }

/* Navbar inferior – fixa, botões maiores, distribuídos e coloridos */
.navbar-bottom.fixed-bottom {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1030;
    min-height: var(--nav-height);
    padding: 6px 4px calc(var(--safe-bottom) + 6px) 4px;
    background: #fff;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.12);
    display: flex;
    align-items: stretch;
    gap: 4px;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}
.navbar-bottom .nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    padding: 8px 4px;
    border-radius: 12px;
    transition: color 0.15s, transform 0.15s;
    min-width: 0;
}
.navbar-bottom .nav-item i {
    font-size: 1.6rem;
    margin-bottom: 2px;
}
.navbar-bottom .nav-item:hover {
    transform: scale(1.05);
}
.navbar-bottom .nav-item.active {
    transform: scale(1.08);
}
/* Cores só no ícone e no texto (sem quadrado de fundo) */
.navbar-bottom .nav-item-inicio i,
.navbar-bottom .nav-item-inicio span { color: #6c757d; }
.navbar-bottom .nav-item-inicio:hover i,
.navbar-bottom .nav-item-inicio:hover span,
.navbar-bottom .nav-item-inicio.active i,
.navbar-bottom .nav-item-inicio.active span { color: #0d6efd; }

.navbar-bottom .nav-item-novo i,
.navbar-bottom .nav-item-novo span { color: #6c757d; }
.navbar-bottom .nav-item-novo:hover i,
.navbar-bottom .nav-item-novo:hover span,
.navbar-bottom .nav-item-novo.active i,
.navbar-bottom .nav-item-novo.active span { color: #198754; }

.navbar-bottom .nav-item-lista i,
.navbar-bottom .nav-item-lista span { color: #6c757d; }
.navbar-bottom .nav-item-lista:hover i,
.navbar-bottom .nav-item-lista:hover span,
.navbar-bottom .nav-item-lista.active i,
.navbar-bottom .nav-item-lista.active span { color: #fd7e14; }

.navbar-bottom .nav-item-relatorios i,
.navbar-bottom .nav-item-relatorios span { color: #6c757d; }
.navbar-bottom .nav-item-relatorios:hover i,
.navbar-bottom .nav-item-relatorios:hover span,
.navbar-bottom .nav-item-relatorios.active i,
.navbar-bottom .nav-item-relatorios.active span { color: #6f42c1; }

.navbar-bottom .nav-item-sair i,
.navbar-bottom .nav-item-sair span { color: #6c757d; }
.navbar-bottom .nav-item-sair:hover i,
.navbar-bottom .nav-item-sair:hover span,
.navbar-bottom .nav-item-sair.active i,
.navbar-bottom .nav-item-sair.active span { color: #dc3545; }

/* Botões grandes - mobile */
.btn-mobile {
    min-height: 48px;
    font-size: 1rem;
    padding: 12px 20px;
    border-radius: 10px;
}
.btn-receber { background: var(--verde); color: #fff; border: none; }
.btn-receber:hover { background: #157347; color: #fff; }
.btn-pagar { background: var(--vermelho); color: #fff; border: none; }
.btn-pagar:hover { background: #bb2d3b; color: #fff; }

/* Formulários */
.form-control, .form-select {
    min-height: 48px;
    border-radius: 10px;
}
.form-label { font-weight: 500; }

/* Tabela lista - estilo planilha */
.tabela-lancamentos { font-size: 0.9rem; }
.tabela-lancamentos th {
    font-weight: 600;
    background: #f8f9fa;
    white-space: nowrap;
}
.tabela-lancamentos td {
    vertical-align: middle;
}
.tabela-lancamentos .valor-receber { color: var(--verde); font-weight: 600; }
.tabela-lancamentos .valor-pagar { color: var(--vermelho); font-weight: 600; }

/* Alerts */
.alert-app {
    border-radius: 10px;
    border: none;
}

/* Gráficos em barras (dashboard) */
.barra-wrap {
    height: 24px;
    background: #e9ecef;
    border-radius: 6px;
    overflow: hidden;
}
.barra-wrap.barra-sm { height: 14px; }
.barra {
    height: 100%;
    border-radius: 6px;
    transition: width 0.3s ease;
}
.barra-verde { background: #198754; }
.barra-vermelha { background: #dc3545; }
.barra-dash { }
.barra-evolucao { }

/* Gráficos (Chart.js - relatórios) */
.chart-container {
    position: relative;
    width: 100%;
    height: 220px;
    min-height: 220px;
    margin: 12px 0;
}
.chart-container canvas {
    display: block;
    max-width: 100%;
}

/* Título da tela */
.tela-titulo {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: #1a1a1a;
}

/* Resumo números grandes */
.resumo-numero {
    font-size: 1.5rem;
    font-weight: 700;
}
.resumo-numero.positivo { color: var(--verde); }
.resumo-numero.negativo { color: var(--vermelho); }

/* Dashboard – ícones e cores nos cards */
.card-dash-sobra .card-header i,
.card-dash-realizado .card-header i,
.card-dash-saldo .fa-piggy-bank,
.card-dash-dividas .card-header i { opacity: 0.95; }
.card.border-success .resumo-numero.positivo { color: #198754; }
.card.border-danger .resumo-numero.negativo { color: #dc3545; }
.card-header .fa-wallet,
.card-header .fa-check-double { font-size: 1.1rem; }

/* Checkbox grande */
.form-check-input { width: 1.25rem; height: 1.25rem; }
.form-check-label { font-size: 1rem; }

/* Dashboard – botões de mês maiores (celular) */
.btn-mes-nav {
    min-width: 48px;
    min-height: 48px;
    padding: 10px 14px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-mes-nav .fa-mes-icon {
    font-size: 1.5rem;
}

/* Dashboard – Incluir provisões: só o switch (sem texto Sim/Não ao lado) */
.toggle-provisao-wrap {
    min-height: 56px;
    align-items: center;
}
.toggle-provisao-wrap .text-provisao-label {
    font-size: 1.05rem;
}
.toggle-provisao-wrap .text-provisao-label .fa-cloud {
    font-size: 1.25rem;
}
.toggle-provisao-só-switch .form-check-label,
.toggle-provisao-só-switch label { display: none !important; }
.toggle-provisao-input,
.toggle-provisao-wrap .toggle-dividas-input {
    width: 4rem !important;
    height: 2.25rem !important;
    min-width: 4rem !important;
    cursor: pointer;
    border-radius: 2rem !important;
}

/* Autocomplete cliente */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 100;
    max-height: 220px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    list-style: none;
    margin: 0;
    padding: 0;
}
.autocomplete-list li {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}
.autocomplete-list li:hover,
.autocomplete-list li:focus {
    background: #f0f7ff;
}
.autocomplete-list li:last-child { border-bottom: none; }
.autocomplete-list .empty { padding: 12px; color: #6c757d; font-size: 0.9rem; }

/* Listagem por tipo: blocos A receber / A pagar */
.card.border-success .list-group-item,
.card.border-danger .list-group-item {
    border-left-width: 3px;
}
.list-group-item .valor-receber { white-space: nowrap; font-size: 0.95rem; }
.list-group-item .valor-pagar { white-space: nowrap; font-size: 0.95rem; }
.list-group-item .btn-toggle-pago { flex-shrink: 0; }

/* ========== Tela Lançamentos – mobile, ícones, cores, toque fácil ========== */
.lista-titulo { font-size: 1.5rem; display: flex; align-items: center; }
.lista-titulo i { font-size: 1.3rem; }

.lista-provisao-card .lista-provisao-label { font-size: 1.05rem; font-weight: 500; }
.lista-toggle-só-switch .form-check-label,
.lista-toggle-só-switch label { display: none !important; }
.lista-provisao-card .lista-provisao-input,
.lista-provisao-card .lista-dividas-input {
    width: 4.5rem !important;
    height: 2.5rem !important;
    min-width: 4.5rem !important;
    cursor: pointer;
    border-radius: 2rem !important;
}
.lista-filtro-card .lista-filtro-label { font-size: 0.95rem; font-weight: 500; }
.lista-filtro-select,
.lista-filtro-input { min-height: 48px; font-size: 1rem; border-radius: 10px; }
.lista-btn-filtrar { min-height: 48px; font-size: 1rem; border-radius: 10px; font-weight: 600; }

.lista-nav-mes { gap: 1rem; min-height: 56px; }
.btn-nav-mes {
    min-width: 56px;
    min-height: 56px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    padding: 0;
}
.lista-mes-ano-label { font-size: 1.25rem; font-weight: 700; min-width: 8rem; text-align: center; }

.lista-card-header { font-size: 1.1rem; }
.lista-card-header-receber { background: rgba(25, 135, 84, 0.12); }
.lista-card-header-danger { background: rgba(220, 53, 69, 0.12); }
.lista-card-header-warning { background: rgba(255, 193, 7, 0.2); }
.fa-lista-secao { font-size: 1.25rem; }

.lista-empty {
    padding: 2rem 1rem;
    text-align: center;
    font-size: 1rem;
}
.lista-empty i { font-size: 2rem; opacity: 0.6; }

.lista-group .lista-item {
    padding: 0.75rem 1rem;
    border-left-width: 4px;
    transition: background 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.lista-item:active { background: rgba(0, 0, 0, 0.04); }
.lista-item-topo { min-width: 0; }
.lista-item-titulo { font-size: 0.95rem; line-height: 1.35; margin-bottom: 2px; }
.lista-item-status { font-size: 0.85rem; color: var(--bs-secondary); }
.lista-item-linha-baixo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-top: 0.25rem;
    border-top: 1px solid rgba(0,0,0,0.06);
}
.lista-item-linha-baixo .lista-valor { font-size: 1.1rem; font-weight: 700; white-space: nowrap; }
.lista-item-linha-baixo .valor-receber { color: var(--verde); }
.lista-item-linha-baixo .valor-pagar { color: var(--vermelho); }
.lista-item-botoes {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.btn-ico {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    border: none;
}
.btn-ico-success { background: rgba(25, 135, 84, 0.2); color: var(--bs-success); }
.btn-ico-danger { background: rgba(220, 53, 69, 0.2); color: var(--bs-danger); }
.btn-ico-warning { background: rgba(255, 193, 7, 0.35); color: #856404; }
.btn-ico-info { background: rgba(13, 202, 240, 0.2); color: var(--bs-info); }
.btn-ico-outline { background: transparent; color: var(--bs-danger); border: 1px solid rgba(220, 53, 69, 0.5); }

.lista-saldo-card { border-width: 2px; }
.lista-saldo-label { font-size: 0.95rem; color: var(--bs-secondary); }
.lista-saldo-valor { font-size: 1.5rem; font-weight: 700; }
.lista-saldo-texto { font-size: 0.95rem; font-weight: 600; }

/* Tela de login/cadastro */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(180deg, #f0f2f5 0%, #e4e8ec 100%);
}
.auth-container {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.auth-title {
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.25rem;
}
.auth-container .nav-tabs .nav-link {
    border: none;
    color: #6c757d;
    font-weight: 500;
}
.auth-container .nav-tabs .nav-link.active {
    color: #0d6efd;
    background: transparent;
    border-bottom: 2px solid #0d6efd;
}
