/* ============================================================
   iaSaúdeGov · Componentes base (CSS vanilla)
   Classes utilitárias para os componentes do design system,
   pensadas para o sistema atual (HTML + CSS puro, sem Tailwind).
   Importe APÓS tokens.css.
   ============================================================ */

/* ===== Reset + base ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-feature-settings: var(--font-features);
  font-size: var(--text-body);
  line-height: 1.5;
  color: var(--ink-800);
  background: var(--ink-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }

/* ===== Tipografia utilitária ===== */
.t-display  { font-size: var(--text-display); line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; }
.t-h1       { font-size: var(--text-h1);      line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
.t-h2       { font-size: var(--text-h2);      line-height: 1.4;  font-weight: 600; letter-spacing: -0.005em; }
.t-h3       { font-size: var(--text-h3);      line-height: 1.4;  font-weight: 600; }
.t-body     { font-size: var(--text-body);    line-height: 1.5;  }
.t-small    { font-size: var(--text-small);   line-height: 1.45; }
.t-micro    { font-size: var(--text-micro);   line-height: 1.4;  font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-500); }
.t-mono     { font-family: var(--font-mono); font-feature-settings: 'zero' 1; }
.t-num      { font-variant-numeric: tabular-nums; }

/* ===== Button ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 12px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  border: 1px solid transparent; border-radius: var(--radius-md);
  cursor: pointer; user-select: none;
  transition: transform var(--duration-base) var(--ease-bounce),
              box-shadow var(--duration-base) ease,
              background-color var(--duration-fast) ease,
              border-color var(--duration-fast) ease,
              color var(--duration-fast) ease;
  will-change: transform;
}
.btn-sm { padding: 4px 8px;  font-size: 12px; }
.btn-lg { padding: 9px 16px; font-size: 14px; }

.btn-primary   { background: var(--teal-600); color: #fff; border-color: var(--teal-700); }
.btn-primary:hover:not(:disabled) { background: var(--teal-700); }
.btn-secondary { background: #fff; color: var(--ink-800); border-color: var(--ink-200); }
.btn-secondary:hover:not(:disabled){ background: var(--ink-50); }
.btn-ghost     { background: transparent; color: var(--ink-700); }
.btn-ghost:hover:not(:disabled) { background: var(--ink-100); }
.btn-danger    { background: var(--red-solid); color: #fff; border-color: var(--red-solid); }

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  filter: brightness(1.02);
}
.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
  transition-duration: 80ms;
}
.btn:focus-visible { outline: 2px solid var(--teal-500); outline-offset: 2px; }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }

/* Hover universal — pega TODO <button> sem a classe .no-hover-lift */
button:not(.no-hover-lift):not([data-no-lift]) {
  transition: transform var(--duration-base) var(--ease-bounce),
              box-shadow var(--duration-base) ease,
              background-color var(--duration-fast) ease;
  will-change: transform;
}
button:not(.no-hover-lift):not([data-no-lift]):not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  filter: brightness(1.02);
}
button:not(.no-hover-lift):not([data-no-lift]):not(:disabled):active {
  transform: translateY(0) scale(0.98);
  transition-duration: 80ms;
}

/* ===== Card ===== */
.card {
  background: #fff;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--ink-200);
}
.card-title    { font-size: var(--text-h2); font-weight: 600; color: var(--ink-900); margin: 0; }
.card-subtitle { font-size: var(--text-small); color: var(--ink-500); margin: 2px 0 0; }
.card-body     { padding: 20px; }
.card-body-flush { padding: 0; }

