/* ============================================================
   Livro Caixa MEI — Folha de estilos principal
   Paleta: #FFFFFF fundo, #1A3A6B azul primário
   ============================================================ */

:root {
  --blue-primary:   #1A3A6B;
  --blue-dark:      #122d54;
  --blue-light:     #e8eef7;
  --blue-mid:       #2d5fa6;
  --green-credit:   #1a7a3c;
  --red-debit:      #b91c1c;
  --gray-border:    #dee2e6;
  --gray-bg:        #f8f9fa;
  --text-main:      #1e293b;
  --text-muted:     #64748b;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.1);
  --shadow-md:      0 4px 12px rgba(0,0,0,.12);
  --radius:         8px;
}

/* ---- Reset / Base ---- */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  color: var(--text-main);
  background: var(--gray-bg);
  margin: 0;
}

/* ============================================================
   BOOTSTRAP OVERRIDES
   ============================================================ */
.btn-primary {
  background-color: var(--blue-primary);
  border-color: var(--blue-primary);
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--blue-dark);
  border-color: var(--blue-dark);
}
.btn-outline-primary {
  color: var(--blue-primary);
  border-color: var(--blue-primary);
}
.btn-outline-primary:hover {
  background-color: var(--blue-primary);
  border-color: var(--blue-primary);
}
.form-control:focus, .form-select:focus {
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 .2rem rgba(26, 58, 107, .2);
}
.progress-bar.bg-primary {
  background-color: var(--blue-primary) !important;
}
.nav-tabs .nav-link.active {
  color: var(--blue-primary);
  border-color: var(--gray-border) var(--gray-border) #fff;
}
.nav-tabs .nav-link {
  color: var(--text-muted);
}

/* ============================================================
   PÁGINA DE LOGIN
   ============================================================ */
