/* =========================================================
   Sistema modular: planeador de ataque por vagas e flancos
   Ficheiro lógico: src/attack-planner.js
   ========================================================= */
.attack-planner-modal {
  width:min(1180px,97vw);
  max-height:94vh;
  border-color:#765329;
  background:#2a2119;
}
.attack-planner-modal .modal-head {
  padding:10px 14px;
  background:linear-gradient(#5a4934,#3a2f25);
  border-bottom-color:#8b6a3d;
}
.attack-planner-modal .modal-body {
  padding:0;
  background:#d1b487;
  color:#2e241a;
}
.attack-planner-modal .modal-actions {
  padding:10px 14px;
  background:#5d4734;
  border-top-color:#8f6e47;
}
.attack-planner-shell { min-width:0; }
.attack-target-strip {
  display:grid;
  grid-template-columns:92px minmax(210px,1fr) 150px minmax(300px,1.35fr);
  align-items:center;
  gap:12px;
  min-height:108px;
  padding:10px 14px;
  color:#f8edd6;
  background:linear-gradient(110deg,#4d3a29,#6d5137 55%,#3e3025);
  border-bottom:3px solid #8d6a3b;
}
.attack-target-portrait {
  width:82px;
  height:88px;
  display:grid;
  place-items:center;
  overflow:hidden;
  border:2px solid #d7b978;
  border-radius:8px;
  background:radial-gradient(circle,#799151,#29341f);
  box-shadow:0 5px 12px #0008;
}
.attack-target-portrait img { width:78px; height:94px; object-fit:contain; filter:drop-shadow(0 5px 4px #0009); }
.attack-target-main small,.attack-target-stat small { display:block; color:#d9c7a7; font-size:11px; text-transform:uppercase; letter-spacing:.45px; }
.attack-target-main strong { display:block; margin:3px 0; color:#ffe6aa; font-family:Georgia,serif; font-size:22px; }
.attack-target-main span { color:#e8dac0; font-size:12px; }
.attack-target-stat {
  padding:10px 12px;
  border:1px solid #9a7849;
  border-radius:7px;
  background:#2b221bcc;
  box-shadow:inset 0 1px #ffffff18;
}
.attack-target-stat b { display:block; margin-top:5px; color:white; font-size:18px; }
.attack-target-stat.loot b { font-size:12px; }
.attack-target-stat .resource-svg-line { justify-content:flex-start; }

.attack-planner-layout {
  display:grid;
  grid-template-columns:174px minmax(560px,1fr) 224px;
  min-height:520px;
}
.attack-wave-panel,.attack-summary-panel {
  padding:13px;
  background:#b99064;
}
.attack-wave-panel { border-right:2px solid #80603d; }
.attack-summary-panel { border-left:2px solid #80603d; }
.attack-wave-panel h4,.attack-summary-panel h4 { margin:0 0 5px; color:#392719; font-family:Georgia,serif; font-size:17px; }
.attack-wave-panel p { margin:0 0 11px; color:#624a35; font-size:11px; line-height:1.35; }
.attack-wave-list { display:grid; gap:7px; }
.attack-wave-btn {
  width:100%;
  padding:10px;
  text-align:left;
  border:2px solid #896845;
  border-radius:7px;
  color:#3e2d20;
  background:linear-gradient(#e2c39a,#c7a170);
  box-shadow:inset 0 1px #fff8;
}
.attack-wave-btn span { display:block; font-weight:900; }
.attack-wave-btn small { display:block; margin-top:2px; color:#70543b; }
.attack-wave-btn.active { border-color:#4a6b1d; background:linear-gradient(#a8cf4b,#6f9f25); color:#172205; }
.attack-wave-btn.active small { color:#26380d; }
.attack-wave-btn.has-troops:not(.active) { border-color:#587329; box-shadow:inset 5px 0 #668f25; }
.attack-panel-btn { width:100%; margin-top:10px; }

.attack-formation-panel { min-width:0; padding:13px; background:#dfc29a; }
.attack-section-heading { display:flex; align-items:end; justify-content:space-between; gap:14px; margin-bottom:10px; }
.attack-section-heading small { color:#765d42; text-transform:uppercase; font-size:10px; letter-spacing:.6px; }
.attack-section-heading h4 { margin:1px 0 0; color:#3d2919; font-family:Georgia,serif; font-size:22px; }
.attack-section-heading > span { max-width:430px; color:#6a5138; font-size:11px; text-align:right; }
.attack-flank-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:9px; }
.attack-flank-card {
  min-width:0;
  overflow:hidden;
  border:2px solid #81603c;
  border-radius:8px;
  background:#ecd1aa;
  box-shadow:0 5px 11px #6b492b44;
}
.attack-flank-card.is-disabled { filter:saturate(.45); opacity:.72; }
.attack-flank-toggle {
  width:100%;
  min-height:44px;
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 9px;
  color:#2d241b;
  border:0;
  border-bottom:1px solid #9d7a50;
  background:linear-gradient(#d8b584,#b88e5e);
  text-align:left;
}
.attack-flank-card.is-enabled .attack-flank-toggle { background:linear-gradient(#9ec64b,#6e9f28); }
.attack-flank-toggle > span { width:22px; height:22px; display:grid; place-items:center; border:1px solid #5c4b34; border-radius:4px; background:#f0dfc4; font-weight:900; }
.attack-flank-toggle b { min-width:0; font-size:12px; }
.attack-flank-total { display:flex; justify-content:space-between; gap:6px; padding:6px 9px; color:#695037; background:#c6a275; font-size:10px; }
.attack-flank-total strong { color:#2f2419; }
.attack-troop-list { padding:4px 8px 8px; }
.attack-troop-row {
  display:grid;
  grid-template-columns:minmax(0,1fr) 72px;
  align-items:center;
  gap:7px;
  padding:6px 0;
  border-bottom:1px solid #b8966d;
}
.attack-troop-row:last-child { border-bottom:0; }
.attack-troop-name { min-width:0; display:flex; align-items:center; gap:5px; color:#493523; font-size:11px; }
.attack-troop-name b { font-size:18px; }
.attack-troop-name span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.attack-troop-row input {
  width:100%;
  padding:7px 5px;
  color:#241b13;
  border:1px solid #83623e;
  border-radius:5px;
  background:#fff0d4;
  font-weight:800;
  text-align:center;
}
.attack-troop-row input:focus { outline:2px solid #6e962f; border-color:#47651b; }
.attack-troop-row input:disabled { color:#8d7c68; background:#cbb393; }
.attack-order-strip {
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  margin-top:12px;
  padding:9px;
  border:1px solid #9d7a50;
  border-radius:7px;
  background:#c7a478;
}
.attack-order-strip > span { margin-right:4px; color:#59412d; font-size:11px; font-weight:900; }
.attack-order-strip > i { color:#765635; font-style:normal; font-weight:900; }
.attack-order-step { min-width:64px; display:grid; grid-template-columns:22px 1fr; align-items:center; padding:5px; border:1px solid #9b7a52; border-radius:5px; background:#ddc29b; color:#69513a; }
.attack-order-step b { grid-row:1/3; width:19px; height:19px; display:grid; place-items:center; border-radius:50%; background:#8f7452; color:white; font-size:10px; }
.attack-order-step span { font-size:9px; font-weight:800; }
.attack-order-step small { font-size:9px; }
.attack-order-step.active { border-color:#527123; background:#a8cb58; color:#28370e; }
.attack-order-step.active b { background:#527123; }

.attack-availability-list { display:grid; gap:6px; }
.attack-availability-row {
  display:grid;
  grid-template-columns:1fr auto;
  gap:2px 7px;
  padding:7px;
  border:1px solid #8d6b46;
  border-radius:6px;
  background:#d7b485;
}
.attack-availability-row span { min-width:0; color:#493522; font-size:11px; }
.attack-availability-row strong { color:#25350c; font-size:16px; }
.attack-availability-row small { grid-column:1/3; color:#70543b; font-size:9px; text-align:right; }
.attack-summary-box { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-top:8px; padding:8px; border:1px solid #7d5c38; border-radius:6px; color:#59412d; background:#cba576; font-size:11px; }
.attack-summary-box strong { color:#2f420f; font-size:17px; }
.attack-order-btn {
  min-width:260px;
  padding:11px 20px;
  border:2px solid #93c342;
  border-radius:7px;
  color:white;
  background:linear-gradient(#6faf1c,#3d7907);
  box-shadow:inset 0 2px #d8f49a99,0 4px 10px #0006;
  font-weight:900;
  text-shadow:0 1px 2px #254300;
}
.attack-order-btn:hover { filter:brightness(1.08); }

@media (max-width:1100px) {
  .attack-planner-layout { grid-template-columns:150px minmax(480px,1fr) 195px; }
  .attack-target-strip { grid-template-columns:80px 1fr 130px; }
  .attack-target-stat.loot { grid-column:2/4; }
  .attack-flank-grid { gap:6px; }
}
@media (max-width:850px) {
  .attack-planner-modal { width:98vw; }
  .attack-planner-layout { grid-template-columns:1fr; }
  .attack-wave-panel,.attack-summary-panel { border:0; }
  .attack-wave-list { grid-template-columns:repeat(4,1fr); }
  .attack-flank-grid { grid-template-columns:1fr; }
  .attack-summary-panel { display:grid; grid-template-columns:repeat(2,1fr); gap:7px; }
  .attack-summary-panel h4,.attack-availability-list { grid-column:1/3; }
  .attack-panel-btn { margin-top:0; }
}
.attack-player-castle {
  display:grid;
  place-items:center;
  width:76px;
  height:76px;
  font-size:52px;
  line-height:1;
  filter:drop-shadow(0 4px 5px rgba(0,0,0,.45));
}

/* =========================================================
   v0.1.89 — Planeador de ataque ajustado para caber no ecrã
   Sem scroll vertical na janela de ataque/captura dos Postos Avançados.
   ========================================================= */
.attack-planner-modal {
  width:min(1190px,98vw);
  height:min(970px,calc(100vh - 20px));
  max-height:calc(100vh - 20px);
  display:flex;
  flex-direction:column;
  overflow:hidden !important;
}
.attack-planner-modal .modal-head {
  flex:0 0 auto;
  padding:8px 14px;
}
.attack-planner-modal .modal-head h3 { font-size:18px; }
.attack-planner-modal .modal-close { line-height:1; }
.attack-planner-modal .modal-body {
  flex:1 1 auto;
  min-height:0;
  display:flex;
  padding:0;
  overflow:hidden !important;
}
.attack-planner-modal .modal-actions {
  flex:0 0 auto;
  padding:7px 14px;
}
.attack-planner-shell {
  flex:1 1 auto;
  min-height:0;
  height:100%;
  display:flex;
  flex-direction:column;
}
.attack-target-strip {
  flex:0 0 auto;
  grid-template-columns:76px minmax(210px,1fr) 150px minmax(285px,1.35fr);
  gap:10px;
  min-height:78px;
  padding:7px 14px;
}
.attack-target-portrait {
  width:66px;
  height:68px;
  border-radius:7px;
}
.attack-target-portrait img {
  width:62px;
  height:74px;
}
.attack-player-castle {
  width:62px;
  height:62px;
  font-size:42px;
}
.attack-target-main small,
.attack-target-stat small { font-size:10px; }
.attack-target-main strong {
  margin:1px 0;
  font-size:19px;
  line-height:1.08;
}
.attack-target-main span { font-size:11px; }
.attack-target-stat {
  padding:7px 10px;
  border-radius:6px;
}
.attack-target-stat b {
  margin-top:3px;
  font-size:16px;
}
.attack-target-stat.loot b { font-size:11px; }
.attack-planner-layout {
  flex:1 1 auto;
  min-height:0;
  height:auto;
  grid-template-columns:174px minmax(560px,1fr) 214px;
}
.attack-wave-panel,
.attack-summary-panel,
.attack-formation-panel {
  min-height:0;
  padding:10px;
  overflow:hidden;
}
.attack-wave-panel h4,
.attack-summary-panel h4 {
  margin-bottom:4px;
  font-size:16px;
  line-height:1.05;
}
.attack-wave-panel p {
  margin-bottom:8px;
  font-size:10px;
}
.attack-wave-list { gap:6px; }
.attack-wave-btn {
  padding:8px 9px;
  border-radius:6px;
}
.attack-wave-btn span { font-size:14px; }
.attack-wave-btn small { font-size:10px; }
.attack-panel-btn { margin-top:8px; }
.attack-section-heading {
  align-items:center;
  margin-bottom:8px;
}
.attack-section-heading h4 {
  font-size:20px;
  line-height:1.05;
}
.attack-section-heading small { font-size:9px; }
.attack-section-heading > span {
  max-width:420px;
  font-size:10px;
}
.attack-flank-grid { gap:8px; }
.attack-flank-card { border-radius:7px; }
.attack-flank-toggle {
  min-height:36px;
  padding:6px 8px;
}
.attack-flank-toggle > span {
  width:21px;
  height:21px;
}
.attack-flank-toggle b { font-size:11px; }
.attack-flank-total {
  padding:5px 8px;
  font-size:9px;
}
.attack-troop-list { padding:3px 8px 6px; }
.attack-troop-row {
  grid-template-columns:minmax(0,1fr) 70px;
  gap:6px;
  padding:5px 0;
}
.attack-troop-name { font-size:10px; }
.attack-troop-name b { font-size:16px; }
.attack-troop-row input {
  padding:6px 5px;
  border-radius:5px;
}
.attack-tools-section {
  margin-top:6px;
  padding-top:6px;
}
.attack-tools-heading {
  margin-bottom:4px;
}
.attack-tools-heading span { font-size:11px; }
.attack-tools-heading small { font-size:8px; }
.attack-tool-row {
  grid-template-columns:1fr 58px 42px;
  gap:5px;
  padding:3px 0;
}
.attack-tool-name { gap:5px; }
.attack-tool-name .siege-tool-icon {
  flex-basis:24px;
  width:24px;
  height:24px;
}
.attack-tool-name b { font-size:10px; }
.attack-tool-name small { font-size:7px; }
.attack-tool-input {
  padding:5px 4px;
  border-radius:4px;
}
.attack-tool-row em { font-size:8px; }
.attack-order-strip {
  margin-top:8px;
  padding:7px;
}
.attack-order-step {
  min-width:60px;
  padding:4px;
}
.attack-order-step b {
  width:18px;
  height:18px;
}
.attack-availability-list { gap:5px; }
.attack-availability-row {
  padding:6px;
  border-radius:5px;
}
.attack-availability-row span { font-size:10px; }
.attack-availability-row strong { font-size:15px; }
.attack-availability-row small { font-size:8px; }
.attack-tools-summary {
  margin-top:8px;
  padding-top:8px;
}
.attack-tools-summary h4 {
  margin-bottom:5px;
  font-size:16px;
  line-height:1.05;
}
.attack-tool-summary-row {
  grid-template-columns:24px 1fr auto;
  gap:5px;
  padding:4px 0;
  font-size:10px;
}
.attack-tool-summary-row .siege-tool-icon {
  width:23px;
  height:23px;
}
.attack-tools-total {
  margin-top:5px;
  padding:6px;
}
.attack-summary-box {
  margin-top:6px;
  padding:7px;
  font-size:10px;
}
.attack-summary-box strong { font-size:15px; }
.attack-order-btn {
  min-width:240px;
  padding:9px 18px;
}

@media (max-height:850px) {
  .attack-planner-modal {
    width:min(1200px,99vw);
    height:calc(100vh - 12px);
    max-height:calc(100vh - 12px);
  }
  .attack-planner-modal .modal-head { padding:6px 12px; }
  .attack-planner-modal .modal-actions { padding:6px 12px; }
  .attack-target-strip {
    min-height:66px;
    grid-template-columns:64px minmax(200px,1fr) 135px minmax(270px,1.3fr);
    padding:5px 12px;
  }
  .attack-target-portrait { width:56px; height:58px; }
  .attack-target-portrait img { width:52px; height:64px; }
  .attack-player-castle { width:52px; height:52px; font-size:36px; }
  .attack-target-main strong { font-size:17px; }
  .attack-target-main span { font-size:10px; }
  .attack-target-stat { padding:5px 8px; }
  .attack-planner-layout { grid-template-columns:160px minmax(535px,1fr) 205px; }
  .attack-wave-panel,
  .attack-summary-panel,
  .attack-formation-panel { padding:8px; }
  .attack-flank-toggle { min-height:32px; padding:5px 7px; }
  .attack-troop-row { padding:4px 0; }
  .attack-troop-row input { padding:5px 4px; }
  .attack-tool-row { padding:2px 0; }
  .attack-order-strip { margin-top:6px; padding:6px; }
}

/* =========================================================
   v0.1.151 — Janela de ataque sempre totalmente visível
   O planeador abre junto ao topo do ecrã e respeita a altura
   disponível, mantendo os botões Cancelar/Dar ordem acessíveis.
   ========================================================= */
body.gge-layout-active .modal-backdrop.attack-planner-backdrop {
  box-sizing: border-box !important;
  place-items: start center !important;
  padding: 8px 10px !important;
}

body.gge-layout-active .modal-backdrop.attack-planner-backdrop > .attack-planner-modal {
  box-sizing: border-box !important;
  width: min(1190px, calc(100vw - 20px)) !important;
  height: min(970px, calc(100vh - 16px)) !important;
  max-height: calc(100vh - 16px) !important;
  margin: 0 !important;
}

@supports (height: 100dvh) {
  body.gge-layout-active .modal-backdrop.attack-planner-backdrop > .attack-planner-modal {
    height: min(970px, calc(100dvh - 16px)) !important;
    max-height: calc(100dvh - 16px) !important;
  }
}

@media (max-height: 760px) {
  body.gge-layout-active .modal-backdrop.attack-planner-backdrop {
    padding: 4px 6px !important;
  }

  body.gge-layout-active .modal-backdrop.attack-planner-backdrop > .attack-planner-modal {
    width: calc(100vw - 12px) !important;
    height: calc(100vh - 8px) !important;
    max-height: calc(100vh - 8px) !important;
  }
}

