/* ══════════════════════════════════════════════════════════
   DESIGN SYSTEM — Espaço Ferraz
   Calculadora de Cirurgias · Dr. Danilo Ferraz
══════════════════════════════════════════════════════════ */

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

:root {
  /* Cores */
  --gold: #c9a96e;
  --gold-light: #e2c898;
  --gold-dark: #a8884d;
  --gold-glow: rgba(201,169,110,0.35);
  --dark: #0a0a0a;
  --darker: #060606;
  --card-bg: rgba(201,169,110,0.04);
  --card-border: rgba(201,169,110,0.12);
  --card-border-strong: rgba(201,169,110,0.28);
  --white: #f5f4f0;
  --text: #b8b5ae;
  --muted: #78756e;
  --input-bg: rgba(201,169,110,0.06);
  --input-border: rgba(201,169,110,0.18);
  --input-focus: rgba(201,169,110,0.45);

  /* Estados */
  --green: #4ade80;
  --green-bg: rgba(74,222,128,0.10);
  --green-border: rgba(74,222,128,0.30);
  --amber: #fbbf24;
  --amber-bg: rgba(251,191,36,0.10);
  --amber-border: rgba(251,191,36,0.30);
  --red: #f87171;
  --red-bg: rgba(248,113,113,0.10);
  --red-border: rgba(248,113,113,0.30);

  /* Tipografia */
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', -apple-system, sans-serif;
  --poppins: 'Poppins', -apple-system, sans-serif;

  /* Espaçamento */
  --radius: 10px;
  --radius-lg: 14px;
  --radius-sm: 6px;
  --shadow-gold: 0 4px 24px rgba(201,169,110,0.18);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.4);
}

html { scroll-behavior: smooth; }

body {
  background: var(--dark);
  color: var(--white);
  font-family: var(--sans);
  font-weight: 400;
  font-size: 15px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

img { max-width: 100%; height: auto; display: block; }

/* Texturas e brilhos de fundo */
.texture-noise::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  top: -300px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 900px;
  background: radial-gradient(circle, rgba(201,169,110,0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ══════════════════════════════════════════════════════════
   HEADER & NAVEGAÇÃO
══════════════════════════════════════════════════════════ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--card-border);
}

.app-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  display: grid;
  place-items: center;
  color: var(--darker);
  font-family: var(--serif);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.5px;
}

.brand-text strong {
  font-family: var(--poppins);
  font-size: 18px;
  font-weight: 500;
  color: var(--white);
  letter-spacing: 0.3px;
  display: block;
  line-height: 1.1;
}

.brand-text small {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 180ms ease;
}

.tab:hover {
  color: var(--white);
  background: var(--input-bg);
}

.tab.active {
  color: var(--gold-light);
  background: var(--card-bg);
  border-color: var(--card-border-strong);
}

/* ══════════════════════════════════════════════════════════
   LAYOUT PRINCIPAL
══════════════════════════════════════════════════════════ */
.app-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  position: relative;
  z-index: 1;
}

.app-footer {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-top: 1px solid var(--card-border);
}

/* Heading de view */
.view-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.view-title {
  font-family: var(--poppins);
  font-weight: 400;
  font-size: 32px;
  color: var(--white);
  letter-spacing: 0.5px;
  line-height: 1.1;
}

.view-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
  letter-spacing: 0.3px;
}

/* ══════════════════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════════════════ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.card + .card { margin-top: 16px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  font-family: var(--poppins);
  font-size: 22px;
  font-weight: 500;
  color: var(--gold-light);
  letter-spacing: 0.3px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-top: 2px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* ══════════════════════════════════════════════════════════
   FORMULÁRIOS
══════════════════════════════════════════════════════════ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.field-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.input, .select, .textarea {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--white);
  font-family: var(--sans);
  font-size: 14px;
  padding: 10px 12px;
  width: 100%;
  transition: border-color 150ms ease, background 150ms ease;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--input-focus);
  background: rgba(201,169,110,0.10);
}

.input::placeholder, .textarea::placeholder { color: var(--muted); }

.textarea { resize: vertical; min-height: 80px; font-family: var(--sans); }

.input-affix {
  position: relative;
}
.input-affix .affix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}
.input-affix .input { padding-right: 36px; }

/* ══════════════════════════════════════════════════════════
   BOTÕES
══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 180ms ease;
  text-transform: uppercase;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  color: var(--darker);
  border-color: var(--gold-dark);
}
.btn-primary:hover {
  box-shadow: var(--shadow-gold);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--card-border-strong);
}
.btn-ghost:hover {
  color: var(--white);
  border-color: var(--gold);
  background: var(--card-bg);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: var(--red-border);
}
.btn-danger:hover {
  background: var(--red-bg);
}

.btn-sm { padding: 6px 12px; font-size: 11px; }

.btn-block { width: 100%; }

/* ══════════════════════════════════════════════════════════
   TABELAS
══════════════════════════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 640px;
}

.table th {
  background: rgba(201,169,110,0.06);
  color: var(--gold-light);
  font-weight: 600;
  text-align: left;
  padding: 12px 14px;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--card-border-strong);
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(201,169,110,0.03); }

.table .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--white); }
.table .strong { color: var(--white); font-weight: 500; }

.table-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ══════════════════════════════════════════════════════════
   BADGES & STATUS
══════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.badge-green { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.badge-amber { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-border); }
.badge-red   { background: var(--red-bg);   color: var(--red);   border-color: var(--red-border); }
.badge-muted { background: var(--card-bg);  color: var(--muted); border-color: var(--card-border); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }
.dot-red   { background: var(--red); }

/* ══════════════════════════════════════════════════════════
   SEMÁFORO DE STATUS (resultado da simulação)
══════════════════════════════════════════════════════════ */
.status-card {
  border-radius: var(--radius-lg);
  padding: 28px;
  border-width: 1px;
  border-style: solid;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.status-green { background: var(--green-bg); border-color: var(--green-border); }
.status-amber { background: var(--amber-bg); border-color: var(--amber-border); }
.status-red   { background: var(--red-bg);   border-color: var(--red-border); }

.status-light {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(0,0,0,0.3) inset;
}

.status-green .status-light { background: var(--green); box-shadow: 0 0 20px var(--green), 0 0 0 4px rgba(0,0,0,0.2) inset; }
.status-amber .status-light { background: var(--amber); box-shadow: 0 0 20px var(--amber), 0 0 0 4px rgba(0,0,0,0.2) inset; }
.status-red   .status-light { background: var(--red);   box-shadow: 0 0 20px var(--red),   0 0 0 4px rgba(0,0,0,0.2) inset; }

.status-content { flex: 1; min-width: 220px; }
.status-label {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 600;
  opacity: 0.85;
}
.status-headline {
  font-family: var(--poppins);
  font-size: 26px;
  font-weight: 500;
  margin-top: 2px;
  line-height: 1.1;
}
.status-msg {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text);
  max-width: 640px;
}

