/* Outpost Tab Styles */

.outpost-tab-container {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.outpost-build-status {
  background: #f8f9fa;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 25px;
}

.outpost-build-status h3 {
  margin: 0 0 15px 0;
  color: #495057;
  font-size: 1.2em;
}

.outpost-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 15px;
}

.outpost-stats .stat {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: white;
  border-radius: 4px;
  border: 1px solid #dee2e6;
}

.outpost-stats .label {
  font-weight: 600;
  color: #6c757d;
}

.outpost-stats .value {
  color: #212529;
  font-weight: 700;
}

.outpost-build-restriction {
  padding: 12px;
  border-radius: 6px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
}

.outpost-build-restriction.cooldown {
  background: #d1ecf1;
  border-color: #17a2b8;
  color: #0c5460;
}

.outpost-restriction-list {
  margin: 6px 0 0 0;
  padding-left: 20px;
  list-style: disc;
}

.outpost-restriction-list li {
  margin: 2px 0;
}

.outpost-build-ready {
  padding: 12px;
  border-radius: 6px;
  background: #d4edda;
  border: 1px solid #28a745;
  color: #155724;
  font-weight: 600;
}

.outpost-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #6c757d;
}

.outpost-empty-state p {
  margin: 10px 0;
  font-size: 1.1em;
}

.outpost-empty-state em {
  color: #007bff;
}

.outpost-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.outpost-list h3 {
  margin: 20px 0 10px 0;
  color: #495057;
  font-size: 1.3em;
  border-bottom: 2px solid #dee2e6;
  padding-bottom: 8px;
}

.outpost-card {
  background: white;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  padding: 20px;
  transition: all 0.3s ease;
  box-sizing: border-box;
  max-width: 100%;
}

.outpost-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.outpost-card.healthy {
  border-left: 4px solid #28a745;
}

.outpost-card.stopped {
  border-left: 4px solid #ffc107;
  background: #fffef5;
}

.outpost-card.decaying {
  border-left: 4px solid #dc3545;
  background: #fff5f5;
}

.outpost-card.demolished {
  border-left: 4px solid #6c757d;
  background: #f8f9fa;
  opacity: 0.7;
}

.outpost-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.outpost-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.outpost-icon {
  font-size: 1.8em;
}

.outpost-name {
  font-size: 1.3em;
  font-weight: 700;
  color: #212529;
}

.outpost-tier {
  background: #6c757d;
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: 600;
}

.outpost-health {
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9em;
}

.outpost-health.healthy {
  background: #d4edda;
  color: #155724;
}

.outpost-health.stopped {
  background: #fff3cd;
  color: #856404;
}

.outpost-health.decaying {
  background: #f8d7da;
  color: #721c24;
}

.outpost-health.demolished {
  background: #e2e3e5;
  color: #383d41;
}

.outpost-resources {
  margin: 15px 0;
}

.resource-bar {
  height: 24px;
  background: #e9ecef;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 8px;
  border: 1px solid #dee2e6;
}

.resource-fill {
  height: 100%;
  background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
  transition: width 0.5s ease;
  border-radius: 12px 0 0 12px;
}

.resource-text {
  text-align: center;
  font-weight: 600;
  color: #495057;
  font-size: 1.05em;
}

.outpost-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin: 15px 0;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
}

.outpost-details .detail {
  color: #495057;
  font-size: 0.95em;
}

.outpost-details .detail strong {
  color: #212529;
}

.outpost-details .detail.warning {
  color: #dc3545;
  font-weight: 600;
}

.outpost-details .detail.automated {
  color: #007bff;
  font-weight: 600;
}

.outpost-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #dee2e6;
}

.outpost-actions .btn {
  padding: 8px 14px;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85em;
  white-space: nowrap;
}

.outpost-actions .btn-sm {
  font-size: 0.9em;
  padding: 8px 14px;
}

.outpost-actions .btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.outpost-actions .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.outpost-actions .btn-danger {
  background: #dc3545;
  color: white;
}

