/* ============================================================
   EKKLESIA CONTÁBIL - CSS Principal
   ============================================================ */

:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #dbeafe;
  --success:       #16a34a;
  --success-light: #dcfce7;
  --danger:        #dc2626;
  --danger-light:  #fee2e2;
  --warning:       #d97706;
  --warning-light: #fef3c7;
  --info:          #0891b2;
  --info-light:    #cffafe;
  --sidebar-bg:    #1e293b;
  --sidebar-hover: #334155;
  --sidebar-text:  #94a3b8;
  --sidebar-active:#e2e8f0;
  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 1px 3px rgba(0,0,0,.1),0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px rgba(0,0,0,.07),0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 15px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);
  --sidebar-w:     260px;
  --topbar-h:      60px;
  --font:          'Inter', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: width .25s ease;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px;
  border-bottom: 1px solid #334155;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f8fafc;
  font-size: 16px;
  white-space: nowrap;
}
.sidebar-logo i { color: #60a5fa; font-size: 22px; }
.sidebar-logo strong { font-weight: 700; }

.sidebar-toggle {
  background: none; border: none;
  color: var(--sidebar-text); cursor: pointer;
  font-size: 16px; padding: 4px;
}

.sidebar-igreja {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  color: #60a5fa;
  font-size: 12px;
  font-weight: 600;
  background: rgba(96,165,250,.08);
  border-bottom: 1px solid #334155;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-group-title {
  padding: 16px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #475569;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  transition: all .15s;
  white-space: nowrap;
  overflow: hidden;
  border-left: 3px solid transparent;
}
.nav-item i { width: 18px; text-align: center; font-size: 14px; }
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-active); text-decoration: none; }
.nav-item.active { background: var(--sidebar-hover); color: #60a5fa; border-left-color: #60a5fa; }
.nav-logout { color: #f87171 !important; margin-top: 8px; }
.text-green { color: #4ade80; }
.text-red { color: #f87171; }

/* MAIN */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}

.topbar-left { display: flex; align-items: center; gap: 14px; }
.page-title { font-size: 17px; font-weight: 600; color: var(--text); }
.sidebar-toggle-mobile { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.topbar-user i { font-size: 18px; color: var(--primary); }
.topbar-user small { background: var(--primary-light); color: var(--primary); padding: 1px 6px; border-radius: 4px; font-size: 11px; }
.topbar-date { font-size: 12px; color: var(--text-muted); }

.content-body {
  padding: 24px;
  flex: 1;
}

/* ============================================================
   CARDS / WIDGETS
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--primary); }

/* STATS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  border-left: 4px solid var(--primary);
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card.green { border-left-color: var(--success); }
.stat-card.red   { border-left-color: var(--danger); }
.stat-card.blue  { border-left-color: var(--primary); }
.stat-card.orange{ border-left-color: var(--warning); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.stat-card.green .stat-icon { background: var(--success-light); color: var(--success); }
.stat-card.red   .stat-icon { background: var(--danger-light);  color: var(--danger); }
.stat-card.blue  .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card.orange .stat-icon{ background: var(--warning-light); color: var(--warning); }

.stat-info { flex: 1; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

.td-valor-positivo { color: var(--success); font-weight: 600; }
.td-valor-negativo { color: var(--danger); font-weight: 600; }
.td-center { text-align: center; }
.td-right  { text-align: right; }

/* ============================================================
   FORMS
   ============================================================ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-grid-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-full   { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.form-group label .req { color: var(--danger); }

.form-control {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint { font-size: 11.5px; color: var(--text-muted); }

.form-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px; font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none !important;
}
.btn:hover { filter: brightness(.93); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  position: relative;
}
.alert-success { background: var(--success-light); color: var(--success); }
.alert-danger  { background: var(--danger-light);  color: var(--danger); }
.alert-warning { background: var(--warning-light); color: var(--warning); }
.alert-info    { background: var(--info-light);    color: var(--info); }
.alert-close { background: none; border: none; cursor: pointer; font-size: 18px; margin-left: auto; opacity: .7; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info    { background: var(--info-light);    color: var(--info); }
.badge-muted   { background: var(--bg); color: var(--text-muted); }

/* ============================================================
   FILTROS / BUSCA
   ============================================================ */
.filtros-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  align-items: flex-end;
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}
.filtros-bar .form-group { min-width: 140px; }
.filtros-bar .form-control { padding: 7px 10px; font-size: 13px; }

/* ============================================================
   DASHBOARD CHARTS
   ============================================================ */
.charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 20px; }
.chart-container { position: relative; height: 300px; }
canvas { max-width: 100%; }

/* ============================================================
   PLANO DE CONTAS
   ============================================================ */
.pc-nivel-1 { font-weight: 700; font-size: 14px; background: #1e293b; color: #f8fafc; }
.pc-nivel-2 { font-weight: 600; background: #334155; color: #e2e8f0; }
.pc-nivel-3 { font-weight: 600; background: #f1f5f9; }
.pc-nivel-4 { padding-left: 32px !important; }

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .sidebar, .topbar, .filtros-bar, .btn-group, .form-actions, .alert { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  body { font-size: 12px; }
}

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 768px) {
  .sidebar { width: 0; overflow: hidden; }
  .sidebar.open { width: var(--sidebar-w); }
  .main-content { margin-left: 0; }
  .sidebar-toggle-mobile { display: flex; }
  .charts-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .content-body { padding: 16px; }
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo i { font-size: 48px; color: var(--primary); }
.login-logo h1 { font-size: 22px; font-weight: 700; margin-top: 10px; }
.login-logo p { color: var(--text-muted); font-size: 13px; }

/* ============================================================
   DIRF / DECLARAÇÕES
   ============================================================ */
.declaracao-box {
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  white-space: pre;
  overflow-x: auto;
  max-height: 400px;
}

.stepper {
  display: flex; gap: 0;
  margin-bottom: 24px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.step {
  flex: 1; padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
}
.step:last-child { border-right: none; }
.step.active { background: var(--primary-light); color: var(--primary); }
.step.done   { background: var(--success-light); color: var(--success); }
.step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: var(--border); color: var(--text-muted);
}
.step.active .step-num { background: var(--primary); color: #fff; }
.step.done .step-num   { background: var(--success); color: #fff; }

/* DRE Styling */
.dre-table td:first-child { padding-left: calc(14px + var(--nivel, 0) * 20px); }
.dre-total { font-weight: 700; background: #f1f5f9; }
.dre-superavit { background: #dcfce7; color: var(--success); font-weight: 700; font-size: 16px; }
.dre-deficit   { background: #fee2e2; color: var(--danger);  font-weight: 700; font-size: 16px; }
