/* Join Components - Craft and Location Selectors */

/* CSS Variables for Join Components */
:root {
  --secondary-color: #3498db;
  --accent-color: #e74c3c;
  --white: #ffffff;
  --retro-gray: #E0E0E0;
  --border-color: #ddd;
  --border-radius: 4px;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --transition: all 0.3s ease;
}

/* Craft Selector Styles */
.craft-selector-container {
  position: relative;
  width: 100%;
}

.craft-filter-input {
  width: 100%;
  padding: 10px 4px;
  font-family: inherit;
  transition: var(--transition);
  color: black;
  border: 1px inset #d4d0c8;
  margin-bottom: var(--spacing-xs);
}

.craft-filter-input:focus {
  outline: none;
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.craft-list-box {
  position: absolute;
  left: 0;
  right: 0;
  background: white;
  border: 2px solid #ddd;
  border-top: none;
  max-height: 150px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
}

.craft-filter-input:focus + .craft-list-box,
.craft-list-box:hover {
  display: block;
}

.craft-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  transition: var(--transition);
  margin-left: 10px;
}

.craft-item:last-child {
  border-bottom: none;
}

.craft-item:hover {
  background: rgba(52, 152, 219, 0.1);
}

.craft-item.hidden {
  display: none;
}

.craft-add-btn {
  background-color: white;
  border: none;
  width: 24px;
  height: 24px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.craft-add-btn:hover {
  background: #2980b9;
  transform: scale(1.1);
}

.selected-crafts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  min-height: 32px;
}

.selected-craft-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  background: var(--retro-gray);
  padding: 6px 12px;
  font-weight: 500;
  transition: var(--transition);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  border: 1px solid #2c2c2c;
}

.selected-craft-tag:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.craft-tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  padding: 0;
  margin: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.craft-tag-remove:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

/* Location Selector Styles */
.location-selector-container {
  position: relative;
}

.location-filter-input {
  width: 100%;
  padding: 10px 4px;
  border: 1px inset #d4d0c8;
  font-size: 14px;
  font-family: 'MS Sans Serif', Tahoma, Arial, sans-serif;
  background: white;
  transition: all 0.3s ease;
}

.location-filter-input:focus {
  outline: none;
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.location-list-box {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 2px solid #ddd;
  border-top: none;
  max-height: 150px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
}

.location-filter-input:focus + .location-list-box,
.location-list-box:hover {
  display: block;
}

.location-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border-bottom: 1px solid #f0f0f0;
}

.location-item:last-child {
  border-bottom: none;
}

.location-item:hover {
  background-color: #f8f9fa;
}

.location-item.hidden {
  display: none;
}

.location-name {
  flex: 1;
  font-size: 14px;
  color: #333;
}

.location-add-btn {
  background: var(--secondary-color);
  color: var(--white);
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.location-add-btn:hover {
  background: #2980b9;
  transform: scale(1.1);
}

.location-tag {
  display: inline-flex;
  align-items: center;
  background: var(--retro-gray);
  padding: 6px 12px;
  font-size: 13px;
  margin: 2px;
  gap: 8px;
  border: 1px solid #2c2c2c;
}

.location-tag-remove {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.location-tag-remove:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Scrollbar styling for craft and location list boxes */
.craft-list-box::-webkit-scrollbar,
.location-list-box::-webkit-scrollbar {
  width: 6px;
}

.craft-list-box::-webkit-scrollbar-track,
.location-list-box::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

.craft-list-box::-webkit-scrollbar-thumb,
.location-list-box::-webkit-scrollbar-thumb {
  background: var(--secondary-color);
  border-radius: 3px;
}

.craft-list-box::-webkit-scrollbar-thumb:hover,
.location-list-box::-webkit-scrollbar-thumb:hover {
  background: #2980b9;
}

/* Animation for selected tags */
@keyframes tagAppear {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.selected-craft-tag {
  animation: tagAppear 0.3s ease-out;
}

/* Error and Success states for selectors */
.form-group.error .craft-filter-input,
.form-group.error .location-filter-input {
  border-color: var(--accent-color);
}

.form-group.error .craft-filter-input:focus,
.form-group.error .location-filter-input:focus {
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.form-group.success .craft-filter-input,
.form-group.success .location-filter-input {
  border-color: #27ae60;
}

.form-group.success .craft-filter-input:focus,
.form-group.success .location-filter-input:focus {
  box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.1);
}

/* Success Message Styling */
.success-message {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

/* Mobile-specific styles for join components */
.mobile-optimized {
  -webkit-tap-highlight-color: transparent;
}

.mobile-file-button {
  background: var(--secondary-color);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: var(--border-radius);
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  margin: 10px auto;
  display: block;
  min-height: 44px;
  min-width: 44px;
  transition: var(--transition);
}

.mobile-file-button:hover,
.mobile-file-button:active {
  background: #2980b9;
  transform: scale(0.98);
}

.touch-active {
  background-color: rgba(0, 0, 0, 0.1) !important;
  transform: scale(0.95);
}

/* Mobile loading overlay */
.mobile-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.mobile-loading-content {
  background: white;
  padding: 30px;
  border-radius: 10px;
  text-align: center;
  max-width: 300px;
  margin: 20px;
}

.mobile-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--secondary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

.mobile-loading-hint {
  font-size: 12px;
  color: #666;
  margin-top: 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  .file-upload-area {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  
  .craft-filter-input,
  .location-filter-input {
    -webkit-appearance: none;
    border-radius: 0;
  }
  
  .craft-filter-input:focus,
  .location-filter-input:focus {
    -webkit-appearance: none;
    outline: none;
    border: 2px solid var(--secondary-color);
  }
}

/* Mobile viewport fixes */
@media screen and (max-width: 768px) {
  .craft-list-box {
    height: 120px;
    -webkit-overflow-scrolling: touch;
  }
  

  

  
  .mobile-file-button {
    font-size: 18px;
    padding: 15px 25px;
  }
  
  

}

/* iPhone specific fixes */
@media screen and (max-width: 480px) {
  .craft-filter-input,
  .location-filter-input {
    font-size: 16px !important;
    -webkit-text-size-adjust: 100%;
  }
  
  .location-list-box {
    height: 120px;
    -webkit-overflow-scrolling: touch;
  }
  
  .location-item {
    padding: 12px;
    min-height: 44px;
  }
  
  .location-add-btn {
    min-height: 32px;
    min-width: 32px;
    font-size: 14px;
  }
  
  .mobile-file-button {
    width: 100%;
    max-width: 250px;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .craft-item:hover {
    background: transparent;
  }
  
  .craft-item:active {
    background: rgba(52, 152, 219, 0.2);
  }
  
  .craft-add-btn:hover {
    background: var(--secondary-color);
    transform: none;
  }
  
  .craft-add-btn:active {
    background: #2980b9;
    transform: scale(0.95);
  }
  
  .selected-craft-tag:hover {
    transform: none;
  }
  
  .selected-craft-tag:active {
    transform: scale(0.95);
  }
}

/* High DPI mobile displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .mobile-file-button,
  .craft-add-btn,
  .craft-tag-remove {
    border: none;
    outline: none;
  }
}

/* Skill Emblems Styles */
.emblems-selector-container {
  position: relative;
  width: 100%;
}

.emblems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 12px;
  padding: 16px;
  background: #f0f0f0;
  border: 1px inset #d4d0c8;
  border-radius: 0;
}

.emblem-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: white;
  border: 1px outset #d4d0c8;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 80px;
}

.emblem-item:hover {
  background: #f8f8f8;
  border: 1px inset #d4d0c8;
  transform: translateY(-1px);
}

.emblem-item.selected {
  background: #e0f0ff;
  border: 2px solid #0078d4;
  box-shadow: 0 0 8px rgba(0, 120, 212, 0.3);
}

.emblem-image {
  width: 32px;
  height: 32px;
  margin-bottom: 4px;
  object-fit: contain;
  filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.2));
}

.emblem-title {
  font-size: 10px;
  font-weight: bold;
  color: #000000;
  text-align: center;
  line-height: 1.2;
  max-width: 70px;
  word-wrap: break-word;
}

.selected-emblems {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  margin-top: 8px;
}

.selected-emblem-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e0f0ff;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid #0078d4;
  border-radius: 0;
}

.emblem-tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  padding: 0;
  margin: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
  color: #666666;
}

.emblem-tag-remove:hover {
  background: rgba(255, 255, 255, 0.3);
  color: #000000;
}

/* Mobile responsive for emblems */
@media (max-width: 768px) {
  .emblems-grid {
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 8px;
    padding: 12px;
  }

  .emblem-item {
    min-height: 70px;
    padding: 6px;
  }

  .emblem-image {
    width: 28px;
    height: 28px;
  }

  .emblem-title {
    font-size: 9px;
    max-width: 60px;
  }
}

@media (max-width: 480px) {
  .emblems-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 8px;
  }

  .emblem-item {
    min-height: 60px;
    padding: 4px;
  }

  .emblem-image {
    width: 24px;
    height: 24px;
  }

  .emblem-title {
    font-size: 8px;
    max-width: 50px;
  }
}
