/* ===== DashTudo — estilos globais ===== */
:root {
  --brand: #878ECD;
  --brand-dark: #5B63B7;
  --brand-light: #eef0fb;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1f2330;
  --muted: #5f6472;
  --border: #e3e6ef;
  --danger: #dc2626;
  --success: #059669;
  --warning: #b45309;
  --radius: 12px;
  --shadow: 0 4px 18px rgba(31, 35, 48, 0.07);
  color-scheme: light;
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  color: var(--text);
  background: linear-gradient(to bottom right, #f3f6ff, #e9ebfb);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; }
main { flex: 1; }

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

h1 { font-size: 1.9rem; font-weight: 600; line-height: 1.25; margin: 0.2rem 0 0.4rem; }
h3 { font-size: 1.1rem; margin: 0 0 0.75rem; }
h4 { font-size: 1.1rem; color: #4f4d52; margin: 0 0 0.5rem; font-weight: 500; }
h1:focus { outline: none; }

.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 1rem; }
.page { padding-top: 2rem; padding-bottom: 3rem; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 0.5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
.stack-sm { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-2.gap-lg { gap: 1.25rem; }
.success-text { color: var(--success); }
.danger-text { color: var(--danger) !important; }

/* ===== Formulários ===== */
label { display: block; font-size: 0.88rem; font-weight: 500; margin: 0.75rem 0 0.3rem; }
label.checkbox { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; margin: 0.4rem 0; cursor: pointer; }

input:not([type]), input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(135, 142, 205, 0.25);
}
input[type=checkbox] { width: 1rem; height: 1rem; accent-color: var(--brand-dark); }
textarea { resize: vertical; }
.validation-message { color: var(--danger); font-size: 0.8rem; margin-top: 0.2rem; }
.invalid { border-color: var(--danger) !important; }
.inline-form { display: inline; margin: 0; }
.inline-fields { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: flex-start; }
.inline-fields input { max-width: 320px; }

/* ===== Botões ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit; font-weight: 500;
  cursor: pointer;
  text-decoration: none !important;
  transition: background 0.15s, color 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.88rem; }
.btn-block { width: 100%; margin-top: 1rem; }
.stack-sm .btn-block { margin-top: 0; }
.btn-primary { background: var(--brand-dark); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #4a51a0; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-dark); }
.btn-light { background: rgba(255, 255, 255, 0.95); color: var(--brand-dark); }
.btn-light:hover { background: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-danger { background: var(--danger); color: #fff; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 0.2rem; opacity: 0.7; }
.icon-btn:hover { opacity: 1; }

/* ===== Navbar ===== */
.navbar { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
.navbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 0.6rem; color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none !important; }
.nav-links { display: flex; align-items: center; gap: 1.75rem; }
.nav-links a { color: #fff; opacity: 0.9; }
.nav-links a:hover, .nav-links a.active { opacity: 1; text-decoration: none; }
.nav-links a.active { font-weight: 600; border-bottom: 2px solid #fff; }
.nav-links a.btn { opacity: 1; color: var(--brand-dark); }
.nav-toggle { display: none; }
.nav-toggle-label { display: none; }

@media (max-width: 800px) {
  .nav-toggle-label { display: block; cursor: pointer; padding: 0.75rem; }
  .nav-toggle-label span, .nav-toggle-label span::before, .nav-toggle-label span::after {
    display: block; width: 24px; height: 2px; background: #fff; position: relative; transition: 0.2s;
  }
  .nav-toggle-label span::before, .nav-toggle-label span::after { content: ""; position: absolute; }
  .nav-toggle-label span::before { top: -7px; }
  .nav-toggle-label span::after { top: 7px; }
  .nav-links {
    position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: #fff; box-shadow: var(--shadow);
    display: none;
  }
  .nav-links a, .nav-links form { padding: 0.9rem 1.25rem; border-bottom: 1px solid var(--border); color: var(--text) !important; }
  .nav-links a.active { border-bottom: 1px solid var(--border); color: var(--brand-dark) !important; }
  .nav-links .btn { width: 100%; background: var(--brand-dark); color: #fff !important; }
  .nav-toggle:checked ~ .nav-links { display: flex; }
}

.site-footer { text-align: center; padding: 1.5rem; color: var(--muted); font-size: 0.85rem; }

/* ===== Cards, alertas, abas ===== */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; border: 1px solid rgba(227, 230, 239, 0.6); min-width: 0; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.75rem; }
.card-title-row h3 { margin: 0; }
.alert { padding: 0.75rem 1rem; border-radius: 8px; margin: 0.75rem 0; font-size: 0.92rem; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tab { background: none; border: none; padding: 0.7rem 1rem; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand-dark); border-bottom-color: var(--brand-dark); font-weight: 600; }
.card > .tabs { margin-top: -0.5rem; }

.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; background: var(--brand-light); color: var(--brand-dark); }
.badge-pdf { background: #fee2e2; color: #b91c1c; }
.badge-xlsx { background: #dcfce7; color: #166534; }
.badge-csv, .badge-tsv { background: #dbeafe; color: #1e40af; }
.badge-txt, .badge-md, .badge-manual { background: #f3f4f6; color: #374151; }

/* ===== Home ===== */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 2rem; align-items: center; padding-top: 4rem; padding-bottom: 2rem; }
.hero h1 { font-size: 2.3rem; }
.hero-image img { width: 100%; max-width: 560px; }
.hero-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; padding-bottom: 4rem; }
.feature-icon { font-size: 1.8rem; }

/* ===== Auth ===== */
.auth-page { display: flex; justify-content: center; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card.wide { max-width: 560px; }
.auth-logo { display: block; width: 90px; margin: 0 auto 0.5rem; }
.auth-card h1 { text-align: center; }
.auth-card > p.muted { text-align: center; }

/* ===== Perfil ===== */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: 1.25rem 0; }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; display: flex; flex-direction: column; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--brand-dark); }
.stat-label { font-size: 0.82rem; color: var(--muted); }
.danger-zone { margin-top: 1.25rem; border-color: #fecaca; }
.card form .btn { margin-top: 1rem; }
.inline-fields .btn { margin-top: 0 !important; }

/* ===== Dashboard / upload ===== */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.dropzone {
  position: relative; display: block; text-align: center;
  border: 2px dashed #b9bfe6; border-radius: var(--radius);
  padding: 3rem 1rem; margin: 0; cursor: pointer; transition: background 0.2s, border-color 0.2s;
}
.dropzone:hover { background: var(--brand-light); border-color: var(--brand); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.dropzone-icon { font-size: 2.5rem; }
.dropzone h3 { margin: 0.5rem 0 0.25rem; }
.paste-area .btn { margin-top: 1rem; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin: 2rem 0 0.75rem; }
.section-header h3 { margin: 0; }
.dataset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.dataset-card { display: block; color: inherit; text-decoration: none !important; transition: transform 0.15s, box-shadow 0.15s; padding: 1.1rem; }
.dataset-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(31, 35, 48, 0.12); }
.dataset-card h4 { margin: 0.5rem 0 0.25rem; color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.dataset-card p { margin: 0.1rem 0; }
.dataset-card-top { display: flex; justify-content: space-between; }
.filters { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1.25rem; padding: 1rem; flex-wrap: wrap; }
.filters input[type=search] { flex: 1; min-width: 220px; }
.filters select { width: auto; }
.empty { text-align: center; padding: 2.5rem; }

/* ===== Dataset ===== */
.details-editor { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.5rem 0; max-width: 640px; }
.details-editor input { font-size: 1.3rem; font-weight: 600; }
.layout-sidebar { display: grid; grid-template-columns: 340px 1fr; gap: 1.25rem; align-items: start; }
.chart-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.chart-type { display: flex; flex-direction: column; align-items: center; padding: 0.5rem 0.25rem; border: 2px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; font: inherit; }
.chart-type span { font-size: 1.2rem; }
.chart-type:hover { border-color: var(--brand); }
.chart-type.active { border-color: var(--brand-dark); background: var(--brand-light); color: var(--brand-dark); }
.checklist { max-height: 180px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 0.4rem 0.75rem; }
.chart-box { position: relative; height: 420px; }
.chart-empty { display: flex; align-items: center; justify-content: center; height: 100%; }
.insights { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.insights li { background: #f8f9fc; border-radius: 6px; padding: 0.5rem 0.65rem; font-size: 0.88rem; color: #3b3f4c; }

.table-wrapper, .grid-wrapper { overflow-x: auto; }
.table, .data-grid { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th, .table td, .data-grid th, .data-grid td { padding: 0.5rem 0.65rem; border-bottom: 1px solid #f0f1f5; text-align: left; white-space: nowrap; }
.table th, .data-grid th { color: #3b3f4c; font-weight: 600; background: #fafbfd; }
.table td.num, .table th.num, .data-grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-grid .col-title { gap: 0.25rem; }
.data-grid button.col-title { background: none; border: none; font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.paginator { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; margin-top: 0.75rem; font-size: 0.88rem; }
.paginator button { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 0.25rem 0.5rem; cursor: pointer; }
.document-text { white-space: pre-wrap; font-family: inherit; font-size: 0.92rem; max-height: 70vh; overflow-y: auto; margin: 0; }

/* ===== Relatórios de IA ===== */
.report summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; align-items: baseline; }
.report summary::-webkit-details-marker { display: none; }
.report summary::before { content: "▸"; color: var(--brand-dark); }
.report[open] summary::before { content: "▾"; }
.report-meta { margin-left: auto; }
.report-actions { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
.report.live { border: 1px solid var(--brand); }
.markdown { overflow-wrap: anywhere; }
.markdown h1 { font-size: 1.4rem; }
.markdown h2 { font-size: 1.2rem; margin-top: 1.4rem; }
.markdown h3 { font-size: 1.05rem; margin-top: 1.2rem; }
.markdown table { border-collapse: collapse; margin: 0.75rem 0; font-size: 0.88rem; display: block; overflow-x: auto; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 0.35rem 0.6rem; }
.markdown th { background: #fafbfd; }
.markdown blockquote { margin: 0.75rem 0; padding: 0.5rem 1rem; border-left: 3px solid var(--brand); background: var(--brand-light); color: #3b3f4c; }
.markdown code { background: #f3f4f6; padding: 0.1rem 0.3rem; border-radius: 4px; font-size: 0.88em; }

/* ===== Loading ===== */
.loading { display: flex; flex-direction: column; align-items: center; padding: 2rem; }
.loading img { max-width: 160px; }
@keyframes pulse { 0% { opacity: 0.3; } 50% { opacity: 1; } 100% { opacity: 0.3; } }
.loading-pulse { animation: pulse 1.5s ease-in-out infinite; }

/* ===== Erro do Blazor ===== */
#blazor-error-ui {
  background: #fffbe6; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
  display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ===== Responsivo ===== */
@media (max-width: 1000px) {
  .layout-sidebar { grid-template-columns: 1fr; }
  .features { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 800px) {
  .hero { grid-template-columns: 1fr; padding-top: 2rem; }
  .hero h1 { font-size: 1.8rem; }
  .grid-2, .stats-row { grid-template-columns: 1fr 1fr; }
  .grid-2.gap-lg { grid-template-columns: 1fr; }
  .chart-box { height: 320px; }
}
@media (max-width: 520px) {
  .features, .grid-2, .stats-row { grid-template-columns: 1fr; }
  .card { padding: 1.1rem; }
}

@media print {
  .navbar, .site-footer, aside, .tabs, .report-actions, .page-header .row { display: none !important; }
  .layout-sidebar { grid-template-columns: 1fr; }
  .card { box-shadow: none; border: none; }
}