/* ===== Badge ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  font-size: 11.5px; font-weight: 500; line-height: 1.3;
  border-radius: 4px; border: 1px solid transparent;
  white-space: nowrap;
}
.badge-dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.badge-teal   { background: var(--teal-50);  color: var(--teal-700);  border-color: var(--teal-200); }
.badge-red    { background: var(--red-bg);   color: var(--red-fg);    border-color: var(--red-border); }
.badge-amber  { background: var(--amber-bg); color: var(--amber-fg);  border-color: var(--amber-border); }
.badge-green  { background: var(--green-bg); color: var(--green-fg);  border-color: var(--green-border); }
.badge-blue   { background: var(--blue-bg);  color: var(--blue-fg);   border-color: var(--blue-border); }
.badge-neutral{ background: var(--ink-100);  color: var(--ink-700);   border-color: var(--ink-200); }

/* ===== StatCard ===== */
.statcard {
  background: #fff; border: 1px solid var(--ink-200); border-radius: var(--radius-lg);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 6px;
}
.statcard-label {
  font-size: 11px; color: var(--ink-500); font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
}
.statcard-value {
  font-size: 28px; font-weight: 700; color: var(--ink-900);
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.statcard-unit { font-size: 14px; font-weight: 500; color: var(--ink-500); margin-left: 4px; }
.statcard-delta {
  font-size: 12px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px;
}
.statcard-delta-green { color: var(--green-fg); }
.statcard-delta-red   { color: var(--red-fg); }
.statcard-delta-amber { color: var(--amber-fg); }
.statcard-hint { font-size: 11.5px; color: var(--ink-500); }

/* ===== ProgressBar ===== */
.progress {
  width: 100%; height: 6px; background: var(--ink-100);
  border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--teal-600); border-radius: 3px;
  transition: width 280ms var(--ease-out);
}
.progress-fill-red    { background: var(--red-solid); }
.progress-fill-amber  { background: var(--amber-solid); }
.progress-fill-green  { background: var(--green-solid); }

/* ===== Table ===== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead tr { background: var(--ink-50); border-top: 1px solid var(--ink-200); border-bottom: 1px solid var(--ink-200); }
.table th {
  text-align: left; padding: 10px 16px;
  font-size: 11px; font-weight: 600; color: var(--ink-600);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--ink-200); color: var(--ink-800); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width); flex-shrink: 0;
  background: #fff; border-right: 1px solid var(--ink-200);
  display: flex; flex-direction: column; height: 100vh;
  position: sticky; top: 0;
}
.sidebar-nav { flex: 1; overflow: auto; padding: 4px 8px 16px; }
.sidebar-section-label { padding: 4px 8px; margin-top: 14px; }
.sidebar-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: var(--radius-md);
  color: var(--ink-700); font-weight: 500; font-size: 13px;
  cursor: pointer;
  transition: background var(--duration-base) ease,
              color var(--duration-base) ease,
              transform var(--duration-slow) var(--ease-bounce),
              box-shadow var(--duration-base) ease;
}
.sidebar-item:hover {
  background: var(--teal-50); color: var(--teal-700);
  transform: translateX(3px);
  box-shadow: inset 2px 0 0 var(--teal-400), 0 2px 6px rgba(31,86,79,0.08);
}
.sidebar-item.active {
  background: var(--teal-50); color: var(--teal-700); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--teal-600);
}

/* ===== Topbar ===== */
.topbar {
  background: #fff; border-bottom: 1px solid var(--ink-200);
  padding: 14px 28px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: var(--text-h1); font-weight: 600; color: var(--ink-900); margin: 0; letter-spacing: -0.01em; }
.topbar-subtitle { font-size: 13px; color: var(--ink-500); margin-top: 2px; }
.topbar-breadcrumb { font-size: 12px; color: var(--ink-500); display: flex; gap: 6px; align-items: center; margin-bottom: 2px; }

/* ===== Input ===== */
.input {
  width: 100%; padding: 8px 10px;
  font-family: inherit; font-size: 13px; color: var(--ink-800);
  background: #fff; border: 1px solid var(--ink-200); border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}
.input:focus {
  outline: none; border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(45,110,101,0.12);
}

/* ===== Scrollbars sutis ===== */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 5px; border: 2px solid var(--ink-50); }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }
