/*
 * XLX026_GRID_TEXT_WRAP_V1
 * Correção visual cirúrgica para nomes/localizações/gateways longos.
 * Não altera dados, identidade, ordem de colunas ou lógica JS.
 */

/* Base: nenhuma célula pode desenhar por cima da célula vizinha. */
body[data-page="conectados"] table.connected-table,
body[data-page="ao-vivo"] table.home-history {
    table-layout: fixed !important;
    width: 100% !important;
    max-width: 100% !important;
}

body[data-page="conectados"] table.connected-table th,
body[data-page="conectados"] table.connected-table td,
body[data-page="ao-vivo"] table.home-history th,
body[data-page="ao-vivo"] table.home-history td {
    min-width: 0 !important;
    box-sizing: border-box !important;
    vertical-align: middle !important;
}

/* CONECTADOS
 * 1 Nº | 2 País | 3 Indicativo | 4 Nome | 5 Cidade | ...
 */
body[data-page="conectados"] table.connected-table td:nth-child(4),
body[data-page="conectados"] table.connected-table td:nth-child(5) {
    white-space: normal !important;
    overflow: hidden !important;
    text-overflow: clip !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    line-height: 1.28 !important;
}

body[data-page="conectados"] table.connected-table td:nth-child(4),
body[data-page="conectados"] table.connected-table td:nth-child(5) {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    line-clamp: 2 !important;
    max-height: 2.7em !important;
}

body[data-page="conectados"] table.connected-table td:nth-child(3) {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
    font-weight: 800 !important;
}

/* ATIVIDADE 24H
 * 4 Indicativo | 5 Nome | 6 Hotspot/Repetidora | 7 Cidade
 */
body[data-page="ao-vivo"] table.home-history td:nth-child(5),
body[data-page="ao-vivo"] table.home-history td:nth-child(6),
body[data-page="ao-vivo"] table.home-history td:nth-child(7),
body[data-page="ao-vivo"] table.home-history .gateway-display,
body[data-page="ao-vivo"] table.home-history .gateway-value {
    white-space: normal !important;
    overflow: hidden !important;
    text-overflow: clip !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    line-height: 1.28 !important;
    max-width: 100% !important;
}

body[data-page="ao-vivo"] table.home-history td:nth-child(5),
body[data-page="ao-vivo"] table.home-history td:nth-child(6),
body[data-page="ao-vivo"] table.home-history td:nth-child(7) {
    max-height: 3.15em !important;
}

body[data-page="ao-vivo"] table.home-history .gateway-display {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    min-width: 0 !important;
}

body[data-page="ao-vivo"] table.home-history .gateway-value {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    line-clamp: 2 !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

/* Indicativo permanece legível, mas nunca invade outra coluna. */
body[data-page="ao-vivo"] table.home-history td:nth-child(4) {
    white-space: normal !important;
    overflow: hidden !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
}

/* AO VIVO — card TX atual.
 * Nome, localização e Hotspot/Repetidora podem ocupar duas linhas.
 */
body[data-page="ao-vivo"] #moduleGrid .tx-card.live .operator-name,
body[data-page="ao-vivo"] #moduleGrid .tx-card.live .tx-v30-name,
body[data-page="ao-vivo"] #moduleGrid .tx-card.live .operator-location,
body[data-page="ao-vivo"] #moduleGrid .tx-card.live .tx-hotspot-repeater,
body[data-page="ao-vivo"] #moduleGrid .tx-card.live .gateway-display,
body[data-page="ao-vivo"] #moduleGrid .tx-card.live .gateway-value {
    white-space: normal !important;
    overflow: hidden !important;
    text-overflow: clip !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    max-width: 100% !important;
    line-height: 1.22 !important;
}

body[data-page="ao-vivo"] #moduleGrid .tx-card.live .operator-name,
body[data-page="ao-vivo"] #moduleGrid .tx-card.live .tx-v30-name,
body[data-page="ao-vivo"] #moduleGrid .tx-card.live .tx-hotspot-repeater .gateway-value {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    line-clamp: 2 !important;
}