.outpost-actions .btn-danger:hover:not(:disabled) {
  background: #c82333;
}

.outpost-send-caravan {
  background: #28a745;
  color: white;
}

.outpost-send-caravan:hover:not(:disabled) {
  background: #218838;
}

.outpost-toggle-automation.automation-active {
  background: #007bff;
  color: white;
}

.outpost-toggle-automation.automation-active:hover:not(:disabled) {
  background: #0069d9;
}

.outpost-toggle-automation.automation-inactive {
  background: #e9ecef;
  color: #495057;
  border: 1px solid #adb5bd;
}

.outpost-toggle-automation.automation-inactive:hover:not(:disabled) {
  background: #dee2e6;
}

.outpost-upgrade {
  background: #17a2b8;
  color: white;
}

.outpost-upgrade:hover:not(:disabled) {
  background: #138496;
}

.outpost-garrison {
  background: #6c757d;
  color: white;
}

.outpost-garrison:hover:not(:disabled) {
  background: #5a6268;
}

.outpost-withdraw {
  background: #6c757d;
  color: white;
}

.outpost-withdraw:hover:not(:disabled) {
  background: #5a6268;
}

.outpost-rename {
  background: #e9ecef;
  color: #495057;
  border: 1px solid #adb5bd;
}

.outpost-rename:hover:not(:disabled) {
  background: #dee2e6;
}

.outpost-demolish {
  background: #dc3545;
  color: white;
}

.outpost-demolish:hover:not(:disabled) {
  background: #c82333;
}

/* Upgrade progress bar */
.outpost-upgrade-progress {
  margin-top: 8px;
  padding: 8px 0;
}

.outpost-upgrade-progress p {
  margin: 0 0 6px 0;
  font-weight: 600;
  color: #17a2b8;
}

.upgrade-bar {
  height: 18px !important;
}

