/* San Mares — Sistema de Gestão de Condomínio */
/* Estilo baseado no JudicialMonitor */

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

:root {
  --blue: #1e40af;
  --blue-dark: #1e3a8a;
  --blue-light: #dbeafe;
  --green: #16a34a;
  --green-light: #dcfce7;
  --yellow: #f59e0b;
  --yellow-light: #fef3c7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-500: #64748b;
  --gray-700: #374151;
  --gray-900: #111827;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --radius: 10px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f0f4f8;
  color: var(--gray-900);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── NAVBAR ── */
.navbar {
  background: var(--blue-dark);
  color: white;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.navbar-brand { display: flex; align-items: center; gap: 8px; margin-right: 24px; flex-shrink: 0; }
.navbar-icon { font-size: 20px; }
.navbar-title { font-weight: 700; font-size: 15px; white-space: nowrap; }
.navbar-nav { display: flex; list-style: none; gap: 2px; flex: 1; }
.navbar-nav a { display: block; color: rgba(255,255,255,0.75); text-decoration: none; padding: 6px 14px; border-radius: 6px; font-size: 13px; font-weight: 500; transition: background 0.15s, color 0.15s; white-space: nowrap; }
.navbar-nav a:hover, .navbar-nav a.active { background: rgba(255,255,255,0.15); color: white; }
.navbar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: rgba(255,255,255,0.8); flex-shrink: 0; }

/* ── CONTAINER ── */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }

/* ── PAGE HEADER ── */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.page-header h2 { font-size: 22px; font-weight: 800; color: var(--gray-900); }
.text-muted { color: var(--gray-500); font-size: 13px; }
.text-center { text-align: center; }

/* ── CARD ── */
.card { background: white; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); overflow-x: auto; }

/* ── STAT CARDS ── */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 0; }
.cards-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card { padding: 16px; border-left: 4px solid var(--blue); text-align: center; }
.stat-icon { font-size: 24px; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 800; color: var(--gray-900); }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.stat-card-link { display: block; text-decoration: none; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.stat-card-link:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.12); }

/* ── AÇÕES RÁPIDAS ── */
.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.action-btn { display: flex; align-items: center; gap: 10px; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 8px; padding: 12px 16px; text-decoration: none; color: var(--gray-700); font-weight: 500; font-size: 13px; transition: all 0.15s; }
.action-btn:hover { background: var(--blue-light); border-color: var(--blue); color: var(--blue-dark); }
.action-icon { font-size: 20px; }

/* ── TABELAS ── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { background: var(--gray-50); color: var(--gray-500); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; padding: 10px 12px; text-align: left; border-bottom: 2px solid var(--gray-200); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.table tbody tr:hover { background: var(--gray-50); }
.table tfoot td { padding: 10px 12px; }
.table.table-leituras th { padding: 8px 6px; font-size: 10px; }
.table.table-leituras td { padding: 6px 6px; }
.sub-header th { background: white; font-size: 10px; font-weight: 600; color: var(--gray-500); text-transform: none; }
.row-pago td:not(.actions-cell) { opacity: 0.65; }

.input-leitura { width: 90px; border: 1px solid var(--gray-200); border-radius: 6px; padding: 5px 8px; font-size: 13px; text-align: right; }
.input-leitura:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(30,64,175,0.1); }
.estimativa { font-size: 13px; min-width: 90px; }

/* ── FORMULÁRIOS ── */
.field-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field-group label { font-size: 12px; font-weight: 600; color: var(--gray-700); }
input[type=text], input[type=email], input[type=number], input[type=password], select, textarea { width: 100%; border: 1.5px solid var(--gray-200); border-radius: 8px; padding: 9px 12px; font-size: 14px; color: var(--gray-900); background: var(--gray-50); transition: border-color 0.15s, box-shadow 0.15s; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,64,175,0.1); background: white; }
small.text-muted { font-size: 11px; color: var(--gray-500); }
.form-row { display: flex; gap: 12px; }
.form-row .field-group { flex: 1; }