body.login-page {
  background: linear-gradient(135deg, var(--blue-primary) 0%, var(--blue-mid) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-wrapper {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px 36px;
  box-shadow: var(--shadow-md);
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

/* Logo nas páginas de acesso */
.login-logo {
  display: block;
  margin: 0 auto 8px;
  max-height: 110px;
  width: auto;
  object-fit: contain;
}

/* Mantém compatibilidade com ícone SVG caso logo não carregue */
.login-icon {
  background: var(--blue-primary);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(26, 58, 107, .35);
}

.login-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--blue-primary);
  margin: 0 0 4px;
}

.login-header p {
  color: var(--text-muted);
  font-size: .9rem;
  margin: 0;
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: .875rem;
}

.login-footer a {
  color: var(--blue-mid);
  text-decoration: none;
}
.login-footer a:hover { text-decoration: underline; }

/* Campo de senha com botão olho */
.input-password-wrapper {
  position: relative;
}
.input-password-wrapper input { padding-right: 44px; }
.btn-toggle-password {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}
.btn-toggle-password:hover { color: var(--blue-primary); }

/* Barra de força de senha */
.password-strength {
  height: 4px;
  background: #e9ecef;
  border-radius: 2px;
  transition: all .3s;
}
.password-strength.strength-weak   { background: #dc2626; width: 33%; }
.password-strength.strength-medium { background: #f59e0b; width: 66%; }
.password-strength.strength-strong { background: #16a34a; width: 100%; }

/* ============================================================
   NAVBAR DA APLICAÇÃO
   ============================================================ */
.app-navbar {
  background: var(--blue-primary);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.navbar-brand-area {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
}

/* Logo na navbar */
.navbar-logo {
  height: 34px;
  width: auto;
  object-fit: contain;
  display: block;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: background .15s;
}
.navbar-user:hover { background: rgba(255,255,255,.1); }

.navbar-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.navbar-user-name {
  color: #fff;
  font-weight: 600;
  font-size: .875rem;
  line-height: 1.2;
}
.navbar-user-cnpj {
  color: rgba(255,255,255,.75);
  font-size: .775rem;
}

.navbar-avatar {
  background: rgba(255,255,255,.2);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

/* ============================================================
   SUBNAV (tabs de navegação)
   ============================================================ */
.app-subnav {
  background: #fff;
  border-bottom: 1px solid var(--gray-border);
  display: flex;
  padding: 0 16px;
  gap: 4px;
  overflow-x: auto;
}

.subnav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .875rem;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.subnav-link:hover { color: var(--blue-primary); }
.subnav-link.active {
  color: var(--blue-primary);
  border-bottom-color: var(--blue-primary);
  font-weight: 600;
}
.subnav-link.subnav-logout {
  margin-left: auto;
  color: #dc2626;
}
.subnav-link.subnav-logout:hover { color: #991b1b; }

/* ============================================================
   CONTEÚDO PRINCIPAL
   ============================================================ */
.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

.page-title {
  color: var(--blue-primary);
  font-weight: 700;
  margin-bottom: 20px;
}

/* ============================================================
   CARDS DE RESUMO
   ============================================================ */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 4px;
}

.summary-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--blue-primary);
}

.summary-card-limit {
  border-left-color: var(--blue-mid);
}

.summary-card-label {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 6px;
}

.summary-card-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.summary-card-sub {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
   CORES DE CRÉDITO / DÉBITO
   ============================================================ */
.text-credit { color: var(--green-credit) !important; }
.text-debit  { color: var(--red-debit)    !important; }

.badge-credit {
  background-color: #dcfce7;
  color: var(--green-credit);
  font-weight: 700;
  font-size: .8rem;
  padding: 2px 7px;
  border-radius: 4px;
}
.badge-debit {
  background-color: #fee2e2;
  color: var(--red-debit);
  font-weight: 700;
  font-size: .8rem;
  padding: 2px 7px;
  border-radius: 4px;
}

/* ============================================================
   TABELAS
   ============================================================ */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--gray-border);
  font-weight: 600;
  padding: 14px 16px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.table th {
  background: var(--blue-light);
  color: var(--blue-primary);
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 2px solid var(--blue-primary);
  padding: 10px 12px;
  white-space: nowrap;
}
.table td {
  padding: 9px 12px;
  vertical-align: middle;
  border-color: #f1f5f9;
}
.table tbody tr:hover td { background: #f8faff; }

/* Totais do extrato */
.table-totals td {
  border-top: 2px solid var(--gray-border);
  font-size: .875rem;
  padding: 8px 12px;
}

/* ============================================================
   BOTÕES DE AÇÃO (editar / excluir em linha)
   ============================================================ */
.btn-action {
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 3px 6px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  line-height: 1;
}
.btn-action-edit {
  color: var(--blue-primary);
}
.btn-action-edit:hover {
  background: var(--blue-light);
  border-color: var(--blue-primary);
}
.btn-action-delete {
  color: var(--red-debit);
}
.btn-action-delete:hover {
  background: #fee2e2;
  border-color: var(--red-debit);
}

/* ============================================================
   FILTROS DO EXTRATO
   ============================================================ */
.filter-extra {
  animation: fadeIn .15s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   RELATÓRIO MENSAL
   ============================================================ */
.report-card {
  background: #fff;
  border: 1px solid var(--gray-border);
}

.report-header {
  padding-bottom: 12px;
  border-bottom: 2px solid var(--blue-primary);
}

.report-table th {
  background-color: var(--blue-primary);
  color: #fff;
}

.report-table .table-secondary td {
  background: #e9ecef;
}

.report-footer {
  padding-top: 16px;
  border-top: 1px solid var(--gray-border);
}

/* ============================================================
   MODAIS
   ============================================================ */
.modal-header {
  background: var(--blue-light);
  border-bottom: 2px solid var(--blue-primary);
}
.modal-title {
  color: var(--blue-primary);
  font-weight: 700;
}

/* ============================================================
   CARDS DE TIPO DE ATIVIDADE MEI
   ============================================================ */
.activity-check {
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
  min-height: 72px;
}
.activity-check:hover {
  border-color: var(--blue-primary) !important;
  background: var(--blue-light);
}
.activity-check.border-primary { border-color: var(--blue-primary) !important; }
.bg-primary-subtle { background-color: #e8eef7 !important; }

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .app-navbar, .app-subnav, .btn, .card-header button,
  .card-header a, form, .summary-cards, .alert { display: none !important; }
  body { background: #fff; }
  .app-main { padding: 0; max-width: 100%; }
  .card { box-shadow: none; border: none; }
  .table { font-size: 11px; }
  .report-card { border: none !important; }
}

/* ============================================================
   RESPONSIVIDADE
   ============================================================ */
@media (max-width: 768px) {
  .summary-cards { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 28px 20px; }
  .app-main { padding: 16px 12px; }
  .navbar-user-info { display: none; }
  .subnav-link span:not(.subnav-text) { display: none; }
}

@media (max-width: 480px) {
  .summary-cards { grid-template-columns: 1fr; }
}