/* Desktop: reserva mais largura onde texto humano costuma ser maior. */
@media (min-width: 821px) {
    body[data-page="conectados"] table.connected-table th:nth-child(4),
    body[data-page="conectados"] table.connected-table td:nth-child(4) {
        width: 18% !important;
    }
    body[data-page="conectados"] table.connected-table th:nth-child(5),
    body[data-page="conectados"] table.connected-table td:nth-child(5) {
        width: 18% !important;
    }

    body[data-page="ao-vivo"] table.home-history th:nth-child(5),
    body[data-page="ao-vivo"] table.home-history td:nth-child(5) {
        width: 14% !important;
    }
    body[data-page="ao-vivo"] table.home-history th:nth-child(6),
    body[data-page="ao-vivo"] table.home-history td:nth-child(6) {
        width: 14% !important;
    }
    body[data-page="ao-vivo"] table.home-history th:nth-child(7),
    body[data-page="ao-vivo"] table.home-history td:nth-child(7) {
        width: 13% !important;
    }
}

/* Celular: mantém as regras móveis já existentes, mas garante quebra limpa. */
@media (max-width: 820px) {
    body[data-page="conectados"] table.connected-table td,
    body[data-page="ao-vivo"] table.home-history td {
        overflow: hidden !important;
    }

    body[data-page="conectados"] table.connected-table td:nth-child(4),
    body[data-page="conectados"] table.connected-table td:nth-child(5),
    body[data-page="ao-vivo"] table.home-history td:nth-child(5),
    body[data-page="ao-vivo"] table.home-history td:nth-child(6),
    body[data-page="ao-vivo"] table.home-history td:nth-child(7) {
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        word-break: normal !important;
        height: auto !important;
    }
}


