/* =========================================================================
   Best Home · Ficha técnica para imprimir / guardar como PDF
   Todo el diseño vive dentro de @media print. Fuera de print solo se
   oculta .print-only para que no aparezca en la vista web.
   Hoja: Carta (8.5 × 11 in = 816 × 1056 px a 96 dpi).
   Modos (los pone ficha-print.js en <body>):
     .bh-print-brand   → con logo y contacto (por defecto)
     .bh-print-neutral → sin logo, sin contacto, sin QR, sin enlaces
   ========================================================================= */

/* Vista web: la ficha de impresión no existe */
.print-only { display: none; }

@media print {

  @page { size: Letter; margin: 0; }

  /* ---------- Aislar la ficha: ocultar todo lo demás de la página ---------- */
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    background: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body.bh-has-ficha > *:not(#bh-ficha) { display: none !important; }
  .print-only { display: block !important; }

  /* ---------- Base ---------- */
  #bh-ficha {
    width: 816px;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #6d6e71;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  #bh-ficha *, #bh-ficha *::before, #bh-ficha *::after { box-sizing: border-box; }
  #bh-ficha h2, #bh-ficha h3, #bh-ficha p, #bh-ficha ul { margin: 0; padding: 0; }
  #bh-ficha img { display: block; max-width: none; }
  #bh-ficha a { color: inherit; text-decoration: none; }
  #bh-ficha a[href]::after { content: none !important; }   /* evita que el tema imprima la URL */
  #bh-ficha svg { flex: none; }

  /* Modo marca / neutral */
  body.bh-print-neutral #bh-ficha .bh-brand   { display: none !important; }
  body:not(.bh-print-neutral) #bh-ficha .bh-neutral { display: none !important; }

  /* ---------- Hoja ---------- */
  .bh-page {
    width: 816px;
    height: calc(11in - 1px);            /* el -1px evita una hoja en blanco por redondeo */
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    break-after: page;
    break-inside: avoid;
    page-break-after: always;
  }
  .bh-page:last-child { break-after: auto; page-break-after: auto; }
  .bh-page--flow { height: auto; min-height: calc(11in - 1px); overflow: visible; }

  /* ---------- Piezas comunes ---------- */
  .bh-pill {
    display: inline-block;
    background: #eef0f8;
    color: #283890;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.5;
    padding: 4px 12px;
    border-radius: 999px;
    break-inside: avoid;
  }
  .bh-pills { display: flex; flex-wrap: wrap; gap: 8px; }
  .bh-h3 { font-size: 22px; font-weight: 800; line-height: 1.2; color: #283890; break-after: avoid; }
  .bh-trico { display: flex; gap: 4px; height: 4px; }
  .bh-trico span:nth-child(1) { flex: 60; background: #283890; }
  .bh-trico span:nth-child(2) { flex: 15; background: #bf1e2e; }
  .bh-trico span:nth-child(3) { flex: 25; background: #283890; }
  .bh-trico-v { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; display: flex; flex-direction: column; }
  .bh-trico-v span:nth-child(1) { flex: 60; background: #283890; }
  .bh-trico-v span:nth-child(2) { flex: 15; background: #bf1e2e; }
  .bh-trico-v span:nth-child(3) { flex: 25; background: #283890; }
  .bh-ic {
    width: 24px; height: 24px; border-radius: 999px; flex: none;
    background: #bf1e2e; color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .bh-ic--lg { width: 28px; height: 28px; }
  .bh-disclaimer { font-size: 12px; line-height: 1.5; }

  /* Foto: marco 16:10. Horizontal = cover. Vertical = contain sobre gris. */
  .bh-ph {
    position: relative;
    overflow: hidden;
    background: #f6f6f6;
    border-radius: 8px;
    aspect-ratio: 16 / 10;
    break-inside: avoid;
  }
  .bh-ph img { width: 100%; height: 100%; object-fit: cover; }
  .bh-ph img.is-portrait { object-fit: contain; }

  /* =================== PORTADA (opción C) =================== */
  .bh-cover { flex-direction: row; }

  .bh-side {
    position: relative;
    width: 248px; flex: none;
    background: #f6f6f6;
    padding: 32px 24px 32px 32px;
    display: flex; flex-direction: column;
  }
  .bh-logo { width: 184px; }
  .bh-title-neutral { font-size: 22px; font-weight: 800; line-height: 1.2; color: #283890; }

  .bh-price { margin-top: 24px; display: flex; flex-direction: column; gap: 4px; }
  .bh-price small { font-size: 12px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; }
  .bh-price strong { font-size: 28px; font-weight: 800; line-height: 1.25; color: #bf1e2e; }
  .bh-price span { font-size: 13px; font-weight: 700; }

  .bh-sep { height: 1px; background: #e0e0e0; margin: 20px 0; }

  .bh-stats { display: flex; flex-direction: column; gap: 12px; }
  .bh-stat { display: flex; align-items: center; gap: 12px; break-inside: avoid; }
  .bh-stat b { display: block; font-size: 17px; font-weight: 700; line-height: 1.2; color: #283890; }
  .bh-stat span { display: block; font-size: 12px; font-weight: 600; }

  .bh-loc { display: flex; flex-direction: column; gap: 8px; font-size: 13px; font-weight: 600; }
  .bh-loc > span { display: flex; align-items: flex-start; gap: 8px; line-height: 1.4; }
  .bh-loc svg { margin-top: 2px; }
  .bh-loc .bh-id { font-size: 12px; font-weight: 700; color: #283890; }

  .bh-contact { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
  .bh-cta {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; border-radius: 8px;
    background: #bf1e2e; color: #fff !important;
    font-size: 14px; font-weight: 700;
  }
  .bh-qrbox { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; }
  .bh-qr { flex: none; width: 80px; height: 80px; background: #fff; padding: 4px; border-radius: 8px; border: 1px solid #e0e0e0; }
  .bh-qr svg { width: 100%; height: 100%; display: block; }
  .bh-qrbox span { font-size: 12px; font-weight: 700; line-height: 1.4; color: #283890; }
  .bh-cl { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; }
  .bh-cl--tel { font-size: 18px; font-weight: 800; line-height: 1.4; }

  .bh-main { flex: 1; min-width: 0; padding: 32px 40px 32px 32px; display: flex; flex-direction: column; }
  .bh-kicker { display: flex; align-items: center; gap: 12px; }
  .bh-kicker small { font-size: 12px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; }
  .bh-h1 { margin-top: 12px !important; font-size: 24px; font-weight: 800; line-height: 1.15; color: #bf1e2e; text-wrap: balance; break-after: avoid; }

  .bh-mosaic {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: 300px 190px;
    gap: 8px;
  }
  .bh-mosaic .bh-ph { aspect-ratio: auto; min-width: 0; min-height: 0; }
  .bh-mosaic .bh-ph:first-child { grid-column: span 2; }
  .bh-mosaic--2 { grid-template-rows: 300px 190px; }
  .bh-mosaic--2 .bh-ph:nth-child(2) { grid-column: span 2; }
  .bh-mosaic--1 { grid-template-rows: 490px; }

  .bh-intro { margin-top: 24px; }
  .bh-intro .bh-h3 { margin-bottom: 12px; }
  .bh-intro p { font-size: 14px; line-height: 1.6; margin-bottom: 12px; white-space: pre-line; break-inside: avoid; }
  .bh-more { font-size: 13px; font-weight: 700; color: #283890; }
  .bh-main .bh-pills { margin-top: 16px; }
  .bh-main .bh-disclaimer { margin-top: auto; padding-top: 12px; }

  /* =================== PÁGINAS INTERIORES =================== */
  .bh-head {
    padding: 32px 40px 16px;
    min-height: 84px;
    display: flex; justify-content: space-between; align-items: center;
  }
  .bh-head img { height: 36px; width: auto; }
  .bh-head .bh-title-neutral { line-height: 1.2; }
  .bh-head .bh-id { font-size: 14px; font-weight: 700; color: #283890; text-align: right; }
  .bh-rule { height: 1px; background: #e0e0e0; }

  .bh-body { padding: 24px 40px 0; }
  .bh-body + .bh-body { padding-top: 32px; }

  /* Descripción en texto corrido, 2 columnas */
  .bh-cols { margin-top: 12px; columns: 2; column-gap: 32px; font-size: 14px; line-height: 1.6; }
  .bh-cols p {
    margin-bottom: 12px;
    white-space: pre-line;
    break-inside: avoid;                 /* un bloque (p. ej. "Planta Alta" + su lista) no se parte */
    page-break-inside: avoid;
  }
  .bh-cols p:last-child { margin-bottom: 0; }

  /* Características */
  .bh-feat { margin-top: 12px; }
  .bh-feat .bh-pills { margin-bottom: 12px; }
  .bh-feat ul {
    list-style: none;
    border: 1px solid #e0e0e0; border-radius: 8px;
    padding: 14px 16px;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px;
    font-size: 15px; font-weight: 600; line-height: 1.3; color: #283890;
    break-inside: avoid;
  }
  .bh-feat li { display: flex; align-items: center; gap: 8px; break-inside: avoid; }
  .bh-feat li::before { content: ''; width: 7px; height: 7px; border-radius: 999px; background: #bf1e2e; flex: none; }

  /* Fotos pág. 3 y galería */
  .bh-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .bh-gal-title { display: flex; align-items: baseline; justify-content: space-between; }
  .bh-gal-title small { font-size: 13px; font-weight: 700; }

  /* Ficha técnica + mapa */
  .bh-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
  .bh-two > div { break-inside: avoid; }
  .bh-table { margin-top: 12px; border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden; break-inside: avoid; }
  .bh-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 16px; font-size: 14px; line-height: 1.4; border-top: 1px solid #e0e0e0; break-inside: avoid; }
  .bh-row:first-child { border-top: 0; }
  .bh-row:nth-child(even) { background: #f9f9fb; }
  .bh-row span { font-weight: 600; }
  .bh-row b { font-weight: 700; color: #283890; text-align: right; }
  .bh-row b.bh-red { color: #bf1e2e; }

  .bh-map {
    margin-top: 12px;
    position: relative;
    height: 298px;
    border: 1px solid #e0e0e0; border-radius: 8px;
    overflow: hidden; background: #eef0f8;
    break-inside: avoid;
  }
  .bh-map-tiles { position: absolute; left: 50%; top: 50%; width: 768px; height: 768px; display: grid; grid-template-columns: repeat(3, 256px); }
  .bh-map-tiles img { width: 256px; height: 256px; }
  /* Zona aproximada (500 m, sin pin): el diámetro lo calcula ficha-print.js según latitud y zoom. */
  .bh-map-area { position: absolute; left: 50%; top: 50%; width: 220px; height: 220px; transform: translate(-50%, -50%); border: 2px solid #283890; background: rgba(40, 56, 144, .15); border-radius: 50%; z-index: 2; }
  .bh-map-label { position: absolute; left: 8px; bottom: 8px; z-index: 2; background: rgba(255,255,255,.92); border-radius: 6px; padding: 3px 8px; font-size: 11px; font-weight: 700; color: #283890; }
  .bh-map-attr { position: absolute; right: 4px; bottom: 4px; z-index: 2; background: rgba(255,255,255,.8); padding: 0 4px; font-size: 9px; line-height: 1.4; }

  /* Pie */
  .bh-foot { margin-top: auto; break-inside: avoid; }
  .bh-foot-band { background: #f6f6f6; padding: 16px 40px 20px; display: flex; flex-direction: column; gap: 8px; }
  .bh-foot-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 13px; font-weight: 600; }
  .bh-foot-row a { display: flex; align-items: center; gap: 8px; }
  .bh-foot-row a.bh-tel { font-size: 16px; font-weight: 800; }
  .bh-foot-addr { font-size: 12px; font-weight: 600; line-height: 1.5; }
  .bh-foot-neutral { padding: 16px 40px 24px; border-top: 1px solid #e0e0e0; font-size: 12px; line-height: 1.5; }
}