.upgrade-fill {
  background: linear-gradient(90deg, #17a2b8 0%, #20c997 100%) !important;
  transition: width 1s ease;
}

/* Catalyst storage bar */
.outpost-catalyst-storage {
  margin-top: 6px;
}

.catalyst-bar {
  height: 18px !important;
  background: #2d1b4e !important;
}

.catalyst-fill {
  background: linear-gradient(90deg, #9b59b6 0%, #e056fd 100%) !important;
}

.catalyst-text {
  font-size: 0.9em !important;
  color: #6f42c1 !important;
}

/* Warning text for no garrison */
.outpost-warning-text {
  color: #dc3545 !important;
  font-weight: 600;
}

.demolished-notice {
  text-align: center;
  padding: 15px;
  color: #6c757d;
  font-style: italic;
  width: 100%;
}

/* Map outpost modal */
.outpost-map-modal {
  max-width: 420px;
  width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
}

/* Outpost card v2 — vertical layout for modals and list */
.outpost-card-v2 {
  background: var(--bg-light, #f8f9fa);
  border-radius: 8px;
  padding: 16px;
  box-sizing: border-box;
}

.opc-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.opc-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.opc-name {
  flex: 1;
  margin: 0;
  font-size: 1.1em;
  font-weight: 700;
  color: var(--primary, #2c3e50);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opc-level {
  flex-shrink: 0;
  background: var(--secondary, #6c757d);
  color: white;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.85em;
  font-weight: 600;
}

.opc-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.9em;
  margin: 10px 0;
  padding: 8px 10px;
  background: rgba(0,0,0,0.04);
  border-radius: 6px;
}

.opc-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border, #dee2e6);
}

.opc-actions .btn {
  padding: 7px 10px;
  font-size: 0.85em;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
}

/* Structure count badge in header */
.opc-structures {
  flex-shrink: 0;
  background: #495057;
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.8em;
  font-weight: 600;
}

/* Per-resource rows */
.opc-resources {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 10px 0;
}

.opc-resource-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9em;
}

.opc-res-icon {
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.opc-res-name {
  flex-shrink: 0;
  width: 70px;
  font-weight: 600;
  color: var(--primary, #2c3e50);
  font-size: 0.85em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opc-res-bar-wrap {
  flex: 1;
  min-width: 0;
}

.opc-res-bar {
  height: 14px !important;
  margin-bottom: 0 !important;
}

.opc-res-amount {
  flex-shrink: 0;
  width: 40px;
  text-align: right;
  font-weight: 700;
  color: #212529;
  font-size: 0.85em;
}

.opc-res-rate {
  flex-shrink: 0;
  width: 60px;
  text-align: right;
  font-size: 0.8em;
  color: #28a745;
  font-weight: 600;
}

.opc-catalyst-row {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed rgba(0,0,0,0.1);
}

/* Under-construction list */
.opc-building-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}

.opc-building-item {
  font-size: 0.82em;
  color: #856404;
  background: #fff3cd;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

/* Garrison section */
.opc-garrison {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.9em;
  margin: 8px 0;
  padding: 8px 10px;
  background: rgba(0,0,0,0.04);
  border-radius: 6px;
}

.opc-garrison-detail {
  color: #2c3e50;
}

.opc-auto-badge {
  color: #007bff;
  font-weight: 600;
}

.opc-actions .btn-danger {
  grid-column: 1 / -1;
}

.opc-actions .outpost-auto-supply-block {
  grid-column: 1 / -1;
  margin: 0;
}

/* Territory protection badges */
.outpost-protected-badge {
  background: rgba(52, 152, 219, 0.15);
  color: #2980b9;
  border: 1px solid rgba(52, 152, 219, 0.3);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.85em;
  font-weight: 600;
  margin-bottom: 6px;
}

.outpost-vulnerable-badge {
  background: rgba(231, 76, 60, 0.12);
  color: #c0392b;
  border: 1px solid rgba(231, 76, 60, 0.25);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.85em;
  font-weight: 600;
  margin-bottom: 6px;
}

.outpost-damaged-badge {
  background: rgba(192, 57, 43, 0.15);
  color: #e74c3c;
  border: 1px solid rgba(192, 57, 43, 0.3);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.85em;
  font-weight: 600;
  margin-bottom: 6px;
}

.outpost-foreman-line {
  background: rgba(74, 222, 128, 0.12);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.25);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.85em;
  font-weight: 500;
  margin-bottom: 6px;
}

/* Responsive design */
@media (max-width: 768px) {
  .outpost-tab-container {
    padding: 10px;
  }
  
  .outpost-card {
    padding: 15px;
  }
  
  .outpost-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .outpost-details {
    grid-template-columns: 1fr;
  }
  
  .outpost-actions {
    flex-direction: column;
  }
  
  .outpost-actions .btn {
    width: 100%;
  }

  /* Bottom sheet style on mobile — sits at the bottom, leaves map visible above */
  .outpost-map-modal {
    max-width: 100vw;
    width: 100vw;
    max-height: 55vh;
    margin: 0;
    border-radius: 16px 16px 0 0;
    padding: 16px 14px;
    position: fixed;
    bottom: 0;
    left: 0;
    animation: slideUpSheet 0.25s ease-out;
  }

  /* Re-align overlay for bottom sheet */
  .outpost-modal-overlay {
    align-items: flex-end;
    justify-content: center;
  }

  @keyframes slideUpSheet {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .outpost-map-modal .opc-actions {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
  }

  .opc-actions .btn {
    padding: 8px 6px;
    font-size: 0.82em;
  }

  .opc-res-name {
    width: 55px;
    font-size: 0.78em;
  }

  .opc-res-rate {
    width: 50px;
    font-size: 0.75em;
  }
}

/* Map Outpost Styles */
.outpost-marker {
  cursor: pointer;
}

.outpost-marker:hover {
  filter: brightness(1.3) drop-shadow(0 0 2px rgba(255,255,255,0.6));
}

.outpost-background {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.yield-heatmap-cell {
  opacity: 0.6;
  transition: opacity 0.3s;
}

.outpost-placement-preview {
  pointer-events: none;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

/* Modal styles for outpost actions */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-content h3 {
  margin-top: 0;
  color: #1f2937;
  font-size: 1.5em;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 10px;
}

.outpost-details p {
  margin: 8px 0;
  color: #4b5563;
}

.outpost-details strong {
  color: #1f2937;
  display: inline-block;
  min-width: 120px;
}

.button-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.yield-preview {
  background: #f9fafb;
  padding: 15px;
  border-radius: 6px;
  border-left: 4px solid #3b82f6;
}

.construction-cost {
  background: #fef3c7;
  padding: 15px;
  border-radius: 6px;
  border-left: 4px solid #f59e0b;
}

.construction-cost h4 {
  margin-top: 0;
  color: #92400e;
}

.construction-cost ul {
  margin: 10px 0;
  padding-left: 0;
}

.construction-cost li {
  padding: 5px 0;
  color: #78350f;
}

/* ── Structure Info Modal ── */

.struct-modal {
  max-width: 420px;
}

.struct-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.struct-modal-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.struct-modal-title {
  flex: 1;
  font-size: 1.2em;
  font-weight: 700;
  color: var(--primary, #2c3e50);
  margin: 0;
}

.struct-modal-level {
  background: var(--secondary, #3498db);
  color: white;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.85em;
  font-weight: 600;
  flex-shrink: 0;
}

/* Status badges */
.struct-status {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.88em;
  font-weight: 600;
  margin-bottom: 12px;
}

.struct-status--building {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.struct-status--repairing {
  background: rgba(212, 160, 64, 0.12);
  color: #b8860b;
  border: 1px solid rgba(212, 160, 64, 0.25);
}

.struct-status--damaged {
  background: rgba(192, 57, 43, 0.12);
  color: #c0392b;
  border: 1px solid rgba(192, 57, 43, 0.25);
}

.struct-status--upgrading {
  background: rgba(52, 152, 219, 0.12);
  color: #2980b9;
  border: 1px solid rgba(52, 152, 219, 0.25);
}

.struct-status--disabled {
  background: rgba(230, 126, 34, 0.12);
  color: #e67e22;
  border: 1px solid rgba(230, 126, 34, 0.25);
}

/* Detail rows */
.struct-modal-details {
  background: var(--bg-light, #f8f9fa);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.struct-detail-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
}

.struct-detail-section + .struct-detail-section {
  border-top: 1px solid var(--border, #dee2e6);
}

.struct-detail-label {
  font-size: 0.85em;
  color: #7f8c8d;
  font-weight: 600;
}

.struct-detail-value {
  font-size: 0.9em;
  color: var(--primary, #2c3e50);
  font-weight: 600;
}

.struct-ratio {
  background: rgba(0, 0, 0, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  margin-left: 6px;
}

/* Info cards (repair, upgrade) */
.struct-info-card {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 10px;
  border-left: 3px solid;
}

.struct-info-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.92em;
}

.struct-info-card-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85em;
  color: var(--text, #2c3e50);
}

.struct-info-card--repair {
  background: rgba(192, 57, 43, 0.06);
  border-left-color: #c0392b;
}

.struct-info-card--upgrade {
  background: rgba(52, 152, 219, 0.06);
  border-left-color: #3498db;
}

.struct-max-level {
  color: #6c757d;
  font-style: italic;
  font-size: 0.9em;
  margin-bottom: 12px;
}

/* Action buttons */
.struct-modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--border, #dee2e6);
}

.struct-modal-actions .btn {
  padding: 8px 16px;
  font-size: 0.88em;
}

/* Demolish row — separated, subtle */
.struct-modal-demolish {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border, #dee2e6);
}

.struct-modal-demolish .btn {
  padding: 6px 14px;
  font-size: 0.82em;
  flex-shrink: 0;
}

.struct-demolish-refund {
  font-size: 0.8em;
  color: #7f8c8d;
}
