/* ═══════════════════════════════════════════════════
   AVALIAÇÃO FÍSICA PRO — style.css
   Hugo Daflon Personal
   ═══════════════════════════════════════════════════ */

/* ── Tokens ── */
:root {
  --bg:          #0f172a;
  --bg-card:     #1e293b;
  --bg-card-alt: #162032;
  --blue:        #3b82f6;
  --blue-dim:    #1d4ed8;
  --green:       #10b981;
  --green-dim:   #059669;
  --orange:      #f59e0b;
  --red:         #ef4444;
  --purple:      #8b5cf6;
  --yellow:      #eab308;
  --teal:        #14b8a6;
  --text:        #f8fafc;
  --text-muted:  #94a3b8;
  --border:      #334155;
  --sidebar-w:   260px;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px rgba(0,0,0,.4);
  --transition:  .2s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}
input, select, button, textarea { font-family: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ════════════════ SIDEBAR ════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: #0b1524;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand svg { flex-shrink: 0; }
.brand-name {
  display: block;
  font-weight: 700;
  font-size: .9rem;
  color: var(--text);
  line-height: 1.2;
}
.brand-sub {
  display: block;
  font-size: .72rem;
  color: var(--blue);
  font-weight: 500;
  margin-top: 2px;
}

.nav-list {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: .84rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-link:hover { background: var(--bg-card); color: var(--text); }
.nav-link.active { background: rgba(59,130,246,.15); color: var(--blue); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: .72rem;
  color: var(--text-muted);
}

/* ════════════════ MOBILE HEADER ════════════════ */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: #0b1524;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 300;
}
.mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: .84rem;
  flex: 1;
}
.hamburger {
  width: 36px; height: 36px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 4px;
}
.hamburger span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .3s, opacity .3s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 150;
}
.overlay.visible { display: block; }

/* ════════════════ MAIN CONTENT ════════════════ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px 64px;
  max-width: 1200px;
  width: 100%;
}

/* ════════════════ ACTION BAR ════════════════ */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.action-bar-left { display: flex; align-items: center; gap: 12px; }
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}
.badge {
  background: rgba(59,130,246,.15);
  color: var(--blue);
  font-size: .75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid rgba(59,130,246,.3);
}
.action-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ════════════════ BUTTONS ════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-sm { padding: 6px 12px; font-size: .78rem; }
.btn-primary {
  background: var(--blue);
  color: #fff;
}
.btn-primary:hover { background: var(--blue-dim); }
.btn-secondary {
  background: rgba(16,185,129,.15);
  color: var(--green);
  border: 1px solid rgba(16,185,129,.3);
}
.btn-secondary:hover { background: rgba(16,185,129,.25); }
.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover { color: var(--text); border-color: var(--text-muted); }
.btn-danger {
  background: rgba(239,68,68,.15);
  color: var(--red);
  border: 1px solid rgba(239,68,68,.3);
}
.btn-danger:hover { background: rgba(239,68,68,.25); }

/* ════════════════ CARDS / SECTIONS ════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  animation: fadeUp .4s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.section-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.section-icon {
  width: 22px; height: 22px;
  color: var(--blue);
  flex-shrink: 0;
}
.section-desc {
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  margin-top: -12px;
}

/* ════════════════ FORM GRID ════════════════ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.field input,
.field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: .9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.field input::placeholder { color: var(--text-muted); }
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ════════════════ RESULTS GRID ════════════════ */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.result-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color var(--transition), transform var(--transition);
}
.result-card:hover { border-color: var(--blue); transform: translateY(-2px); }
.result-card.highlight { border-color: rgba(59,130,246,.4); background: rgba(59,130,246,.06); }
.result-card.highlight-green { border-color: rgba(16,185,129,.4); background: rgba(16,185,129,.06); }
.result-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.result-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.result-value--sm {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}
.result-unit {
  font-size: .75rem;
  color: var(--text-muted);
}
.result-tag {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  background: rgba(59,130,246,.15);
  color: var(--blue);
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 700;
  align-self: flex-start;
}
.result-tag.green { background: rgba(16,185,129,.15); color: var(--green); }
.result-tag.orange { background: rgba(245,158,11,.15); color: var(--orange); }
.result-tag.red { background: rgba(239,68,68,.15); color: var(--red); }

/* ════════════════ IMC BAR ════════════════ */
.imc-bar-wrap {
  margin-top: 20px;
}
.bar-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: block;
}
.imc-bar {
  position: relative;
  height: 10px;
  border-radius: 99px;
  background: linear-gradient(to right, #3b82f6 0%, #10b981 25%, #f59e0b 55%, #ef4444 80%, #7f1d1d 100%);
  margin-bottom: 6px;
  overflow: visible;
}
.imc-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 18px; height: 18px;
  background: #fff;
  border: 3px solid var(--blue);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
  transition: left .5s cubic-bezier(.34,1.56,.64,1);
  z-index: 1;
}
.imc-labels {
  display: flex;
  justify-content: space-between;
  font-size: .68rem;
  color: var(--text-muted);
}

/* ════════════════ PROTOCOL SELECT ════════════════ */
.protocol-select {
  margin-bottom: 20px;
}
.proto-label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.proto-options {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.proto-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: .86rem;
  transition: all var(--transition);
}
.proto-opt:hover { border-color: var(--blue); }
.proto-opt input[type="radio"] { accent-color: var(--blue); }
.proto-opt:has(input:checked) {
  border-color: var(--blue);
  background: rgba(59,130,246,.08);
  color: var(--blue);
}