/* XLX026_UI_REPEATER_APRS_V2 */
.gateway-display{display:inline-flex!important;align-items:center!important;gap:5px!important;max-width:100%!important;white-space:nowrap!important;overflow:visible!important}
.gateway-value{display:inline-block!important;white-space:nowrap!important;overflow:visible!important;text-overflow:clip!important;word-break:normal!important}
.repeater-info-button{display:inline-grid;place-items:center;width:18px;height:18px;min-width:18px;padding:0;border:1px solid rgba(0,216,255,.45);border-radius:50%;background:rgba(0,216,255,.08);color:#7deaff;font-size:10px;font-weight:900;line-height:1;cursor:pointer}.repeater-info-button:hover{background:rgba(0,216,255,.16);box-shadow:0 0 9px rgba(0,216,255,.2)}
.aprs-activity-satellite{display:inline-flex;align-items:center;justify-content:center;margin-left:5px;text-decoration:none!important;font-size:15px;line-height:1;filter:drop-shadow(0 0 5px rgba(0,216,255,.45));animation:xlxSatPulse 2s ease-in-out infinite}.connected-call-wrap{display:inline-flex;align-items:center;max-width:100%}@keyframes xlxSatPulse{50%{transform:translateY(-1px);filter:drop-shadow(0 0 8px rgba(33,234,160,.75))}}
.xlx026-repeater-dialog{width:min(92vw,520px);border:1px solid rgba(0,216,255,.35);border-radius:16px;background:#081722;color:#eefaff;padding:0;box-shadow:0 24px 80px rgba(0,0,0,.6)}.xlx026-repeater-dialog::backdrop{background:rgba(0,7,12,.72);backdrop-filter:blur(3px)}.repeater-dialog-head{display:flex;align-items:center;justify-content:space-between;padding:15px 18px;border-bottom:1px solid rgba(0,216,255,.16)}.repeater-dialog-head strong{font-size:19px}.repeater-dialog-head button{width:32px;height:32px;border:0;border-radius:9px;background:#102b3a;color:#fff;font-size:22px;cursor:pointer}.repeater-dialog-body{padding:17px}.repeater-detail-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}.repeater-detail-grid>div{padding:10px 11px;border:1px solid rgba(255,255,255,.08);border-radius:10px;background:rgba(255,255,255,.025);min-width:0}.repeater-detail-grid small,.repeater-detail-grid strong{display:block}.repeater-detail-grid small{color:#82a8ba;font-size:10px;text-transform:uppercase;letter-spacing:.06em}.repeater-detail-grid strong{margin-top:3px;font-size:13px;line-height:1.3;overflow-wrap:anywhere}.repeater-source{margin-top:14px;padding-top:12px;border-top:1px solid rgba(255,255,255,.08);font-size:11px;color:#9fc1d0;line-height:1.6}.repeater-source b{color:#dff8ff}.repeater-source span{color:#ffc857}.repeater-loading{color:#9fc1d0}
@media(max-width:560px){.repeater-detail-grid{grid-template-columns:1fr}.aprs-activity-satellite{font-size:14px;margin-left:4px}}
@media(prefers-reduced-motion:reduce){.aprs-activity-satellite{animation:none}}


/* XLX026_REPEATER_INDICATIVO_INFO_V1 */
body[data-page="ao-vivo"] .gateway-display{
  display:inline-flex !important;
  align-items:center !important;
  justify-content:flex-start !important;
  gap:5px !important;
  max-width:100% !important;
  white-space:nowrap !important;
}
body[data-page="ao-vivo"] .gateway-display .gateway-value{
  display:inline-block !important;
  white-space:nowrap !important;
  overflow:visible !important;
  text-overflow:clip !important;
  word-break:normal !important;
  line-height:1.15 !important;
}
body[data-page="ao-vivo"] .gateway-display .gateway-neon{display:none !important;}
body[data-page="ao-vivo"] .repeater-info-button{
  display:inline-grid !important;
  place-items:center !important;
  flex:0 0 17px !important;
  width:17px !important;
  height:17px !important;
  min-width:17px !important;
  margin:0 !important;
  padding:0 !important;
  border:1px solid rgba(0,216,255,.5) !important;
  border-radius:50% !important;
  background:rgba(0,216,255,.06) !important;
  color:#7deaff !important;
  font:800 10px/1 Arial,sans-serif !important;
  text-transform:none !important;
  cursor:pointer !important;
  box-shadow:none !important;
}
body[data-page="ao-vivo"] .repeater-info-button:hover,
body[data-page="ao-vivo"] .repeater-info-button:focus-visible{
  color:#fff !important;
  border-color:#00d8ff !important;
  background:rgba(0,216,255,.13) !important;
  box-shadow:0 0 7px rgba(0,216,255,.22) !important;
  outline:none !important;
}

/* REPEATER_GRID_CLEAN_V2 */
body[data-page="ao-vivo"] table.home-history .gateway-display.has-repeater-info{
  display:inline-flex!important;align-items:center!important;gap:6px!important;flex-wrap:nowrap!important;white-space:nowrap!important;
}
body[data-page="ao-vivo"] table.home-history .repeater-meta-fallback{
  color:#d9edf5!important;font-style:normal!important;
}
body[data-page="ao-vivo"] table.home-history .gateway-extra{display:none!important}
/* /REPEATER_GRID_CLEAN_V2 */

/* XLX026_CONECTADOS_LAYOUT_FIX_V1_20260907
   Corrige colunas estreitas e quebra letra-a-letra na página Conectados. */
body[data-page="conectados"] .connected-table-panel .table-wrap{
  width:100% !important;
  overflow-x:auto !important;
  overflow-y:visible !important;
}
body[data-page="conectados"] table.connected-table{
  width:100% !important;
  min-width:980px !important;
  table-layout:auto !important;
}
body[data-page="conectados"] table.connected-table th,
body[data-page="conectados"] table.connected-table td{
  vertical-align:middle !important;
  word-break:normal !important;
  overflow-wrap:normal !important;
  hyphens:none !important;
}
body[data-page="conectados"] table.connected-table th:nth-child(1),
body[data-page="conectados"] table.connected-table td:nth-child(1){width:42px !important;min-width:42px !important;text-align:center !important;white-space:nowrap !important;}
body[data-page="conectados"] table.connected-table th:nth-child(2),
body[data-page="conectados"] table.connected-table td:nth-child(2){width:52px !important;min-width:52px !important;text-align:center !important;white-space:nowrap !important;}
body[data-page="conectados"] table.connected-table th:nth-child(3),
body[data-page="conectados"] table.connected-table td:nth-child(3){min-width:120px !important;white-space:nowrap !important;}
body[data-page="conectados"] table.connected-table th:nth-child(4),
body[data-page="conectados"] table.connected-table td:nth-child(4){min-width:180px !important;max-width:260px !important;white-space:normal !important;line-height:1.25 !important;overflow-wrap:break-word !important;}
body[data-page="conectados"] table.connected-table th:nth-child(5),
body[data-page="conectados"] table.connected-table td:nth-child(5){min-width:170px !important;max-width:240px !important;white-space:normal !important;line-height:1.25 !important;overflow-wrap:break-word !important;}
body[data-page="conectados"] table.connected-table th:nth-child(6),
body[data-page="conectados"] table.connected-table td:nth-child(6){min-width:120px !important;white-space:nowrap !important;}
body[data-page="conectados"] table.connected-table th:nth-child(7),
body[data-page="conectados"] table.connected-table td:nth-child(7){min-width:70px !important;text-align:center !important;white-space:nowrap !important;}
body[data-page="conectados"] table.connected-table th:nth-child(8),
body[data-page="conectados"] table.connected-table td:nth-child(8),
body[data-page="conectados"] table.connected-table th:nth-child(9),
body[data-page="conectados"] table.connected-table td:nth-child(9),
body[data-page="conectados"] table.connected-table th:nth-child(10),
body[data-page="conectados"] table.connected-table td:nth-child(10){min-width:92px !important;white-space:nowrap !important;}

@media (max-width:820px){
  body[data-page="conectados"] table.connected-table{min-width:900px !important;}
}

/* XLX026_CONECTADOS_COLUMN_ALIGNMENT_FIX_V1
 * Restaura semântica de células da tabela Conectados.
 * Evita deslocamento de Localização/Protocolo/Módulo causado por display:-webkit-box.
 */
body[data-page="conectados"] table.connected-table td:nth-child(4),
body[data-page="conectados"] table.connected-table td:nth-child(5){
  display:table-cell !important;
  -webkit-box-orient:initial !important;
  -webkit-line-clamp:initial !important;
  line-clamp:initial !important;
  max-height:none !important;
  white-space:normal !important;
  overflow-wrap:normal !important;
  word-break:normal !important;
  overflow:visible !important;
  text-overflow:clip !important;
}
body[data-page="conectados"] table.connected-table td:nth-child(3){
  white-space:nowrap !important;
  overflow-wrap:normal !important;
}
@media (min-width:821px){
  body[data-page="conectados"] table.connected-table td:nth-child(4),
  body[data-page="conectados"] table.connected-table td:nth-child(5){
    white-space:normal !important;
  }
}

/* XLX026 DMR Talker Alias RX V1 — complementary radio-reported metadata */
.dmr-talker-alias-badge{display:inline-flex;align-items:center;justify-content:center;width:13px;height:13px;min-width:13px;margin-left:2px;padding:0;border:1px solid currentColor;border-radius:50%;font-size:7px;font-weight:900;line-height:1;vertical-align:middle;opacity:.78;cursor:help;letter-spacing:0;flex:0 0 13px}.dmr-talker-alias-badge:hover,.dmr-talker-alias-badge:focus{opacity:1}.connected-call-wrap{white-space:nowrap!important}@media(max-width:560px){.dmr-talker-alias-badge{width:12px;height:12px;min-width:12px;flex-basis:12px;margin-left:2px;font-size:6px}}


/* XLX026_INDICATIVO_WIDTH_V1 — espaço para posição + Talker Alias sem apertar a grade */
@media (min-width:821px){
  body[data-page="ao-vivo"] table.home-history th:nth-child(4),
  body[data-page="ao-vivo"] table.home-history td:nth-child(4){width:10% !important;}
  body[data-page="ao-vivo"] table.home-history th:nth-child(5),
  body[data-page="ao-vivo"] table.home-history td:nth-child(5){width:13% !important;}
  body[data-page="ao-vivo"] table.home-history th:nth-child(6),
  body[data-page="ao-vivo"] table.home-history td:nth-child(6){width:13% !important;}
}


/* XLX026_LAYOUT_WIDTH_UNIFICADO_1240_V1 — mesma proporção visual em todas as páginas */
@media (min-width:1101px){
  body[data-page="ao-vivo"] main{
    width:min(1240px,calc(100% - 32px)) !important;
    max-width:1240px !important;
  }
  body[data-page="ao-vivo"] .dashboard-main.compact-panel{
    padding-left:16px !important;
    padding-right:16px !important;
  }
  body[data-page="ao-vivo"] table.home-history{
    width:100% !important;
    max-width:100% !important;
  }
}
