/* Server Autocomplete Component Styles */

.server-autocomplete-dropdown {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  margin-top: 2px;
  max-height: 280px;
  overflow-y: auto;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  width: 100%;
}

.server-autocomplete-item {
  padding: 12px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
  min-height: 48px;
  display: flex;
  align-items: center;
}

.server-autocomplete-item:hover,
.server-autocomplete-item.active {
  background: #f5f5f5;
  border-left-color: #1D5F7A;
}

.server-item-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 12px;
}

.server-item-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.server-item-name strong {
  font-weight: 700;
  color: #1D5F7A;
}

.server-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #666;
  flex-shrink: 0;
}

.server-meta-sep {
  color: #ccc;
  font-weight: 300;
}

.server-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.server-tag-era {
  background: #e3f2fd;
  color: #1976d2;
}

.server-tag-hc {
  background: #ffebee;
  color: #d32f2f;
}

.server-tag-sod {
  background: #f3e5f5;
  color: #7b1fa2;
}

.server-tag-anniversary {
  background: #fff3e0;
  color: #f57c00;
}

.server-region {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 3px;
}

.server-region-eu {
  background: #e3f2fd;
  color: #1565c0;
}

.server-region-us {
  background: #ffebee;
  color: #c62828;
}

.server-region-kr,
.server-region-tw,
.server-region-cn {
  background: #f5f5f5;
  color: #666;
}

.server-autocomplete-loading,
.server-autocomplete-empty,
.server-autocomplete-error {
  padding: 20px;
  text-align: center;
  color: #666;
}

.server-autocomplete-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.server-autocomplete-loading .spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #1D5F7A;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.server-autocomplete-empty .hint {
  font-size: 12px;
  color: #999;
  margin-top: 8px;
}

.server-autocomplete-error {
  color: #d32f2f;
}

/* Server input container with region pill */
.server-input-container {
  display: flex;
  gap: 4px;
  align-items: stretch;
  flex-grow: 1;
  width: 100%;
}

.server-input-container.error .server-input {
  border: 1px solid #d32f2f;
  box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.1);
}

/* Override m-field default flex behavior for our custom container */
m-field:has(.server-input-container) {
  display: block;
}

.server-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
}

.server-input-wrapper input {
  display: block;
  font-size: 14px;
  line-height: 20px;
  border-width: 0;
  padding: 5px 30px 5px 10px;
  background-color: #fff;
  flex-grow: 1;
  width: 100%;
  box-sizing: border-box;
  min-height: 30px;
}

.server-input-wrapper input::placeholder {
  color: #666;
}

.server-input-clear {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 5px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 1;
}

.server-input-wrapper input:not(:placeholder-shown) ~ .server-input-clear {
  opacity: 1;
}

.server-input-clear:hover {
  color: #333;
}

.server-region-pill {
  min-width: 50px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #999;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  user-select: none;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.server-region-pill.filled-eu {
  background: #e3f2fd;
  color: #1565c0;
}

.server-region-pill.filled-us {
  background: #ffebee;
  color: #c62828;
}

.server-region-pill.filled-kr,
.server-region-pill.filled-tw,
.server-region-pill.filled-cn {
  background: #f5f5f5;
  color: #666;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .server-input-container {
    flex-direction: column;
    gap: 8px;
  }
  
  .server-region-pill {
    align-self: flex-end;
    min-width: 80px;
  }
  
  .server-autocomplete-item {
    padding: 10px 12px;
    min-height: 44px;
  }
  
  .server-item-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  .server-item-meta {
    font-size: 12px;
  }
}

/* Accessibility */
.server-autocomplete-item:focus {
  outline: 2px solid #1D5F7A;
  outline-offset: -2px;
}

@media (prefers-reduced-motion: reduce) {
  .server-autocomplete-item,
  .server-input-clear,
  .server-region-pill {
    transition: none;
  }
  
  .server-autocomplete-loading .spinner {
    animation: none;
  }
}
