/* =====================================================================
   ÍRIS — receita.css
   Ficha de receita óptica: cabeçalho, tabela de grau, blocos ilustrados,
   desenhos técnicos (SVG inline) e legenda de siglas.
   Só apresentação — nenhuma regra de negócio depende deste arquivo.
   ===================================================================== */

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

/* ============================= CABEÇALHO ============================= */

.rx-cabecalho {
  display: grid;
  grid-template-columns: minmax(200px, 250px) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--c-accent-line);
  border-radius: var(--r-md);
  background:
    linear-gradient(120deg, var(--c-accent-soft), transparent 70%),
    var(--c-surface);
}

.rx-identidade { display: grid; gap: 9px; min-width: 0; }

.rx-selo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: start;
  padding: 3px 9px;
  border-radius: var(--r-full);
  background: var(--c-accent);
  color: #fff;
  font-family: var(--font-cond);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.rx-selo .icon { width: 13px; height: 13px; }

.rx-paciente { display: flex; align-items: center; gap: 9px; min-width: 0; }
.rx-paciente strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rx-paciente .t-dim { display: block; }

.rx-cabecalho__campos { min-width: 0; }

/* ============================== BLOCOS ============================== */

.rx-bloco {
  padding: 14px 15px 15px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  background: var(--c-surface);
}

.rx-bloco__titulo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-family: var(--font-cond);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--c-text-2);
}
.rx-bloco__titulo .icon { color: var(--c-accent); }
.rx-bloco__titulo::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--c-line), transparent);
}

.rx-separador {
  height: 1px;
  margin: 13px 0;
  background: linear-gradient(90deg, var(--c-line), transparent);
}

/* ======================= TABELA DE GRAU (OD/OE) ====================== */

.grau-editor {
  width: 100%;
  min-width: 620px;
  border-collapse: separate;
  border-spacing: 0 7px;
}

.grau-editor thead th {
  padding: 0 8px 4px;
  font-family: var(--font-cond);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--c-text-3);
  text-align: center;
  white-space: nowrap;
}
.grau-editor thead th.grau-editor__olho { text-align: left; padding-left: 14px; }
.grau-editor__un {
  margin-left: 4px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--brand-blue);
  text-transform: none;
}

.grau-editor tbody th,
.grau-editor tbody td {
  background: var(--c-surface-2);
  border-top: 1px solid var(--c-line);
  border-bottom: 1px solid var(--c-line);
}

.grau-editor tbody th.grau-editor__olho {
  width: 132px;
  padding: 8px 12px;
  text-align: left;
  border-left: 1px solid var(--c-line);
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  position: relative;
}
.grau-editor tbody th.grau-editor__olho::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--c-accent);
}
.grau-editor tbody th b {
  display: block;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--c-accent);
}
.grau-editor tbody th span { font-size: 10.5px; color: var(--c-text-3); }

.grau-editor tbody td { padding: 7px 6px; }
.grau-editor tbody td:last-child {
  border-right: 1px solid var(--c-line);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding-right: 8px;
}

.grau-editor input {
  width: 100%;
  height: 38px;
  padding: 0 8px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  font-family: var(--font-mono);
  font-size: 14px;
  text-align: center;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.grau-editor input::placeholder { color: var(--c-text-3); font-size: 12px; }
.grau-editor input:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: var(--ring);
}
.grau-editor input.is-invalido,
.field input.is-invalido {
  border-color: var(--c-danger);
  background: var(--c-danger-soft);
}

/* ======================= BLOCO COM ILUSTRAÇÃO ======================= */

.rx-ilustrado {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 18px;
  align-items: start;
}

.rx-figura {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  background:
    radial-gradient(circle at 30% 0%, color-mix(in srgb, var(--c-accent) 7%, transparent), transparent 62%),
    var(--c-surface-2);
}

.rx-campos { min-width: 0; }
.rx-grade-cotas .field > label { font-variant-numeric: tabular-nums; }

/* ==================== DESENHOS TÉCNICOS (SVG) ==================== */

.ilu { display: block; width: 100%; height: auto; overflow: visible; }

.ilu-peca {
  fill: none;
  stroke: var(--c-text-2);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ilu-lente {
  fill: color-mix(in srgb, var(--c-accent) 9%, transparent);
  stroke: var(--c-text-2);
  stroke-width: 2.2;
}
.ilu-lente-perfil { stroke-width: 3; stroke: var(--c-accent-3); }

.ilu-cota {
  fill: none;
  stroke: var(--c-accent);
  stroke-width: 1.5;
}
.ilu-seta { fill: var(--c-accent); stroke: none; }

.ilu-guia {
  fill: none;
  stroke: var(--c-line-strong);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}
.ilu-eixo {
  fill: none;
  stroke: var(--c-line-strong);
  stroke-width: 1.2;
  stroke-dasharray: 6 5;
}
.ilu-olho { fill: var(--c-text); stroke: none; }

.ilu-tag {
  font-family: var(--font-cond);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .09em;
  fill: var(--c-accent);
  paint-order: stroke;
  stroke: var(--c-surface-2);
  stroke-width: 5;
  stroke-linejoin: round;
}
.ilu-tag--olho { fill: var(--c-text-2); font-size: 13px; }
.ilu-nota {
  font-family: var(--font-sans);
  font-size: 10px;
  fill: var(--c-text-3);
  letter-spacing: .02em;
}

/* ============================== LEGENDA ============================== */

.rx-legenda {
  padding: 12px 15px;
  border: 1px dashed var(--c-line-strong);
  border-radius: var(--r-md);
  background: var(--c-surface-2);
}
.rx-legenda > .t-label { display: block; margin-bottom: 8px; }

.legenda-siglas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 7px 14px;
}
.legenda-siglas li { display: flex; align-items: baseline; gap: 8px; font-size: 12px; }
.legenda-siglas b {
  flex: none;
  min-width: 34px;
  padding: 1px 6px;
  border-radius: var(--r-xs);
  background: var(--c-accent-soft);
  border: 1px solid var(--c-accent-line);
  color: var(--c-accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}
.legenda-siglas span { color: var(--c-text-2); }

/* =========================== RESPONSIVIDADE =========================== */

@media (max-width: 980px) {
  .rx-ilustrado { grid-template-columns: 1fr; }
  .rx-figura { max-width: 520px; }
}

@media (max-width: 760px) {
  .rx-cabecalho { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  /* a tabela de grau vira um cartão por olho */
  .grau-editor { min-width: 0; border-spacing: 0; }
  .grau-editor thead { display: none; }
  .grau-editor tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    padding: 11px 12px;
    margin-bottom: 10px;
    border: 1px solid var(--c-line);
    border-radius: var(--r-md);
    background: var(--c-surface-2);
  }
  .grau-editor tbody th,
  .grau-editor tbody td {
    display: block;
    padding: 0;
    border: 0 !important;
    border-radius: 0;
    background: transparent;
  }
  .grau-editor tbody th.grau-editor__olho {
    grid-column: 1 / -1;
    width: auto;
    padding-left: 10px;
  }
  .grau-editor tbody td::before {
    content: attr(data-rotulo);
    display: block;
    margin-bottom: 3px;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--c-text-2);
  }
  .grau-editor tbody td:nth-child(6) { grid-column: 1 / -1; }
  .rx-bloco { padding: 12px; }
}
