/* ============================================================
   FLUXO DE CAIXA PRO — styles.css
   ============================================================ */

:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-w: 220px;
  --sidebar-collapsed-w: 0px;
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

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

body {
  font-family: "DM Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}
.sidebar-hidden .main-content { margin-left: 0; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition), width var(--transition);
  overflow: hidden;
}
.sidebar-hidden .sidebar { transform: translateX(-100%); }

.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  white-space: nowrap;
}
.logo-title {
  font-size: 1rem; font-weight: 700; color: #fff;
  display: flex; align-items: center; gap: 9px;
}
.logo-title i { color: #60a5fa; }
.sidebar-logo p { font-size: 0.7rem; color: #475569; margin-top: 4px; }

.sidebar-nav {
  padding: 12px 10px; flex: 1;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}
.nav-label {
  font-size: 0.62rem; font-weight: 600;
  letter-spacing: 0.9px; text-transform: uppercase;
  color: #334155; padding: 10px 10px 5px;
}
.nav-btn {
  background: transparent; border: none; color: #94a3b8;
  padding: 9px 12px; cursor: pointer; font-weight: 500;
  font-size: 0.865rem; font-family: "DM Sans", sans-serif;
  border-radius: 8px; display: flex; align-items: center;
  gap: 10px; transition: all 0.15s; width: 100%;
  text-align: left; white-space: nowrap;
}
.nav-btn i { width: 18px; text-align: center; font-size: 0.82rem; }
.nav-btn:hover { background: rgba(255,255,255,0.07); color: #e2e8f0; }
.nav-btn.active { background: rgba(59,130,246,0.2); color: #93c5fd; font-weight: 600; }

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.cloud-status {
  font-size: 0.72rem; color: #475569;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
}
.cloud-status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #334155; flex-shrink: 0;
}
.cloud-status.synced .dot { background: #10b981; }
.cloud-status.syncing .dot { background: #f59e0b; animation: pulse 1s infinite; }
.cloud-status.error .dot { background: #ef4444; }
.cloud-status.offline .dot { background: #94a3b8; animation: pulse 2s infinite; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* Overlay mobile */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* ── TOPBAR ── */
.topbar {
  height: 58px; background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 28px; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 0.95rem; font-weight: 600; }
.topbar-title span { color: var(--text-muted); font-weight: 400; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-date {
  font-size: 0.775rem; color: var(--text-muted);
  font-family: "DM Mono", monospace;
  background: var(--bg); padding: 4px 10px; border-radius: 6px;
}

/* Botão toggle sidebar na topbar */
.sidebar-toggle-btn {
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 8px; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted);
  transition: all 0.15s; font-size: 0.85rem;
}
.sidebar-toggle-btn:hover { background: #e2e8f0; color: var(--text); }

.mobile-toggle {
  display: none; background: none; border: none;
  cursor: pointer; color: var(--text); font-size: 1.1rem;
}

/* ── CLOUD BUTTON topbar ── */
.btn-cloud {
  background: #0f172a; color: #60a5fa;
  border: none; border-radius: 9px;
  padding: 7px 14px; font-size: 0.82rem; font-weight: 600;
  font-family: "DM Sans", sans-serif;
  display: flex; align-items: center; gap: 7px;
  cursor: pointer; transition: all 0.15s;
  white-space: nowrap;
}
.btn-cloud:hover { background: #1e293b; transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,0.2); }
.btn-cloud.syncing { opacity: 0.75; pointer-events: none; }
.btn-cloud i { font-size: 0.78rem; }

/* ── PAGE & CARDS ── */
.page-content { padding: 26px 28px; flex: 1; }

.card {
  background: #fff; padding: 22px 24px;
  border-radius: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  margin-bottom: 20px; border: 1px solid var(--border);
}

h3 {
  color: var(--text); margin: 0 0 18px;
  font-size: 0.975rem; font-weight: 600;
  display: flex; align-items: center; gap: 9px;
}
h3 i { color: var(--primary); font-size: 0.88rem; }

.text-muted { color: var(--text-muted); font-size: 0.855rem; margin-bottom: 14px; display: block; }

.section-header {
  display: flex; justify-content: space-between;
  align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 6px;
}
.section-header h3 { margin: 0; }

/* ── STAT CARDS ── */
.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 18px; display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.accent-blue::after  { background: var(--primary); }
.stat-card.accent-green::after { background: var(--success); }
.stat-card.accent-amber::after { background: var(--warning); }
.stat-card.accent-red::after   { background: var(--danger); }

.stat-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; margin-bottom: 6px;
}
.stat-icon.blue  { background: #dbeafe; color: var(--primary); }
.stat-icon.green { background: #d1fae5; color: var(--success); }
.stat-icon.amber { background: #fef3c7; color: var(--warning); }
.stat-icon.red   { background: #fee2e2; color: var(--danger); }

.stat-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.stat-value { font-size: 1.35rem; font-weight: 700; font-family: "DM Mono", monospace; letter-spacing: -0.5px; line-height: 1.2; }
.stat-value.green { color: var(--success); }
.stat-value.amber { color: var(--warning); }
.stat-value.red   { color: var(--danger); }
.stat-sub { font-size: 0.72rem; color: var(--text-muted); }

/* ── FORMS ── */
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 16px; margin-bottom: 18px;
}
.form-group { display: flex; flex-direction: column; }
label { font-size: 0.73rem; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
input, select, textarea {
  padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 9px;
  font-size: 0.885rem; width: 100%; transition: border-color 0.15s;
  font-family: "DM Sans", sans-serif; color: var(--text); background: #fff;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.field-error { border-color: var(--danger) !important; }
.field-error-msg { font-size: 0.72rem; color: var(--danger); margin-top: 4px; }

/* ── BUTTONS ── */
.actions-bar { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 18px; }
.btn {
  cursor: pointer; padding: 9px 17px; border: none; border-radius: 9px;
  font-weight: 600; font-size: 0.845rem; font-family: "DM Sans", sans-serif;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; transition: all 0.15s;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,0.14); }
.btn:disabled { opacity: 0.55; pointer-events: none; }
.btn-primary   { background: var(--primary); color: white; }
.btn-secondary { background: #64748b; color: white; }
.btn-success   { background: var(--success); color: white; }
.btn-danger    { background: var(--danger); color: white; }
.btn-warning   { background: var(--warning); color: white; }
.btn-ghost     { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-sm { padding: 6px 11px; font-size: 0.78rem; border-radius: 7px; }

/* ── TABLE ── */
.table-controls {
  display: flex; justify-content: space-between;
  align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.table-filters { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.search-wrap { position: relative; }
.search-wrap i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.78rem; pointer-events: none; }
.search-wrap input { padding-left: 30px; }

.table-container {
  width: 100%; overflow-x: auto; border-radius: 10px;
  border: 1px solid var(--border); background: white;
}
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f8fafc; color: var(--text-muted); font-weight: 600; font-size: 0.69rem; text-transform: uppercase; letter-spacing: 0.6px; }
td { font-size: 0.865rem; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

.td-mono  { font-family: "DM Mono", monospace; font-size: 0.82rem; }
.td-valor { font-family: "DM Mono", monospace; font-size: 0.875rem; font-weight: 600; }
.td-obs   { max-width: 180px; overflow: hidden; text-overflow: ellipsis; font-size: 0.8rem; color: var(--text-muted); font-style: italic; white-space: nowrap; }

.alert-row { background: #fffbeb !important; }
.alert-row td:first-child { border-left: 3px solid var(--warning); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; display: block; opacity: 0.3; }

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-top: 1px solid var(--border);
  font-size: 0.82rem; color: var(--text-muted); flex-wrap: wrap; gap: 8px;
}
.pagination-btns { display: flex; gap: 4px; }
.page-btn {
  padding: 5px 10px; border: 1.5px solid var(--border);
  border-radius: 6px; background: white; cursor: pointer;
  font-size: 0.78rem; font-weight: 600; transition: all 0.1s;
}
.page-btn:hover { background: var(--bg); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; pointer-events: none; }

/* ── BADGES ── */
.badge { padding: 3px 9px; border-radius: 20px; font-size: 0.7rem; font-weight: 600; display: inline-block; }
.badge-cat   { background: #e0e7ff; color: #3730a3; }
.badge-week  { background: #f0fdf4; color: #166534; font-family: "DM Mono", monospace; }
.badge-alert { background: #fef3c7; color: #92400e; }
.badge-late  { background: #fee2e2; color: #991b1b; }

/* ── CATEGORIAS ── */
.cat-tag { display: inline-flex; align-items: center; background: var(--bg); border: 1px solid var(--border); padding: 6px 12px; border-radius: 20px; margin: 4px; font-size: 0.855rem; }
.cat-delete { margin-left: 8px; color: var(--text-muted); cursor: pointer; }
.cat-delete:hover { color: var(--danger); }

/* ── FORECAST ── */
.forecast-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; }
.summary-box { background: #fff; padding: 18px 20px; border-radius: 12px; border: 1px solid var(--border); display: flex; flex-direction: column; }
.summary-box h4 { color: var(--primary); border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 12px; font-size: 0.93rem; font-weight: 600; text-transform: capitalize; }
.total-highlight { font-size: 1.2rem; font-weight: 700; font-family: "DM Mono", monospace; letter-spacing: -0.5px; }
.week-pills { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 12px 0; }
.week-pill { background: var(--bg); border-radius: 8px; padding: 7px 10px; }
.week-pill strong { display: block; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin-bottom: 2px; }
.week-pill span { font-family: "DM Mono", monospace; font-size: 0.82rem; font-weight: 600; }

.category-matrix { margin-top: 20px; }
.matrix-header { background-color: var(--primary) !important; color: white !important; }

.consolidado-card { background: linear-gradient(135deg, #f0fdf4, #ecfdf5) !important; border-color: #bbf7d0 !important; }
.consolidado-card h3 { color: var(--success); }
.cons-total { font-size: 1.6rem; font-weight: 700; font-family: "DM Mono", monospace; letter-spacing: -1px; color: var(--success); margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid #bbf7d0; }
.cons-weeks { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.cons-week-chip { background: white; border: 1px solid #d1fae5; border-radius: 8px; padding: 5px 12px; font-size: 0.78rem; font-family: "DM Mono", monospace; color: var(--success); font-weight: 500; }

/* ── CHARTS ── */
.charts-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-top: 16px; }
.chart-box { background: white; padding: 16px; border-radius: 12px; border: 1px solid var(--border); min-height: 270px; }
.chart-print-table { display: none; }

/* ── SPECIAL CARDS ── */
.danger-card  { border-color: var(--danger) !important; background: #fef2f2 !important; }
.danger-card h3  { color: var(--danger); }
.warning-card { border-color: var(--warning) !important; background: #fffbeb !important; }
.warning-card h3 { color: var(--warning); }

/* ── TOAST NOTIFICATIONS ── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: #0f172a; color: white; padding: 12px 18px;
  border-radius: 10px; font-size: 0.855rem; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  animation: toastIn 0.25s ease;
  max-width: 320px; min-width: 220px;
}
.toast.success { border-left: 3px solid #10b981; }
.toast.error   { border-left: 3px solid #ef4444; }
.toast.warning { border-left: 3px solid #f59e0b; }
.toast.info    { border-left: 3px solid #3b82f6; }
@keyframes toastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes toastOut { to { opacity:0; transform:translateY(10px); } }

/* ── SECTION VIEWS ── */
.section-view { display: none; }
.section-view.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(5px); } to { opacity:1; transform:translateY(0); } }

/* ── PRINT HEADER ── */
.print-header { display: none; }

/* ══════════════════════════════════════════════════
   RESPONSIVO
══════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0) !important; }
  .sidebar-hidden .sidebar { transform: translateX(-100%) !important; }
  .main-content { margin-left: 0 !important; }
  .mobile-toggle { display: flex; }
  .sidebar-toggle-btn { display: none; }
  .page-content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .actions-bar { flex-direction: column; }
  .btn { width: 100%; }
  .charts-container { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .topbar-date { display: none; }
  .btn-cloud span { display: none; }
}
@media (max-width: 480px) {
  .stat-row { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════
   IMPRESSÃO
══════════════════════════════════════════════════ */
@media print {
  .sidebar, .topbar, .mobile-toggle, .sidebar-overlay,
  .actions-bar, .btn, .search-wrap, #catFilter, #searchFilter,
  .no-print, nav, .table-controls button, .stat-row,
  .toast-container, .pagination { display: none !important; }

  .section-view { display: none !important; }
  .section-view.active { display: block !important; animation: none !important; }

  body { background: white !important; color: #000 !important; font-size: 10pt; font-family: "DM Sans", Arial, sans-serif; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }

  .print-header { display: block !important; text-align: center; margin: 0 0 14pt; padding-bottom: 9pt; border-bottom: 2pt solid #2563eb; }
  .print-header h1 { font-size: 15pt; color: #2563eb; font-weight: 700; margin-bottom: 2pt; }
  .print-header p { font-size: 8.5pt; color: #64748b; }

  .card { box-shadow: none !important; border: 1pt solid #e2e8f0 !important; border-radius: 5pt !important; margin-bottom: 10pt !important; padding: 10pt 12pt !important; page-break-inside: avoid; }
  h3 { font-size: 10.5pt !important; color: #1e293b !important; margin-bottom: 8pt !important; }
  h3 i { display: none; }

  .table-container { overflow: visible !important; border: 0.5pt solid #e2e8f0 !important; }
  table { min-width: 0 !important; width: 100% !important; }
  th { background: #1e40af !important; color: white !important; font-size: 7.5pt !important; padding: 4pt 6pt !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  td { font-size: 8.5pt !important; padding: 3.5pt 6pt !important; border-bottom: 0.5pt solid #e2e8f0 !important; }
  tbody tr:nth-child(even) td { background: #f8fafc !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .alert-row td { background: #fffbeb !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .alert-row td:first-child { border-left: 3pt solid #d97706 !important; }

  .badge { border: 0.5pt solid #94a3b8; padding: 1pt 5pt; border-radius: 3pt; font-size: 7pt; }
  .badge-cat  { background: #e0e7ff !important; color: #3730a3 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge-week { background: #f0fdf4 !important; color: #065f46 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge-alert { background: #fef3c7 !important; color: #92400e !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge-late  { background: #fee2e2 !important; color: #991b1b !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .td-obs { max-width: none !important; white-space: normal !important; }
  .td-valor, .td-mono { font-family: "DM Mono","Courier New",monospace !important; font-weight: 700 !important; }

  .charts-container { display: block !important; }
  .chart-box { min-height: auto !important; border: 0.5pt solid #e2e8f0 !important; border-radius: 4pt !important; padding: 8pt 10pt !important; margin-bottom: 12pt !important; page-break-inside: avoid; }
  .chart-box canvas { display: none !important; }
  .chart-print-table { display: block !important; width: 100%; }

  .forecast-grid { display: block !important; }
  .summary-box { border: 1pt solid #cbd5e1 !important; padding: 10pt 12pt !important; border-radius: 5pt !important; page-break-inside: avoid; margin-bottom: 12pt !important; }
  .matrix-header { background: #1e40af !important; color: white !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .consolidado-card { background: #f0fdf4 !important; border: 1pt solid #bbf7d0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table-filters { display: none !important; }
}