/* ════════════════ INFO TABLES ════════════════ */
.info-table-wrap,
.meta-table-wrap {
  margin-top: 20px;
  overflow-x: auto;
}
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
}
.info-table th {
  background: rgba(59,130,246,.1);
  color: var(--blue);
  font-weight: 700;
  text-align: left;
  padding: 10px 14px;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.info-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.info-table tr:last-child td { border-bottom: none; }
.info-table tr:hover td { background: rgba(255,255,255,.02); color: var(--text); }

/* ════════════════ DASHBOARD ════════════════ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.dash-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  transition: transform var(--transition), border-color var(--transition);
}
.dash-card:hover { transform: translateY(-2px); border-color: #475569; }
.dash-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.dash-icon svg { width: 20px; height: 20px; }
.dash-icon--blue   { background: rgba(59,130,246,.15); color: var(--blue); }
.dash-icon--green  { background: rgba(16,185,129,.15); color: var(--green); }
.dash-icon--orange { background: rgba(245,158,11,.15); color: var(--orange); }
.dash-icon--red    { background: rgba(239,68,68,.15);  color: var(--red); }
.dash-icon--purple { background: rgba(139,92,246,.15); color: var(--purple); }
.dash-icon--yellow { background: rgba(234,179,8,.15);  color: var(--yellow); }
.dash-icon--teal   { background: rgba(20,184,166,.15); color: var(--teal); }
.dash-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.dash-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.dash-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.dash-tag {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ════════════════ CHARTS ════════════════ */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
.chart-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
}
.chart-wrap--full {
  grid-column: 1 / -1;
}
.chart-title {
  font-size: .84rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 16px;
}

/* ════════════════ HISTÓRICO ════════════════ */
.historico-lista {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.historico-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  transition: border-color var(--transition);
}
.historico-item:hover { border-color: var(--blue); }
.historico-thumb {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(59,130,246,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue);
  font-weight: 800;
  font-size: .9rem;
  flex-shrink: 0;
}
.historico-info { flex: 1; min-width: 0; }
.historico-nome {
  font-weight: 700;
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.historico-meta {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.historico-actions { display: flex; gap: 8px; }

/* ════════════════ EMPTY STATE ════════════════ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 16px; opacity: .4; }
.empty-state p { font-size: .9rem; margin-bottom: 4px; }
.text-muted { color: var(--text-muted); font-size: .82rem; }

/* ════════════════ MODAL ════════════════ */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
  animation: modalIn .25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ════════════════ TOAST ════════════════ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: .86rem;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  z-index: 999;
  transform: translateY(80px);
  opacity: 0;
  transition: transform .3s ease, opacity .3s ease;
  max-width: 320px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red); }

/* ════════════════ RESPONSIVE ════════════════ */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 400;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,.5);
  }
  .mobile-header { display: flex; }
  .main-content {
    margin-left: 0;
    padding: 80px 16px 64px;
  }
  .action-bar { display: none; }
  .charts-grid { grid-template-columns: 1fr; }
  .chart-wrap--full { grid-column: 1; }
}

@media (max-width: 600px) {
  .card { padding: 18px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .results-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .result-value { font-size: 1.4rem; }
  .page-title { font-size: 1.2rem; }
}

@media (max-width: 380px) {
  .form-grid { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ════════════════ SCROLLBAR ════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ════════════════ PRINT / PDF TEMPLATE ════════════════ */
#pdf-template {
  background: #ffffff;
  color: #1e293b;
  font-family: 'Segoe UI', system-ui, sans-serif;
  padding: 40px;
  width: 794px;
}
.pdf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid #3b82f6;
  padding-bottom: 20px;
  margin-bottom: 24px;
}
.pdf-logo-name { font-size: 1.4rem; font-weight: 800; color: #1e293b; }
.pdf-logo-sub  { font-size: .85rem; color: #3b82f6; font-weight: 600; margin-top: 2px; }
.pdf-logo-cref { font-size: .75rem; color: #64748b; margin-top: 4px; }
.pdf-section-title {
  font-size: .8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #3b82f6;
  border-left: 3px solid #3b82f6;
  padding-left: 10px;
  margin: 24px 0 14px;
}
.pdf-data-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}
.pdf-data-cell label {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: .06em;
  margin-bottom: 3px;
}
.pdf-data-cell span { font-size: .9rem; font-weight: 700; color: #1e293b; }
.pdf-results-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.pdf-res-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
}
.pdf-res-label { font-size: .65rem; font-weight: 700; text-transform: uppercase; color: #94a3b8; letter-spacing: .06em; }
.pdf-res-value { font-size: 1.2rem; font-weight: 800; color: #1e293b; line-height: 1.1; margin-top: 2px; }
.pdf-res-unit  { font-size: .7rem; color: #64748b; }
.pdf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
  margin-bottom: 8px;
}
.pdf-table th {
  background: #eff6ff;
  color: #3b82f6;
  font-weight: 700;
  text-align: left;
  padding: 8px 10px;
  font-size: .7rem;
  text-transform: uppercase;
}
.pdf-table td { padding: 7px 10px; border-bottom: 1px solid #e2e8f0; color: #475569; }
.pdf-table tr:last-child td { border-bottom: none; }
.pdf-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  font-size: .72rem;
  color: #94a3b8;
  text-align: center;
}
