/* Ficha integral de consulta de póliza: mismo lenguaje visual que la ficha de Clientes
   (tarjeta, cabecera, resumen, pestañas y secciones). Alcance limitado a #polizaDetalleView. */

/* Fila consultable del listado */
.polizas-body #tablaPolizas tr[data-id] { cursor: pointer; transition: background-color .16s ease, box-shadow .16s ease; }
.polizas-body #tablaPolizas tr[data-id]:hover,
.polizas-body #tablaPolizas tr[data-id]:focus-visible { background: #eef6ff; box-shadow: inset 3px 0 0 #2f80ed; outline: none; }

/* Pantalla completa: la tarjeta ocupa la altura de la ventana y solo el contenido se desplaza */
.polizas-body.polizas-detail-open { overflow: hidden !important; }
.polizas-body.polizas-detail-open #main-content { height: 100vh !important; min-height: 0 !important; overflow: hidden !important; }

#polizaDetalleView[hidden] { display: none !important; }
#polizaDetalleView { box-sizing: border-box; height: 100%; min-width: 0; overflow: hidden; padding: 18px 24px; width: 100%; color: #24364b; }
#polizaDetalleView *, #polizaDetalleView *::before, #polizaDetalleView *::after { box-sizing: border-box; }

.policy-detail-card {
  background: #fff; border: 1px solid #d6e2ef; border-radius: 12px; box-shadow: 0 10px 32px rgba(15, 45, 75, .1);
  display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; padding: 20px 22px; position: relative;
}

