/* ============================================================
   Hojas imprimibles — Ortho Láser Dental
   Usado por: receta, cita, tratamiento
   ============================================================ */
@page {
  size: letter;
  margin: 12mm 14mm 14mm 14mm;
}

:root {
  --print-brand: #1B3A9C;
  --print-brand-soft: #E8EDF8;
  --print-ink: #1a1a1a;
  --print-muted: #555;
  --print-line: #c8c8c8;
}

* { box-sizing: border-box; }

body.ds-print-body {
  margin: 0;
  padding: 0;
  background: #e8e8e8;
  color: var(--print-ink);
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 12px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.ds-print-sheet {
  width: 100%;
  max-width: 780px;
  min-height: 1000px;
  margin: 20px auto;
  padding: 28px 32px 36px;
  background: #fff;
  border: 1px solid #d0d0d0;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ─── Encabezado ─── */
.ds-print-head {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 16px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 3px solid var(--print-brand);
}

.ds-print-logo {
  width: 104px;
  height: 80px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  border: 1px solid rgba(27, 58, 156, 0.08);
  padding: 10px;
  box-sizing: border-box;
}

.ds-print-brand {
  min-width: 0;
}
.ds-print-brand__name {
  font-size: 20px;
  font-weight: 800;
  color: var(--print-brand);
  letter-spacing: -0.02em;
  margin: 0 0 2px;
  line-height: 1.15;
}
.ds-print-brand__doc {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--print-ink);
  margin: 0 0 2px;
}
.ds-print-brand__spec {
  font-size: 11px;
  color: var(--print-muted);
  margin: 0 0 6px;
  font-weight: 500;
}
.ds-print-brand__addr {
  font-size: 10.5px;
  color: var(--print-muted);
  line-height: 1.4;
}
.ds-print-brand__addr b { color: var(--print-ink); font-weight: 600; }

.ds-print-docmeta {
  text-align: right;
  padding-left: 14px;
  border-left: 2px solid var(--print-brand);
  min-width: 120px;
}
.ds-print-docmeta__type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--print-muted);
  font-weight: 700;
  margin-bottom: 2px;
}
.ds-print-docmeta__num {
  font-size: 22px;
  font-weight: 800;
  color: var(--print-brand);
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.ds-print-docmeta__fecha {
  font-size: 11.5px;
  color: var(--print-ink);
  font-weight: 600;
  margin-top: 4px;
}

/* ─── Datos del paciente ─── */
.ds-print-paciente {
  margin: 16px 0 8px;
  padding: 12px 14px;
  background: var(--print-brand-soft);
  border-radius: 8px;
  border: 1px solid rgba(27, 58, 156, 0.12);
}
.ds-print-paciente__grid {
  display: grid;
  grid-template-columns: 2fr 0.7fr 0.6fr 1.1fr;
  gap: 10px 16px;
}
.ds-print-field__lbl {
  display: block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--print-brand);
  font-weight: 700;
  margin-bottom: 2px;
}
.ds-print-field__val {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--print-ink);
  border-bottom: 1px solid rgba(27, 58, 156, 0.25);
  padding-bottom: 2px;
  min-height: 18px;
}

/* ─── Cuerpo ─── */
.ds-print-body {
  flex: 1 1 auto;
  margin-top: 8px;
  min-height: 0;
}
.ds-print-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 10px;
}
.ds-print-section-title h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--print-brand);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ds-print-section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--print-line);
}

.ds-print-rp {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--print-brand);
  margin: 0 0 8px;
}

.ds-print-cuerpo {
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  min-height: 220px;
  color: #222;
  padding: 4px 2px;
}

.ds-print-kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 12px;
  font-size: 12.5px;
  margin: 8px 0;
}
.ds-print-kv dt {
  color: var(--print-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 2px;
}
.ds-print-kv dd {
  margin: 0;
  font-weight: 600;
  color: var(--print-ink);
  border-bottom: 1px solid #e5e5e5;
  padding-bottom: 3px;
}

.ds-print-box {
  border: 1px solid var(--print-line);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 10px 0;
  background: #fafafa;
}
.ds-print-box p { margin: 0 0 6px; }
.ds-print-box p:last-child { margin: 0; }

.ds-print-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 8px 0 12px;
}
.ds-print-table th {
  text-align: left;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--print-muted);
  border-bottom: 2px solid var(--print-brand);
  padding: 6px 8px;
}
.ds-print-table td {
  padding: 8px;
  border-bottom: 1px solid #eee;
  vertical-align: top;
}
.ds-print-table .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 600;
}