/* ── BOTÕES ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; border-radius: 8px; padding: 9px 18px; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; transition: all 0.15s; white-space: nowrap; }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-full { width: 100%; }

.btn-sm { display: inline-flex; align-items: center; gap: 3px; border: none; border-radius: 5px; padding: 4px 8px; font-size: 12px; font-weight: 600; cursor: pointer; text-decoration: none; transition: opacity 0.15s; white-space: nowrap; }
.btn-sm:hover { opacity: 0.8; }
.btn-blue { background: #1d4ed8; color: #fff; }
.btn-green { background: #15803d; color: #fff; }
.btn-success { background: #16a34a; color: #fff; }
.btn-red { background: #dc2626; color: #fff; }

.actions-cell { white-space: nowrap; display: flex; gap: 4px; }

/* ── BADGES ── */
.badge { display: inline-block; border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-green { background: var(--green-light); color: #15803d; }
.badge-blue { background: var(--blue-light); color: #1d4ed8; }
.badge-yellow { background: var(--yellow-light); color: #92400e; }
.badge-red { background: var(--red-light); color: #b91c1c; }

/* ── ALERTAS ── */
.alert { border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; font-size: 13px; font-weight: 500; }
.alert-success { background: var(--green-light); color: #166534; border: 1px solid #86efac; }
.alert-error { background: var(--red-light); color: #991b1b; border: 1px solid #fca5a5; }

/* ── INFO BANNER ── */
.info-banner { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 10px 14px; font-size: 12px; color: #1e3a8a; }

/* ── LOGIN ── */
.login-page { background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 100%); display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-container { width: 100%; max-width: 400px; }
.login-card { background: white; border-radius: 16px; padding: 36px; box-shadow: 0 20px 40px rgba(0,0,0,0.2); }
.login-logo { font-size: 52px; text-align: center; margin-bottom: 8px; }
.login-title { font-size: 22px; font-weight: 800; text-align: center; color: var(--gray-900); margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--gray-500); text-align: center; margin-bottom: 24px; }
.login-footer { color: rgba(255,255,255,0.5); font-size: 12px; text-align: center; margin-top: 24px; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .cards-grid-3 { grid-template-columns: 1fr 1fr; }
  .form-row { flex-direction: column; }
  .navbar-nav { display: none; }
  .container { padding: 16px 12px; }
  .page-header { flex-direction: column; gap: 12px; }
  .table { font-size: 12px; }
  .table th, .table td { padding: 8px 6px; }
  .actions-cell { flex-direction: row; flex-wrap: wrap; gap: 4px; }
}

/* ── TABELA DE CHÁCARAS: CARDS NO MOBILE ── */
@media (max-width: 768px) {
  .table-chacaras thead { display: none; }
  .table-chacaras tbody tr { display: block; border: 1px solid var(--gray-200); border-radius: 8px; margin-bottom: 10px; padding: 4px 0; }
  .table-chacaras tbody tr:hover { background: white; }
  .table-chacaras td { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--gray-100); padding: 8px 12px; font-size: 13px; }
  .table-chacaras td:last-child { border-bottom: none; }
  .table-chacaras td::before { content: attr(data-label); font-weight: 700; font-size: 11px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.4px; min-width: 90px; }
  .table-chacaras .actions-cell { flex-direction: row; flex-wrap: wrap; gap: 6px; justify-content: flex-start; align-items: center; }
}

/* ── TABELA DE FATURAS: CARDS NO MOBILE ── */
@media (max-width: 768px) {
  .table-faturas thead { display: none; }
  .table-faturas tfoot { display: none; }
  .table-faturas tbody tr { display: block; background: white; border: 1px solid var(--gray-200); border-radius: 10px; margin-bottom: 14px; padding: 4px 0; box-shadow: var(--shadow); }
  .table-faturas tbody tr.row-pago td:not(.actions-cell) { opacity: 0.65; }
  .table-faturas tbody tr:hover { background: var(--gray-50); }
  .table-faturas td { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-bottom: 1px solid var(--gray-100); padding: 9px 14px; font-size: 13px; }
  .table-faturas td:last-child { border-bottom: none; }
  .table-faturas td::before { content: attr(data-label); font-weight: 700; font-size: 11px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.4px; min-width: 100px; flex-shrink: 0; }
  .table-faturas .actions-cell { flex-direction: row; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; }
}
/* ══════════════════════════════════════════════════════════════════
   ACESSIBILIDADE MOBILE — corpos maiores e alvos de toque generosos.
   Requisito real do usuario (dificuldade de visao). Fica DEPOIS de
   tudo pra vencer as regras anteriores sem precisar de !important
   em cascata.
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* 16px e o minimo que evita o zoom automatico do navegador em campos */
  html { font-size: 17px; }
  body { font-size: 16px; line-height: 1.5; }

  .container { padding: 14px 10px; }

  /* Titulos e numeros grandes: sao o que se le de relance */
  .page-title, h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  h3 { font-size: 18px; }
  .card-value, .stat-value { font-size: 30px; font-weight: 800; }
  .card-label, .stat-label { font-size: 13px; letter-spacing: .3px; }

  /* Tabelas em modo card: rotulo legivel e valor destacado */
  .table { font-size: 15px; }
  .table th, .table td { padding: 11px 9px; }
  .table td::before { font-size: 13px !important; min-width: 96px !important; }
  .table-chacaras td, .table-faturas td { font-size: 15px; padding: 11px 12px; }
  .table strong, .table b { font-size: 16px; }

  /* Campos: 16px impede o zoom do iOS/Android ao focar */
  input, select, textarea { font-size: 16px !important; padding: 12px 11px !important; }
  .input-leitura { font-size: 17px !important; text-align: center; }
  .input-motivo { font-size: 14px !important; }
  label, .field-group label { font-size: 14px; font-weight: 700; }

  /* Alvo de toque: 44px e o minimo recomendado pra dedo */
  .btn, button, .btn-icon, .actions-cell a {
    min-height: 44px; font-size: 16px; padding: 12px 16px;
  }
  .btn-sm { min-height: 40px; font-size: 15px; padding: 10px 14px; }
  .actions-cell { gap: 8px !important; }
  .actions-cell a, .actions-cell button { min-width: 44px; justify-content: center; }

  /* Etiquetas de status legiveis */
  .badge, .status-badge, .tag { font-size: 13px; padding: 6px 12px; }

  /* Navegacao por mes/ano — usada toda hora */
  .period-nav select, .form-row select { font-size: 16px; min-height: 44px; }

  /* Menu: como .navbar-nav some no mobile, o titulo precisa ficar claro */
  .navbar-brand, .navbar h1 { font-size: 18px; }
}

/* Telas bem pequenas (≤400px): um degrau a mais */
@media (max-width: 400px) {
  html { font-size: 18px; }
  .card-value, .stat-value { font-size: 27px; }
  .table td::before { min-width: 80px !important; }
}
