/**
 * TagInput Component Styles
 * Estilos para el componente de entrada de tags/etiquetas
 */

/* Container principal */
.tag-input-wrapper {
    position: relative;
    width: 100%;
}

/* Contenedor de tags + input */
.tag-input-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--white);
    border: 2px solid #e5e7eb;
    border-radius: var(--radius-lg);
    transition: all 0.2s ease;
    min-height: 48px;
}

.tag-input-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.tag-input-wrapper.disabled .tag-input-container {
    background: #f3f4f6;
    border-color: #d1d5db;
    opacity: 0.6;
    cursor: not-allowed;
}

/* Lista de tags */
.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 0 0 auto;
}

/* Tag individual */
.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 12px;
    background: var(--primary);
    color: var(--white);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    animation: tagSlideIn 0.2s ease-out;
}

@keyframes tagSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.tag-item:hover {
    background: #7c3aed;
    transform: translateY(-1px);
}

.tag-text {
    line-height: 1.2;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Botón de eliminar tag */
.tag-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: var(--white);
    cursor: pointer;
    transition: all 0.2s ease;
    width: 18px;
    height: 18px;
}

.tag-remove:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.tag-remove:active {
    transform: rotate(90deg) scale(0.9);
}

.tag-remove svg {
    width: 12px;
    height: 12px;
}

/* Campo de entrada */
.tag-input-field {
    flex: 1 1 auto;
    min-width: 120px;
    padding: 6px 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: var(--secondary);
}

.tag-input-field::placeholder {
    color: var(--gray-medium);
}

.tag-input-field:disabled {
    cursor: not-allowed;
    color: #9ca3af;
}

/* Lista de sugerencias */
.tag-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--white);
    border: 2px solid #e5e7eb;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    list-style: none;
    margin: 0;
    padding: 4px;
    animation: suggestionsSlideDown 0.2s ease-out;
}

@keyframes suggestionsSlideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tag-suggestion-item {
    padding: 10px 12px;
    font-size: 14px;
    color: var(--secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.tag-suggestion-item:hover {
    background: var(--gray-light);
    color: var(--primary);
}

.tag-suggestion-item.selected {
    background: var(--primary);
    color: var(--white);
}

.tag-suggestion-item mark {
    background: transparent;
    color: var(--primary);
    font-weight: 600;
}

.tag-suggestion-item.selected mark {
    color: var(--white);
    opacity: 0.9;
}

.tag-suggestion-empty {
    padding: 12px;
    text-align: center;
    color: var(--gray-medium);
    font-size: 14px;
    font-style: italic;
}

/* Información y contador */
.tag-input-info {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 6px;
    padding: 0 4px;
}

.tag-count {
    font-size: 12px;
    color: var(--gray-medium);
    font-weight: 500;
}

.tag-count.limit-reached {
    color: var(--warning);
    font-weight: 600;
}

/* Scrollbar personalizado para sugerencias */
.tag-suggestions::-webkit-scrollbar {
    width: 6px;
}

.tag-suggestions::-webkit-scrollbar-track {
    background: transparent;
}

.tag-suggestions::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.tag-suggestions::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Responsive */
@media (max-width: 768px) {
    .tag-input-container {
        padding: 6px 10px;
        min-height: 44px;
    }

    .tag-item {
        font-size: 13px;
        padding: 3px 6px 3px 10px;
    }

    .tag-text {
        max-width: 150px;
    }

    .tag-input-field {
        min-width: 100px;
        font-size: 14px;
    }

    .tag-suggestions {
        max-height: 160px;
    }
}

/* Estados de validación */
.tag-input-wrapper.error .tag-input-container {
    border-color: var(--invalid-color, #ef4444);
}

.tag-input-wrapper.success .tag-input-container {
    border-color: var(--valid-color, #10b981);
}

.tag-input-wrapper.warning .tag-input-container {
    border-color: var(--warning-color, #f59e0b);
}

/* Variantes de color para tags */
.tag-item.variant-success {
    background: #10b981;
}

.tag-item.variant-warning {
    background: #f59e0b;
}

.tag-item.variant-info {
    background: #3b82f6;
}

.tag-item.variant-secondary {
    background: var(--secondary);
}

/* Dark mode support (opcional) */
@media (prefers-color-scheme: dark) {
    .tag-input-container {
        background: #1f2937;
        border-color: #374151;
    }

    .tag-input-field {
        color: #f9fafb;
    }

    .tag-input-field::placeholder {
        color: #6b7280;
    }

    .tag-suggestions {
        background: #1f2937;
        border-color: #374151;
    }

    .tag-suggestion-item {
        color: #f9fafb;
    }

    .tag-suggestion-item:hover {
        background: #374151;
    }
}

/* Animación de error/shake */
@keyframes tagInputShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.tag-input-wrapper.shake .tag-input-container {
    animation: tagInputShake 0.4s ease-in-out;
}

/* Focus visible para accesibilidad */
.tag-remove:focus-visible {
    outline: 2px solid var(--white);
    outline-offset: 2px;
}

.tag-input-field:focus-visible {
    outline: none;
}

/* Loading state */
.tag-input-wrapper.loading .tag-input-container::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--primary);
    border-radius: 50%;
    border-top-color: transparent;
    animation: tagInputSpin 0.6s linear infinite;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

@keyframes tagInputSpin {
    to { transform: translateY(-50%) rotate(360deg); }
}
