/* === MGT2 Commerce – Styles ================================================= */

/* --- Fenetre de dialogue ----------------------------------------------------- */

.mgt2-commerce-dialog .window-header {
  background: linear-gradient(180deg, rgba(44, 44, 62, 0.96) 0%, rgba(30, 30, 43, 0.96) 100%);
  border-bottom: 1px solid #c9a227;
}

.mgt2-commerce-dialog .window-title {
  color: #d9b24c;
  text-shadow: none;
}

.mgt2-commerce-dialog .window-content,
#mgt2-commerce .window-content {
  padding: 0;
  overflow-y: auto;
  background: #f5f0e8;
}

.mgt2-commerce-form {
  display: flex;
  flex-direction: column;
  background: #f5f0e8;
  color: #222;
  min-width: 0;
}

/* --- Barre d onglets --------------------------------------------------------- */

.mgt2-commerce-dialog .mgt2-commerce-form .tabs,
.mgt2-commerce-form .tabs {
  display: flex;
  flex-direction: row;
  background: #2c2c3e;
  border-bottom: 3px solid #c9a227;
  margin: 0;
  padding: 0;
}

.mgt2-commerce-dialog .mgt2-commerce-form .tabs .item,
.mgt2-commerce-form .tabs .item {
  flex: 1;
  padding: 9px 8px;
  text-align: center;
  color: #d8c79a !important;
  cursor: pointer;
  font-size: 0.82em;
  font-weight: bold;
  border-bottom: 3px solid transparent;
  margin-bottom: -3px;
  transition: color 0.18s, border-color 0.18s;
  white-space: nowrap;
  text-shadow: none !important;
}

.mgt2-commerce-dialog .mgt2-commerce-form .tabs .item:hover,
.mgt2-commerce-form .tabs .item:hover {
  color: #f3e3b1 !important;
  background: rgba(201, 162, 39, 0.16) !important;
}

.mgt2-commerce-dialog .mgt2-commerce-form .tabs .item.active,
.mgt2-commerce-form .tabs .item.active {
  color: #d9b24c !important;
  border-bottom-color: #c9a227 !important;
  background: rgba(201, 162, 39, 0.18) !important;
}

/* --- Contenu des onglets ----------------------------------------------------- */

.mgt2-commerce-form .tab-content {
  padding: 14px 16px 10px;
}

.mgt2-commerce-form .tab {
  display: none;
}

.mgt2-commerce-form .tab.active {
  display: block;
}

.mgt2-commerce-dialog .mgt2-commerce-form h3,
.mgt2-commerce-form h3 {
  margin: 0 0 12px;
  color: #5f4300 !important;
  font-size: 1em;
  font-weight: bold;
  border-bottom: 1px solid #b78f26 !important;
  padding-bottom: 5px;
  text-shadow: none !important;
}

/* --- Champs generiques ------------------------------------------------------ */

.mgt2-commerce-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0;
}

.mgt2-commerce-form .form-group label {
  font-size: 0.78em;
  font-weight: bold;
  color: #444;
  line-height: 1.2;
}

.mgt2-commerce-form .form-group .hint {
  font-weight: normal;
  font-size: 0.85em;
  color: #777;
}

.mgt2-commerce-form input[type="text"],
.mgt2-commerce-form input[type="number"],
.mgt2-commerce-form select {
  width: 100%;
  box-sizing: border-box;
  padding: 5px 7px;
  font-size: 0.85em;
  background: #fff;
  color: #222;
  border: 1px solid #bbb;
  border-radius: 3px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
  height: 28px;
}

.mgt2-commerce-form input[type="text"]:focus,
.mgt2-commerce-form input[type="number"]:focus,
.mgt2-commerce-form select:focus {
  border-color: #c9a227;
  outline: none;
  box-shadow: 0 0 0 2px rgba(201,162,39,0.22);
}