.status-green .status-headline { color: var(--green); }
.status-amber .status-headline { color: var(--amber); }
.status-red   .status-headline { color: var(--red); }

/* ══════════════════════════════════════════════════════════
   KPI / MÉTRICA
══════════════════════════════════════════════════════════ */
.metric {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.metric-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.metric-value {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 26px;
  font-weight: 500;
  color: var(--white);
  margin-top: 4px;
  line-height: 1.1;
  letter-spacing: 0.3px;
}

.metric-value.gold { color: var(--gold-light); }
.metric-value.green { color: var(--green); }
.metric-value.amber { color: var(--amber); }
.metric-value.red { color: var(--red); }

.metric-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* ══════════════════════════════════════════════════════════
   LINHAS DE PROCEDIMENTOS SELECIONADOS (Simulador)
══════════════════════════════════════════════════════════ */
.proc-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
}
.proc-row + .proc-row { margin-top: 8px; }

.proc-role {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(201,169,110,0.15);
  color: var(--gold-light);
  white-space: nowrap;
}

.proc-row.is-principal .proc-role {
  background: var(--gold);
  color: var(--darker);
}

.proc-name {
  color: var(--white);
  font-weight: 500;
}
.proc-info {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.3px;
}

.warn-inline {
  color: var(--amber);
  font-size: 11px;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
}
.empty strong {
  display: block;
  font-family: var(--poppins);
  font-size: 20px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 6px;
}

/* ══════════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--darker);
  border: 1px solid var(--card-border-strong);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--white);
  font-size: 13px;
  box-shadow: var(--shadow-card);
  min-width: 240px;
  animation: toast-in 200ms ease;
}

.toast.success { border-color: var(--green-border); }
.toast.error { border-color: var(--red-border); }
.toast.info { border-color: var(--card-border-strong); }

@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ══════════════════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════════════════ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  background: var(--darker);
  border: 1px solid var(--card-border-strong);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 440px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-gold);
}

.modal-card h3 {
  font-family: var(--poppins);
  font-size: 22px;
  font-weight: 500;
  color: var(--gold-light);
  margin-bottom: 8px;
}
.modal-card p {
  color: var(--text);
  font-size: 14px;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ══════════════════════════════════════════════════════════
   PROC SELECTOR (toggle list)
══════════════════════════════════════════════════════════ */
.proc-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.proc-pick {
  text-align: left;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text);
  transition: all 150ms ease;
  font-family: var(--sans);
}
.proc-pick:hover {
  border-color: var(--input-focus);
  color: var(--white);
}
.proc-pick.selected {
  background: rgba(201,169,110,0.14);
  border-color: var(--gold);
  color: var(--white);
}
.proc-pick.principal {
  background: linear-gradient(135deg, rgba(201,169,110,0.20), rgba(201,169,110,0.10));
  border-color: var(--gold-light);
}
.proc-pick strong {
  display: block;
  font-weight: 500;
  font-size: 13.5px;
}
.proc-pick small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.proc-pick.selected small { color: var(--gold-light); }

/* ══════════════════════════════════════════════════════════
   UTILS
══════════════════════════════════════════════════════════ */
.muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.flex-row { display: flex; align-items: center; gap: 8px; }
.gap-12 { gap: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.sep { height: 1px; background: var(--card-border); margin: 16px 0; border: 0; }
.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVO
══════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  .app-header-inner { padding: 12px 16px; }
  .app-main { padding: 20px 16px 60px; }
  .view-title { font-size: 26px; }
  .card { padding: 18px; }
  .tabs { width: 100%; justify-content: flex-start; overflow-x: auto; padding-bottom: 4px; }
  .tab { white-space: nowrap; }
  .metric-value { font-size: 22px; }
  .status-card { padding: 20px; gap: 16px; }
  .status-light { width: 44px; height: 44px; }
  .status-headline { font-size: 22px; }
  .proc-row { grid-template-columns: 1fr; }
}
