/* css/modules/tag-input.css
 * Styling for the tag input component used in personality editor
 * Follows existing design patterns from mobile-ai-chat.css and reward-form.css
 */

/* Container */
.tag-input-container {
  margin-bottom: 16px;
}

/* Label */
.tag-input-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #333);
  margin-bottom: 8px;
}

/* Wrapper for pills and input */
.tag-input-wrapper {
  background: var(--input-bg, #f5f5f5);
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 12px;
  padding: 8px 12px;
  min-height: 44px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tag-input-wrapper:focus-within {
  border-color: var(--accent-color, #FF9500);
  box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.15);
}

.tag-input-wrapper--disabled {
  opacity: 0.7;
  background: var(--input-bg-disabled, #eee);
}

/* Pills container - horizontal flex with wrapping */
.tag-input-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.tag-input-pills:empty {
  display: none;
}

.tag-input-pills:empty + .tag-input-add {
  margin-top: 0;
}

/* Individual pill/tag */
.tag-input-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--accent-bg, rgba(255, 149, 0, 0.15));
  border: 1px solid var(--accent-color, #FF9500);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-color, #FF9500);
  max-width: 100%;
  animation: tagInputFadeIn 0.15s ease;
}

@keyframes tagInputFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.tag-input-pill-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Remove button on pill */
.tag-input-pill-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--accent-color, #FF9500);
  font-size: 16px;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
}

.tag-input-pill-remove:hover {
  opacity: 1;
  background: rgba(255, 149, 0, 0.2);
}

.tag-input-pill-remove:active {
  transform: scale(0.9);
}

/* Add input area */
.tag-input-add {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Text input field */
.tag-input-field {
  flex: 1;
  min-width: 120px;
  padding: 6px 0;
  background: transparent;
  border: none;
  font-size: 14px;
  color: var(--text-primary, #333);
  outline: none;
}

.tag-input-field::placeholder {
  color: var(--text-tertiary, #999);
}

/* Add button */
.tag-input-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: var(--accent-color, #FF9500);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 18px;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
}

.tag-input-add-btn:hover {
  background: var(--accent-color-hover, #E68600);
}

.tag-input-add-btn:active {
  transform: scale(0.9);
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .tag-input-label {
    color: var(--text-primary-dark, #f0f0f0);
  }

  .tag-input-wrapper {
    background: var(--input-bg-dark, #2a2a2a);
    border-color: var(--border-color-dark, #444);
  }

  .tag-input-wrapper--disabled {
    background: var(--input-bg-disabled-dark, #222);
  }

  .tag-input-field {
    color: var(--text-primary-dark, #f0f0f0);
  }

  .tag-input-field::placeholder {
    color: var(--text-tertiary-dark, #888);
  }
}

/* When inside a modal with dark theme class */
.personality-editor-modal .tag-input-wrapper {
  background: var(--modal-input-bg, #f5f5f5);
}

[data-theme="dark"] .tag-input-wrapper,
.dark-theme .tag-input-wrapper {
  background: var(--modal-input-bg-dark, #2a2a2a);
  border-color: var(--modal-border-dark, #444);
}

[data-theme="dark"] .tag-input-label,
.dark-theme .tag-input-label {
  color: var(--modal-text-dark, #f0f0f0);
}

[data-theme="dark"] .tag-input-field,
.dark-theme .tag-input-field {
  color: var(--modal-text-dark, #f0f0f0);
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .tag-input-pill {
    padding: 8px 12px;
    font-size: 14px;
  }

  .tag-input-pill-remove {
    width: 20px;
    height: 20px;
    font-size: 18px;
  }

  .tag-input-add-btn {
    width: 32px;
    height: 32px;
    font-size: 20px;
  }

  .tag-input-field {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
}

/* Hint text below the input */
.tag-input-hint {
  font-size: 12px;
  color: var(--text-tertiary, #999);
  margin-top: 6px;
}

[data-theme="dark"] .tag-input-hint,
.dark-theme .tag-input-hint {
  color: var(--text-tertiary-dark, #888);
}