.mgt2-commerce-form input[type="checkbox"] {
  accent-color: #c9a227;
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

.form-group-row {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.form-group-row .form-group {
  flex: 1;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.85em;
  color: #333;
  cursor: pointer;
}

.mgt2-commerce-form fieldset {
  border: 1px solid #c9a227;
  border-radius: 5px;
  padding: 10px 12px 8px;
  margin: 10px 0;
  background: rgba(201,162,39,0.04);
}

.mgt2-commerce-dialog .mgt2-commerce-form fieldset legend,
.mgt2-commerce-form fieldset legend {
  color: #7a5c00 !important;
  font-size: 0.78em;
  font-weight: bold;
  padding: 0 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.actor-skill-helper {
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px dashed #c9a227;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.55);
}

.actor-skill-summary,
.actor-skill-empty {
  margin: 0;
  font-size: 0.8em;
  color: #444;
  line-height: 1.4;
}

.actor-skill-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.actor-skill-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(44, 44, 62, 0.08);
  color: #2c2c3e;
  font-size: 0.95em;
  white-space: nowrap;
}

button.btn-actor-skill,
.btn-actor-skill {
  width: fit-content !important;
  flex: 0 0 auto !important;
  height: 28px;
  padding: 0 11px;
  border: 1px solid #7a5c00;
  border-radius: 3px;
  background: #fff9eb;
  color: #7a5c00;
  font-size: 0.8em;
  font-weight: bold;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

button.btn-actor-skill:hover,
.btn-actor-skill:hover {
  background: #f5ecd0;
}

/* --- Bouton de calcul ------------------------------------------------------- */

.form-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

button.btn-calculate,
.btn-calculate {
  background: #2c2c3e;
  color: #e1bc57;
  border: 1px solid #c9a227;
  border-radius: 4px;
  padding: 7px 18px;
  font-size: 0.85em;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.18s;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-shadow: none;
}

button.btn-calculate:hover,
.btn-calculate:hover {
  background: #243852;
  color: #f2d27a;
}

/* === Blocs monde (zone recherche + UWP + Zone) ============================== */

/* Rangee de deux blocs monde + separateur parsecs */
.worlds-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.world-block {
  flex: 1;
  background: #ede8dc;
  border: 1px solid #d4c99a;
  border-radius: 5px;
  padding: 10px 11px 9px;
  min-width: 0;
}

.world-block-full {
  flex: none;
  width: 100%;
  margin-bottom: 10px;
}

.world-block-title {
  font-size: 0.78em;
  font-weight: bold;
  color: #7a5c00;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 7px;
}

/* Separateur parsecs entre les deux blocs */
.parsecs-separator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding-top: 24px;
  flex-shrink: 0;
  width: 68px;
}

.parsecs-separator > i {
  color: #c9a227;
  font-size: 1.1em;
}

.parsecs-separator .form-group {
  width: 100%;
  text-align: center;
}

.parsecs-separator input[type="number"] {
  text-align: center;
  padding: 5px 2px;
}

/* Ligne UWP + Zone en bas du bloc monde */
.uwp-zone-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 7px;
}

.uwp-zone-row .uwp-field {
  flex: 3;
  min-width: 0;
}

.uwp-zone-row .zone-field {
  flex: 2;
  min-width: 0;
}

.world-search-widget {
  position: relative;
}

.world-search-row {
  display: flex;
  gap: 5px;
  align-items: stretch;
}

/* Surcharge le width:100% global — doit se comporter en flex item */
.world-search-input {
  /* width:0 + flex:1 1 auto = prend tout l'espace libre sans déborder */
  width: 0 !important;
  flex: 1 1 auto !important;
  min-width: 0;
  padding: 5px 8px;
  font-size: 0.85em;
  background: #fff;
  color: #222;
  border: 1px solid #bbb;
  border-radius: 3px;
  height: 28px;
  box-sizing: border-box;
}

.world-search-input:focus {
  border-color: #c9a227;
  outline: none;
  box-shadow: 0 0 0 2px rgba(201,162,39,0.22);
}

.btn-world-search {
  /* Foundry met display:flex sur button → width:auto = pleine largeur.
     width:fit-content force la taille au contenu. */
  width: fit-content !important;
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  background: #4a4a6a;
  color: #c9a227;
  border: 1px solid #c9a227;
  border-radius: 3px;
  padding: 0 12px;
  cursor: pointer;
  font-size: 0.8em;
  font-weight: bold;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: background 0.18s;
}

.btn-world-search:hover {
  background: #2c2c3e;
}

.btn-world-search:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Liste de resultats (dropdown) */
.world-search-results {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 9999;
  background: #fff;
  border: 1px solid #c9a227;
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
}

.world-search-results:empty {
  display: none;
}

.world-search-results li {
  padding: 6px 10px;
  font-size: 0.83em;
  color: #222;
  cursor: pointer;
  border-bottom: 1px solid #f0e8d0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.world-search-results li:last-child {
  border-bottom: none;
}

.world-search-results li:hover {
  background: rgba(201,162,39,0.13);
}

.world-search-results li.no-result {
  color: #888;
  cursor: default;
  font-style: italic;
}

.world-search-results .world-name {
  font-weight: bold;
  color: #222;
}

.world-search-results .world-uwp {
  font-family: monospace;
  font-size: 0.88em;
  color: #555;
}

.world-search-results .world-sector {
  font-size: 0.78em;
  color: #999;
  margin-left: auto;
  white-space: nowrap;
}

/* === Zone de resultats inline (commerce speculatif) ========================= */

.trade-goods-result {
  margin-top: 14px;
  border-top: 2px solid #c9a227;
  padding-top: 10px;
}

.trade-goods-result h4 {
  color: #7a5c00;
  margin: 0 0 8px;
  font-size: 0.9em;
  font-weight: bold;
}

.trade-good-item label {
  color: #222 !important;
  font-size: 0.83em;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 0;
  cursor: pointer;
}

/* === Carte de chat ========================================================== */

.mgt2-commerce-result {
  font-size: 0.85em;
  color: #222;
}

.mgt2-commerce-result .commerce-header h3 {
  color: #7a5c00;
  border-bottom: 2px solid #c9a227;
  padding-bottom: 4px;
  margin-bottom: 8px;
  font-size: 1em;
}

.mgt2-commerce-result .commerce-section {
  margin-bottom: 8px;
  color: #333;
}

.mgt2-commerce-result .route {
  margin: 4px 0;
  color: #444;
}

/* Tables de resultats */
.commerce-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82em;
  margin-bottom: 8px;
}

