/* ── Crafting Tab Styles ── */

.crafting-container {
  padding: 0.5rem;
}

/* Sub-tab navigation */
.crafting-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--border, #bdc3c7);
  padding-bottom: 0.25rem;
}

.crafting-tab {
  padding: 0.4rem 0.8rem;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  background: var(--bg-light, #ecf0f1);
  color: #7f8c8d;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.crafting-tab:hover {
  background: #dfe6e9;
  color: var(--primary, #2c3e50);
}

.crafting-tab.active {
  background: white;
  color: var(--primary, #2c3e50);
  border-color: var(--border, #bdc3c7);
  font-weight: 600;
}

.crafting-panel {
  display: none;
}

.crafting-panel.active {
  display: block;
}

/* Building status bar */
.building-status-bar {
  margin-bottom: 0.75rem;
}

.building-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-light, #ecf0f1);
  border-radius: 4px;
  font-size: 0.9rem;
  color: var(--primary, #2c3e50);
}

.queue-slots {
  margin-left: auto;
  color: #7f8c8d;
  font-size: 0.8rem;
}

/* Recipe Grid */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

/* Tier group headers */
.recipe-tier-header {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #7f8c8d;
  padding: 0.4rem 0.2rem 0.2rem;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--border, #bdc3c7);
}

.recipe-tier-header:first-child {
  margin-top: 0;
}

/* Penalty text in effect descriptions */
.effect-penalty {
  color: var(--danger, #e74c3c);
  font-weight: 600;
}

.recipe-card {
  background: white;
  border: 1px solid var(--border, #bdc3c7);
  border-radius: 6px;
  padding: 0.75rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.recipe-card:hover {
  border-color: var(--secondary, #3498db);
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
}

.recipe-card.recipe-locked {
  opacity: 0.6;
  border-color: var(--border, #bdc3c7);
}

.recipe-locked-hint {
  font-size: 0.8rem;
  color: var(--danger, #c0392b);
  margin-bottom: 0.3rem;
}

.recipe-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.recipe-icon {
  font-size: 1.1rem;
}

.recipe-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--primary, #2c3e50);
}

.recipe-owned {
  margin-left: auto;
  color: #7f8c8d;
  font-size: 0.75rem;
}

.recipe-effect {
  font-size: 0.75rem;
  color: var(--secondary, #3498db);
  margin-bottom: 0.3rem;
  font-style: italic;
}

.recipe-cost {
  font-size: 0.75rem;
  color: #555;
  margin-bottom: 0.2rem;
}

.cost-ok {
  color: var(--success, #27ae60);
}

.cost-short {
  color: var(--danger, #e74c3c);
}

.recipe-time {
  font-size: 0.75rem;
  color: #7f8c8d;
  margin-bottom: 0.4rem;
}

.recipe-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.craft-count {
  background: #f7fafc;
  border: 1px solid var(--border, #bdc3c7);
  color: var(--primary, #2c3e50);
  border-radius: 3px;
  padding: 0.2rem;
  text-align: center;
}

/* Buttons */
.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-small:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--secondary, #3498db);
  color: #fff;
}

.btn-accent {
  background: var(--warning, #f39c12);
  color: #fff;
}

.btn-danger {
  background: var(--danger, #e74c3c);
  color: #fff;
}

/* Crafting Queue */
.crafting-queue {
  margin-bottom: 1rem;
}

.queue-entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: white;
  border: 1px solid var(--border, #bdc3c7);
  border-radius: 4px;
  margin-bottom: 0.4rem;
}

.queue-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--primary, #2c3e50);
}

.queue-time {
  color: #7f8c8d;
  font-size: 0.75rem;
}

.queue-progress {
  width: 80px;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--secondary, #3498db);
  border-radius: 3px;
  transition: width 0.5s linear;
}

/* Tool Buffs Banner */
.tool-buffs-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem;
  margin-bottom: 0.75rem;
  background: #fff8e1;
  border: 1px solid var(--warning, #f39c12);
  border-radius: 4px;
}

.buff-tag {
  padding: 0.2rem 0.5rem;
  background: rgba(243, 156, 18, 0.15);
  border-radius: 12px;
  font-size: 0.75rem;
  color: #e67e22;
  font-weight: 600;
}

/* Equipment Panel */
.equipment-summary {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
}

.unit-equipment-card {
  background: white;
  border: 1px solid var(--border, #bdc3c7);
  border-radius: 6px;
  padding: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.unit-equip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.unit-equipment-card h4 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--primary, #2c3e50);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.unit-count-badge {
  background: var(--primary, #2c3e50);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  line-height: 1.2;
}

.btn-equip-all {
  margin-left: auto;
  background: var(--accent, #27ae60);
  color: white;
  border: none;
  font-weight: 600;
}
.btn-equip-all:hover {
  background: #219a52;
}

.bonus-tags {
  display: flex;
  gap: 0.3rem;
}

.bonus-tag {
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 600;
}

.bonus-tag.attack {
  background: rgba(231, 76, 60, 0.12);
  color: #c0392b;
}

.bonus-tag.defense {
  background: rgba(39, 174, 96, 0.12);
  color: #229954;
}

.bonus-tag.speed {
  background: rgba(41, 128, 185, 0.12);
  color: #2471a3;
}

/* Gear Inventory Banner */
.gear-inventory-banner {
  background: #fef9e7;
  border: 1px solid #f9e79f;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
}

.gear-inv-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #7d6608;
  margin-bottom: 0.35rem;
}

.gear-inv-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.gear-inv-item {
  background: white;
  border: 1px solid #f0e68c;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  color: var(--primary, #2c3e50);
  white-space: nowrap;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
}

.slot-card {
  background: #f7fafc;
  border: 1px solid var(--border, #bdc3c7);
  border-radius: 6px;
  padding: 0.5rem;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  overflow: hidden;
}

.slot-card.equipped {
  border-color: var(--secondary, #3498db);
  background: #ebf5fb;
}

.slot-header-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.slot-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.slot-name {
  font-weight: 600;
  text-transform: capitalize;
  font-size: 0.7rem;
  color: #7f8c8d;
}

.slot-item-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary, #2c3e50);
  line-height: 1.2;
}

.slot-coverage {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.slot-coverage-bar {
  flex: 1;
  height: 5px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.slot-coverage-fill {
  height: 100%;
  background: var(--secondary, #3498db);
  border-radius: 3px;
  transition: width 0.3s;
}

.slot-coverage-text {
  font-size: 0.65rem;
  font-weight: 600;
  color: #7f8c8d;
  white-space: nowrap;
}

.slot-empty-label {
  font-size: 0.7rem;
  color: #b0b8c0;
  font-style: italic;
  text-align: center;
  padding: 0.3rem 0;
}

.equip-action {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: nowrap;
}

.equip-action-assign {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 0.3rem;
}

.equip-count-input {
  width: 38px;
  background: white;
  border: 1px solid var(--border, #bdc3c7);
  color: var(--primary, #2c3e50);
  border-radius: 4px;
  padding: 0.15rem 0.2rem;
  text-align: center;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.equip-item-name {
  font-size: 0.65rem;
  color: #7f8c8d;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Icon buttons for equip/unequip */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--border, #bdc3c7);
  background: white;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 700;
  color: #7f8c8d;
  flex-shrink: 0;
  transition: all 0.15s;
  padding: 0;
  line-height: 1;
}

.btn-icon:hover {
  background: #f0f0f0;
}

.btn-icon:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-unequip-gear.btn-icon {
  color: #c0392b;
  border-color: rgba(192, 57, 43, 0.3);
}

.btn-unequip-gear.btn-icon:hover {
  background: rgba(231, 76, 60, 0.1);
}

.btn-icon-equip {
  color: white;
  background: var(--secondary, #3498db);
  border-color: var(--secondary, #3498db);
  font-size: 0.85rem;
}

.btn-icon-equip:hover {
  background: #2980b9;
  border-color: #2980b9;
}

.muted {
  color: #7f8c8d;
  font-size: 0.85rem;
  font-style: italic;
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
  .crafting-container {
    padding: 0.25rem;
  }

  .crafting-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    gap: 0;
    scrollbar-width: none;
  }

  .crafting-tabs::-webkit-scrollbar {
    display: none;
  }

  .crafting-tab {
    flex-shrink: 0;
    padding: 0.5rem 0.7rem;
    min-height: 44px;
    font-size: 0.8rem;
  }

  .recipe-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .recipe-card {
    padding: 0.6rem;
  }

  .recipe-actions {
    flex-wrap: wrap;
  }

  .recipe-actions .btn-small {
    min-height: 44px;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }

  .craft-count {
    min-height: 44px;
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
  }

  /* Equipment panel: single column on mobile */
  .slot-grid {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .slot-card {
    padding: 0.4rem;
  }

  .equip-action {
    flex-wrap: wrap;
  }

  .equip-action .btn-icon {
    min-height: 32px;
    min-width: 32px;
  }

  .equip-count-input {
    width: 48px;
    min-height: 32px;
    font-size: 0.8rem;
  }

  .equip-item-name {
    flex-basis: 100%;
    font-size: 0.75rem;
  }

  .unit-equip-header {
    flex-wrap: wrap;
  }

  .unit-equip-header h4 {
    flex-basis: 100%;
  }

  .btn-equip-all {
    min-height: 44px;
    padding: 0.4rem 0.8rem;
  }

  .gear-inventory-banner {
    overflow: hidden;
  }

  .gear-inv-items {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 0.2rem;
  }

  .unit-equipment-card {
    padding: 0.6rem;
    overflow: hidden;
  }

  .bonus-tags {
    flex-wrap: wrap;
  }

  .queue-entry {
    gap: 0.3rem;
    padding: 0.4rem;
  }

  .queue-progress {
    width: 60px;
  }

  .tool-buffs-banner {
    padding: 0.4rem;
    gap: 0.3rem;
  }
}

/* ── Auto-Craft (Automation) ────────────────── */

.auto-craft-rules {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.auto-craft-rule {
  background: var(--bg-light, #ecf0f1);
  padding: 0.75rem;
  border-radius: 6px;
  border-left: 3px solid var(--accent, #8e44ad);
}

.auto-craft-rule-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}

.auto-craft-rule-row label {
  font-weight: 600;
  white-space: nowrap;
}

.auto-craft-select {
  padding: 0.3rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border, #bdc3c7);
  font-size: 0.85rem;
  max-width: 200px;
}

.auto-craft-input {
  width: 70px;
  padding: 0.3rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border, #bdc3c7);
  font-size: 0.85rem;
}

.auto-craft-rule-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
}

.auto-craft-toggle {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.auto-craft-add {
  margin-top: 0.5rem;
}