/* ─── Firmas (simétricas: pad + línea + texto) ─── */
.ds-print-firmas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  margin-top: auto;          /* empuja al pie sin hueco raro en medio */
  padding-top: 36px;
  align-items: start;        /* ambas columnas empiezan igual */
  flex-shrink: 0;
}
.ds-print-firma {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
/* Zona en blanco para firmar a mano (misma altura en ambos lados) */
.ds-print-firma__pad {
  width: 100%;
  height: 52px;
  flex-shrink: 0;
}
.ds-print-firma__rule {
  width: 100%;
  max-width: 280px;
  border: 0;
  border-top: 1.5px solid #222;
  margin: 0 0 8px;
  padding: 0;
  height: 0;
}
.ds-print-firma__name {
  font-size: 12px;
  font-weight: 700;
  color: var(--print-ink);
  line-height: 1.3;
  max-width: 280px;
}
.ds-print-firma__meta {
  font-size: 10px;
  color: var(--print-muted);
  line-height: 1.4;
  margin-top: 3px;
  max-width: 280px;
}

/* ─── Pie ─── */
.ds-print-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid #eee;
  font-size: 9.5px;
  color: #888;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ds-print-anulada {
  background: #FFEBEE;
  border: 2px solid #C62828;
  color: #B71C1C;
  padding: 10px 14px;
  margin: 12px 0;
  text-align: center;
  font-weight: 800;
  letter-spacing: 0.04em;
  border-radius: 6px;
}

/* ─── Acciones pantalla ─── */
.ds-print-actions {
  max-width: 780px;
  margin: 0 auto 40px;
  padding: 0 8px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.ds-print-actions .ds-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: #222;
}
.ds-print-actions .ds-btn--primary {
  background: #1D1D1F;
  border-color: #1D1D1F;
  color: #fff;
}
.ds-print-actions .ds-btn--danger {
  background: #fff;
  border-color: #C62828;
  color: #C62828;
}

/* ─── Formato papel (cita / receta / estado de cuenta) ─── */
:root {
  --ec-accent: #0E5B5B;
  --ec-line: #d7ddd9;
  --ec-soft: #6b756f;
  --ec-bg: #fafcfc;
}

.ds-ec-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 2px solid var(--print-brand, #1B3A9C);
}
.ds-ec-brand__logo {
  width: 88px !important;
  height: 68px !important;
  max-width: 88px !important;
  max-height: 68px !important;
  object-fit: contain !important;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.06);
  padding: 6px;
  flex-shrink: 0;
  display: block;
}
.ds-ec-brand__name {
  font-size: 18px;
  font-weight: 800;
  color: var(--print-brand, #1B3A9C);
  line-height: 1.15;
  margin: 0 0 2px;
}
.ds-ec-brand__doc {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--print-ink);
  margin: 0 0 2px;
}
.ds-ec-brand__meta {
  font-size: 10.5px;
  color: var(--print-muted);
  line-height: 1.4;
  margin: 0;
}

.ds-ec-title {
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--ec-accent);
  margin: 18px 0 14px;
}

.ds-ec-rows {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}
.ds-ec-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--ec-line);
  border-radius: 6px;
  padding: 9px 14px;
}
.ds-ec-row__lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ec-soft);
}
.ds-ec-row__val {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  text-align: right;
}

.ds-ec-block {
  border: 1px solid var(--ec-line);
  border-radius: 6px;
  margin: 0 0 12px;
  overflow: hidden;
  background: #fff;
}
.ds-ec-block__title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ec-soft);
  text-align: center;
  padding: 8px 10px;
  background: var(--ec-bg);
  border-bottom: 1px solid var(--ec-line);
}
.ds-ec-block__body {
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.6;
  color: #222;
  white-space: pre-wrap;
  min-height: 120px;
}
.ds-ec-rp {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--print-brand, #1B3A9C);
  margin: 0 0 8px;
}

@media print {
  body.ds-print-body { background: #fff; }
  .ds-print-sheet {
    margin: 0;
    max-width: none;
    min-height: 0;
    border: none;
    box-shadow: none;
    padding: 0;
  }
  .ds-print-actions, .no-print { display: none !important; }
}