.commerce-table th {
  background: #2c2c3e;
  color: #c9a227;
  padding: 4px 5px;
  text-align: center;
  border: 1px solid #555;
  font-size: 0.9em;
}

.commerce-table td {
  padding: 3px 5px;
  border: 1px solid #ccc;
  text-align: center;
  color: #222;
}

.commerce-table tr:nth-child(even) td {
  background: rgba(0,0,0,0.04);
}

.commerce-table tr.has-passengers td {
  color: #000;
  font-weight: bold;
}

.commerce-table tfoot td,
.commerce-table tr.total-row td {
  background: #e8f4e8;
  color: #2a6a2a;
  font-weight: bold;
  border-top: 2px solid #4a8a4a;
}

.total-revenue-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #e8f4e8;
  color: #2a6a2a;
  border-top: 2px solid #4a8a4a;
  border-radius: 0 0 4px 4px;
  padding: 4px 8px;
  font-size: 0.85em;
  margin-top: -1px;
}

.commerce-table tr.illegal-good td {
  color: #b01020;
}

/* Courrier */
.mail-section { font-size: 0.88em; }
.mail-available { color: #2a7a2a; font-weight: bold; }
.mail-none { color: #777; }

.no-goods {
  color: #666;
  font-style: italic;
  text-align: center;
  padding: 8px;
}

/* === Colonnes de table ====================================================== */

.commerce-table .col-label   { text-align: left; min-width: 80px; }
.commerce-table .col-dice    { text-align: center; color: #555; font-size: 0.9em; min-width: 32px; }
.commerce-table .col-main    { text-align: right; min-width: 50px; }
.commerce-table .col-revenue { text-align: right; font-weight: bold; background: rgba(42,106,42,0.07); min-width: 60px; }
.commerce-table .col-mod     { text-align: center; min-width: 40px; font-weight: bold; }
.commerce-table .col-d66     { text-align: center; min-width: 28px; font-family: monospace; }

/* En-têtes de colonnes dice discrets */
.commerce-table th.col-dice {
  background: #3a3a52;
  color: #a0a0c0;
}

/* === Couleurs des modificateurs ============================================= */

.mod-pos { color: #1a6a1a; font-weight: bold; }
.mod-neg { color: #a01020; font-weight: bold; }
.mod-zero { color: #777; }

/* === Ligne de route ========================================================= */

.mgt2-commerce-result .route {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  flex-wrap: wrap;
}

.route-uwp {
  font-family: monospace;
  font-size: 0.95em;
  background: #2c2c3e;
  color: #c9a227;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: bold;
}

.route-arrow {
  color: #c9a227;
  font-size: 0.85em;
}

.route-parsecs {
  color: #666;
  font-size: 0.85em;
  font-style: italic;
}

.trade-codes {
  font-family: monospace;
  font-weight: bold;
  color: #1a5a8a;
  letter-spacing: 0.05em;
}

.supplier-roll {
  font-size: 0.9em;
  color: #444;
  margin: 3px 0;
}

.dice-detail {
  color: #777;
  font-style: italic;
}

.dice-total {
  color: #1a5a1a;
}

/* === Tooltips sur les en-têtes de table ===================================== */

.commerce-table th {
  position: relative;
}

.commerce-table th[data-tip] {
  cursor: help;
}

.commerce-table th[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: #1c1c2e;
  color: #f0ead8;
  padding: 7px 10px;
  border-radius: 5px;
  font-size: 0.76em;
  font-weight: normal;
  white-space: normal;
  width: 200px;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  z-index: 9999;
  border: 1px solid #c9a227;
  line-height: 1.45;
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
  transition: opacity 0.15s 0.25s;
}

.commerce-table th[data-tip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #c9a227;
  pointer-events: none;
  opacity: 0;
  z-index: 9999;
  transition: opacity 0.15s 0.25s;
}

.commerce-table th[data-tip]:hover::after,
.commerce-table th[data-tip]:hover::before {
  opacity: 1;
}

.tip-icon {
  font-size: 0.7em;
  opacity: 0.6;
  vertical-align: super;
  margin-left: 2px;
}

/* Bandeau monde sélectionné (depuis carte de chat) */

.world-info-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #e8e0d0;
  border: 1px solid #c9a227;
  border-radius: 4px;
  margin-bottom: 10px;
  font-size: 0.95em;
}

.world-info-banner i {
  color: #c9a227;
}

.world-info-banner .world-info-loc {
  color: #888;
  font-size: 0.85em;
}