/* Cabecera */
.policy-detail-header { align-items: center; border-bottom: 1px solid #dbe5f0; display: flex; flex: 0 0 auto; gap: 16px; justify-content: space-between; padding: 0 4px 14px 0; }
.policy-detail-heading { align-items: center; display: flex; gap: 18px; min-width: 0; }
.policy-detail-heading > div { min-width: 0; }
.policy-detail-title { color: #0b2f4f; font-size: 23px; line-height: 1.2; margin: 2px 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.policy-detail-title:focus { outline: none; }
.policy-detail-subtitle { color: #64748b; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.policy-detail-eyebrow { color: #2f80ed; font-size: 10px; font-weight: 800; letter-spacing: .08em; margin: 0; text-transform: uppercase; }
.policy-detail-header .facturas-btn.neutral { background: #edf2f7; border: 1px solid #dbe5f0; color: #18314f; flex: 0 0 auto; }
.policy-detail-header .modal-close {
  align-items: center; background: transparent; border: 0; border-radius: 8px; color: #52677f; cursor: pointer; display: inline-flex;
  flex: 0 0 auto; font-size: 26px; height: 36px; justify-content: center; line-height: 1; position: static; width: 36px;
}
.policy-detail-header .modal-close:hover { background: #edf2f7; color: #0b2f4f; }

/* Resumen */
.policy-detail-summary {
  align-items: center; background: linear-gradient(135deg, #f2f7ff 0%, #f9fbfe 100%); border: 1px solid #d5e5f7; border-radius: 10px;
  display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: 14px 18px; margin: 14px 0 0; padding: 14px 18px;
}
.policy-detail-avatar {
  align-items: center; background: #2f80ed; border-radius: 50%; box-shadow: 0 5px 14px rgba(47, 128, 237, .25); color: #fff; display: flex;
  flex: 0 0 54px; font-size: 22px; height: 54px; justify-content: center; width: 54px;
}
.policy-detail-summary-main { flex: 1 1 260px; min-width: 0; }
.policy-detail-summary-main h3 { color: #0b2f4f; font-size: 18px; margin: 2px 0 7px; overflow-wrap: anywhere; }
.policy-detail-code { color: #5b7088; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.policy-detail-badges { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; }
.policy-detail-badge {
  align-items: center; background: #eef2f7; border-radius: 999px; color: #52677f; display: inline-flex; font-size: 10px; font-weight: 800;
  gap: 6px; line-height: 1.2; max-width: 100%; padding: 6px 10px; overflow-wrap: anywhere;
}
.policy-detail-badge.success { background: #dcfce7; color: #15803d; }
.policy-detail-badge.danger { background: #fee2e2; color: #b91c1c; }
.policy-detail-badge.info { background: #dbeafe; color: #1d4ed8; }
.policy-detail-badge.neutral { background: #e9eef5; color: #52677f; }
.policy-detail-badge i { font-size: 8px; }

.policy-detail-stats { display: grid; flex: 1 1 460px; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-left: auto; max-width: 680px; min-width: 0; }
.policy-detail-stat { align-items: center; background: #fff; border: 1px solid #d5e5f7; border-radius: 9px; display: flex; gap: 10px; min-width: 0; padding: 10px 12px; }
.policy-detail-stat-icon { align-items: center; background: #edf5ff; border-radius: 8px; color: #2f80ed; display: flex; flex: 0 0 32px; height: 32px; justify-content: center; width: 32px; }
.policy-detail-stat > div { min-width: 0; }
.policy-detail-stat small { color: #718096; display: block; font-size: 10px; font-weight: 700; margin-bottom: 2px; }
.policy-detail-stat strong { color: #0b2f4f; display: block; font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
.policy-detail-stat.is-pending { border-color: #f5c9c9; }
.policy-detail-stat.is-pending .policy-detail-stat-icon { background: #fee2e2; color: #b91c1c; }
.policy-detail-stat.is-pending strong { color: #b91c1c; }

/* Pestañas */
.policy-detail-tabs { align-items: flex-end; border-bottom: 2px solid #dbe5f0; display: flex; flex: 0 0 auto; gap: 10px; overflow-x: auto; padding: 10px 0 0; }
.policy-detail-tab {
  align-items: center; background: transparent; border: 0; border-bottom: 3px solid transparent; border-radius: 0; box-shadow: none; color: #52677f;
  cursor: pointer; display: inline-flex; flex: 0 0 auto; font-size: 12px; font-weight: 800; gap: 7px; justify-content: center; margin: 0 0 -2px;
  min-height: 42px; padding: 9px 13px; white-space: nowrap;
}
.policy-detail-tab:hover { background: #f5f9ff; color: #1f6feb; }
.policy-detail-tab.active { border-bottom-color: #2f80ed; color: #1672e8; }

/* Contenido desplazable */
.policy-detail-content { flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 16px 3px 4px; scrollbar-gutter: stable; }
.policy-detail-content::-webkit-scrollbar { width: 10px; }
.policy-detail-content::-webkit-scrollbar-thumb { background: #b9c8d8; border: 2px solid #f4f7fb; border-radius: 999px; }
.policy-detail-content::-webkit-scrollbar-track { background: #f4f7fb; }
.policy-detail-panel[hidden] { display: none !important; }
.policy-detail-panel { min-height: 100%; }

.policy-detail-sections { align-items: start; display: grid; gap: 15px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.policy-detail-section { background: #fff; border: 1px solid #ccdced; border-radius: 10px; box-shadow: 0 6px 18px rgba(22, 66, 110, .09); min-width: 0; padding: 16px 17px; }
.policy-detail-section h3 { align-items: center; border-bottom: 1px solid #e3ebf4; color: #173b61; display: flex; font-size: 13px; gap: 8px; margin: 0 0 13px; padding-bottom: 10px; }
.policy-detail-section h3 i { color: #2f80ed; }
.policy-detail-data-grid { display: grid; gap: 12px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.policy-detail-item { align-items: flex-start; display: flex; gap: 9px; min-width: 0; }
.policy-detail-item-icon { align-items: center; background: #edf5ff; border-radius: 7px; color: #2f80ed; display: flex; flex: 0 0 30px; height: 30px; justify-content: center; width: 30px; }
.policy-detail-item > div { min-width: 0; }
.policy-detail-item dt { color: #718096; font-size: 10px; font-weight: 700; margin-bottom: 3px; overflow-wrap: anywhere; }
.policy-detail-item dd { color: #153653; font-size: 12px; font-weight: 700; line-height: 1.35; margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.policy-detail-empty-value { color: #8a9aad; font-style: italic; font-weight: 500; }
.policy-detail-flag { border-radius: 999px; display: inline-block; font-size: 10px; font-weight: 800; line-height: 1; padding: 5px 10px; }
.policy-detail-flag.is-yes { background: #dcfce7; color: #15803d; }
.policy-detail-flag.is-no { background: #e9eef5; color: #52677f; }

/* Junto a "División de cartera" para no dejar un hueco en la cuadrícula; en una sola columna ocupa todo el ancho. */
.policy-detail-notes { grid-column: auto; }
.policy-detail-notes p { color: #425b73; line-height: 1.6; margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }

/* Estados */
.policy-detail-loading, .policy-detail-error {
  align-items: center; border: 1px dashed #c8d7e7; border-radius: 10px; color: #64748b; display: flex; flex: 1 1 auto; gap: 10px;
  justify-content: center; margin-top: 16px; min-height: 220px; padding: 24px; text-align: center;
}
.policy-detail-loading > i, .policy-detail-error > i { color: #2f80ed; font-size: 24px; }
.policy-detail-error { background: #fff6f6; border-color: #f0c4c4; color: #a12626; }
.policy-detail-error > i { color: #c0392b; }
.policy-detail-error strong, .policy-detail-error span { display: block; overflow-wrap: anywhere; }
.policy-detail-error span { font-size: 12px; margin-top: 3px; }

@media (max-width: 1000px) { .policy-detail-sections { grid-template-columns: 1fr; } .policy-detail-stats { flex-basis: 100%; max-width: none; } }

/* Pantallas bajas o móviles: cabecera + resumen + pestañas no dejan espacio al contenido, así que la tarjeta
   completa se desplaza y las pestañas quedan fijas arriba mientras se recorre la ficha. */
@media (max-width: 700px), (max-height: 800px) {
  .policy-detail-card { overflow-y: auto; scrollbar-gutter: stable; }
  .policy-detail-content { flex: 0 0 auto; min-height: auto; overflow: visible; }
  /* top negativo = padding superior de la tarjeta, para que las pestañas queden pegadas al borde. */
  .policy-detail-tabs { background: #fff; position: sticky; top: -20px; z-index: 3; }
}
@media (max-width: 700px) {
  #polizaDetalleView { padding: 8px; }
  .policy-detail-card { padding: 14px; }
  .policy-detail-header { align-items: flex-start; }
  .policy-detail-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .policy-detail-title { font-size: 19px; white-space: normal; }
  .policy-detail-subtitle { white-space: normal; }
  .policy-detail-stats { grid-template-columns: 1fr; }
  .policy-detail-tabs { gap: 4px; top: -14px; }
  .policy-detail-tab { padding: 9px 10px; }
  .policy-detail-data-grid { grid-template-columns: 1fr; }
}
