/* =========================================================
   v0.1.100 — Menus mais legíveis
   Corrige textos cortados/sobrepostos nos painéis de melhoria,
   especialmente Defesas do castelo, sem alterar a lógica do jogo.
   ========================================================= */

/* Painel de melhoria normal dos edifícios */
.building-upgrade-modal {
  width: min(880px, 96vw) !important;
  max-height: 92vh !important;
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
}
.building-upgrade-modal > .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.building-upgrade-modal .upgrade-benefits-panel {
  width: 100%;
}
.building-upgrade-modal .upgrade-benefit-head,
.building-upgrade-modal .upgrade-benefit-row {
  grid-template-columns: minmax(250px, 1.2fr) minmax(115px, .42fr) 22px minmax(175px, .72fr) minmax(96px, .34fr) !important;
  gap: 12px !important;
}
.building-upgrade-modal .upgrade-benefit-row {
  min-height: 60px !important;
}
.building-upgrade-modal .upgrade-benefit-name strong,
.building-upgrade-modal .upgrade-benefit-name small {
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: normal !important;
  line-height: 1.18;
}
.building-upgrade-modal .upgrade-benefit-current,
.building-upgrade-modal .upgrade-benefit-next,
.building-upgrade-modal .upgrade-benefit-difference {
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: normal !important;
  line-height: 1.15 !important;
}
.building-upgrade-modal .upgrade-benefit-current,
.building-upgrade-modal .upgrade-benefit-next {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.building-upgrade-modal .upgrade-benefit-difference {
  justify-self: stretch;
  align-self: center;
  max-width: 100%;
}

/* Defesas do castelo: cartões mais largos e comparação ao lado, sem texto cortado */
.castle-fortification-modal {
  width: min(1040px, 97vw) !important;
  max-height: 92vh !important;
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
}
.castle-fortification-modal > .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 14px 16px;
}
.castle-fortification-modal .castle-fortification-list {
  gap: 10px;
}
.castle-fortification-modal .castle-fortification-row {
  grid-template-columns: 54px minmax(0, 1fr) 108px !important;
  gap: 14px !important;
  padding: 14px !important;
  align-items: center;
}
.castle-fortification-modal .castle-fortification-icon {
  font-size: 34px;
}
.castle-fortification-modal .castle-fortification-main {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(160px, .75fr) minmax(470px, 1.55fr);
  grid-template-rows: auto auto auto;
  gap: 4px 14px;
  align-items: center;
}
.castle-fortification-modal .castle-fortification-main > strong {
  grid-column: 1;
  grid-row: 1;
  line-height: 1.15;
}
.castle-fortification-modal .castle-fortification-main > small {
  grid-column: 1;
  grid-row: 2;
  line-height: 1.2;
}
.castle-fortification-modal .castle-fortification-main > .costs {
  grid-column: 1;
  grid-row: 3;
  margin-top: 8px;
}
.castle-fortification-modal .castle-fortification-main > .upgrade-benefits-panel {
  grid-column: 2;
  grid-row: 1 / span 3;
  width: 100%;
  min-width: 0 !important;
  margin: 0 !important;
}
.castle-fortification-modal .upgrade-benefits-panel.is-fortification > header {
  padding: 8px 11px !important;
}
.castle-fortification-modal .upgrade-benefits-panel.is-fortification > header h3 {
  font-size: 14px;
}
.castle-fortification-modal .upgrade-benefits-panel.is-fortification .upgrade-benefit-row,
.castle-fortification-modal .upgrade-benefits-panel.is-compact .upgrade-benefit-row {
  grid-template-columns: minmax(210px, 1fr) 58px 18px 58px 86px !important;
  gap: 8px !important;
  min-height: 44px !important;
  padding: 8px 10px !important;
}
.castle-fortification-modal .upgrade-benefits-panel.is-fortification .upgrade-benefit-name {
  gap: 7px;
}
.castle-fortification-modal .upgrade-benefits-panel.is-fortification .upgrade-benefit-name > span {
  width: 22px;
  flex: 0 0 22px;
  font-size: 16px;
}
.castle-fortification-modal .upgrade-benefits-panel.is-fortification .upgrade-benefit-name strong,
.castle-fortification-modal .upgrade-benefits-panel.is-fortification .upgrade-benefit-name small {
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: normal !important;
  line-height: 1.15;
}
.castle-fortification-modal .upgrade-benefits-panel.is-fortification .upgrade-benefit-current,
.castle-fortification-modal .upgrade-benefits-panel.is-fortification .upgrade-benefit-next,
.castle-fortification-modal .upgrade-benefits-panel.is-fortification .upgrade-benefit-difference {
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: nowrap;
}
.castle-fortification-modal .castle-fortification-row > .action-btn {
  width: 108px;
  padding: 10px 8px;
  white-space: nowrap;
}

/* Evita sobreposição em menus de comparação compactos usados noutros painéis */
.upgrade-benefits-panel.is-compact .upgrade-benefit-name strong,
.upgrade-benefits-panel.is-compact .upgrade-benefit-name small {
  line-height: 1.15;
}
.upgrade-benefit-current,
.upgrade-benefit-next,
.upgrade-benefit-difference {
  min-width: 0;
}

@media (max-width: 940px) {
  .castle-fortification-modal .castle-fortification-row {
    grid-template-columns: 46px minmax(0, 1fr) !important;
  }
  .castle-fortification-modal .castle-fortification-main {
    grid-template-columns: 1fr;
  }
  .castle-fortification-modal .castle-fortification-main > .upgrade-benefits-panel {
    grid-column: 1;
    grid-row: auto;
    margin-top: 8px !important;
  }
  .castle-fortification-modal .castle-fortification-row > .action-btn {
    grid-column: 1 / -1;
    justify-self: end;
  }
  .castle-fortification-modal .upgrade-benefits-panel.is-fortification .upgrade-benefit-row,
  .building-upgrade-modal .upgrade-benefit-row {
    grid-template-columns: minmax(180px, 1fr) minmax(82px,.45fr) 18px minmax(118px,.65fr) 76px !important;
  }
}

@media (max-width: 720px) {
  .building-upgrade-modal .upgrade-benefit-head,
  .castle-fortification-modal .upgrade-benefit-head {
    display: none;
  }
  .building-upgrade-modal .upgrade-benefit-row,
  .castle-fortification-modal .upgrade-benefits-panel.is-fortification .upgrade-benefit-row {
    grid-template-columns: 1fr 58px 18px 58px !important;
  }
  .building-upgrade-modal .upgrade-benefit-difference,
  .castle-fortification-modal .upgrade-benefit-difference {
    grid-column: 2 / 5;
    justify-self: stretch;
  }
}


/* v0.1.120 — valores longos nos menus de melhoria (ex.: Cavalos de guerra) deixam de sobrepor a coluna Diferença. */
.building-upgrade-modal .upgrade-benefit-list {
  min-width: 0;
}
.building-upgrade-modal .upgrade-benefit-next,
.building-upgrade-modal .upgrade-benefit-current {
  overflow-wrap: anywhere;
}
.building-upgrade-modal .upgrade-benefit-head span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
