/* ====================================================================
   IO INPUT KW - Keyword/Tag Input Styling
   Inherits base io-input structure, adds chip-specific styles
   ==================================================================== */

/* Chips Container - Sits inside io-input-wrapper */
.io-input-kw-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--io-space-xs);
    flex: 0 0 auto;
}

/* Chip - Animated keyword tag */
.io-input-kw-chip {
    display: flex;
    align-items: center;
    gap: var(--io-space-xs);
    padding: 2px 10px;
    background: var(--io-accent-subtle);
    border: none;
    border-radius: var(--io-radius-sm);
    font-size: var(--io-text-sm);
    color: var(--io-text-primary);
    font-family: var(--io-font-primary);
    transition: all var(--io-transition-bounce);
    animation: io-chip-enter var(--io-transition-bounce);
    cursor: default;
    
    /* Crisp border simulation */
    box-shadow: inset 0 0 0 1px var(--io-accent);
    
    /* GPU acceleration */
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    will-change: transform, box-shadow;
}

.io-input-kw-chip:hover {
    background: var(--io-accent-glow);
    box-shadow: 
        inset 0 0 0 1px var(--io-accent-bright),
        0 0 8px var(--io-accent-glow);
    transform: translate3d(0, -1px, 0) scale(1.02);
}

.io-input-kw-chip-text {
    user-select: none;
    font-weight: 500;
}

/* Remove Button */
.io-input-kw-chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--io-text-secondary);
    cursor: pointer;
    transition: all var(--io-transition-bounce);
    border-radius: var(--io-radius-sm);
    opacity: 0.6;
}

.io-input-kw-chip:hover .io-input-kw-chip-remove {
    opacity: 1;
}

.io-input-kw-chip-remove:hover {
    color: var(--io-error);
    background: var(--io-error-subtle);
    transform: rotate(90deg) scale(1.1);
}

.io-input-kw-chip-remove:active {
    transform: rotate(90deg) scale(0.9);
}

.io-input-kw-chip-remove i {
    font-size: 10px;
    pointer-events: none;
}

/* Input Field - Override flex behavior for chip input */
.io-input-kw .io-input-field {
    flex: 1 1 auto;
    min-width: 120px;
}

/* ====================================================================
   VARIANT OVERRIDES
   ==================================================================== */

/* Neon Variant - Chip styling */
.io-input-neon.io-input-kw .io-input-kw-chip {
    background: var(--io-accent);
    color: var(--io-on-accent);
    box-shadow: 
        inset 0 0 0 1px var(--io-accent-bright),
        var(--io-glow-sm);
}

.io-input-neon.io-input-kw .io-input-kw-chip:hover {
    box-shadow: 
        inset 0 0 0 1px var(--io-accent-bright),
        var(--io-glow-md);
}

.io-input-neon.io-input-kw .io-input-kw-chip-remove {
    color: var(--io-on-accent);
    opacity: 0.7;
}

.io-input-neon.io-input-kw .io-input-kw-chip:hover .io-input-kw-chip-remove {
    opacity: 1;
}

.io-input-neon.io-input-kw .io-input-kw-chip-remove:hover {
    color: var(--io-on-accent);
    background: var(--io-overlay-dark);
    transform: rotate(90deg) scale(1.1);
}

/* ====================================================================
   ANIMATIONS
   ==================================================================== */

/* Chip entry animation */
@keyframes io-chip-enter {
    0% {
        opacity: 0;
        transform: translate3d(0, 10px, 0) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

/* Chip removal animation */
.io-input-kw-chip.io-removing {
    animation: io-chip-remove var(--io-transition-base) forwards;
}

@keyframes io-chip-remove {
    0% {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate3d(0, -10px, 0) scale(0.8);
    }
}

/* Focus pulse animation for wrapper */
.io-input-kw.io-input-focused .io-input-wrapper {
    animation: io-input-focus-pulse 0.3s ease-out;
}

@keyframes io-input-focus-pulse {
    0% {
        transform: translate3d(0, 0, 0) scale(1);
    }
    50% {
        transform: translate3d(0, 0, 0) scale(1.01);
    }
    100% {
        transform: translate3d(0, 0, 0) scale(1);
    }
}

/* Icon scale on focus */
.io-input-kw.io-input-focused .io-input-icon {
    transform: scale(1.1);
}

/* ====================================================================
   RESPONSIVE
   ==================================================================== */

@media (max-width: 600px) {
    .io-input-kw-chip {
        font-size: var(--io-text-xs);
        padding: 3px 8px;
    }
}

/* ====================================================================
   ACCESSIBILITY
   ==================================================================== */

.io-input-kw-chip:focus-within {
    outline: 2px solid var(--io-accent);
    outline-offset: 2px;
}

.io-input-kw-chip-remove:focus {
    outline: 2px solid var(--io-error);
    outline-offset: 1px;
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .io-input-kw-chip,
    .io-input-kw-chip-remove {
        animation: none;
        transition: none;
    }
}

.io-input-kw-chip:hover {
    background: var(--io-accent-glow);
    box-shadow: 
        inset 0 0 0 1px var(--io-accent-bright),
        0 0 8px var(--io-accent-glow);
    transform: translate3d(0, -1px, 0); /* ← REMOVED scale(1.02) */
}

.io-input-neon.io-input-kw .io-input-kw-chip:hover {
    box-shadow: 
        inset 0 0 0 1px var(--io-accent-bright),
        var(--io-glow-md);
    transform: translate3d(0, -1px, 0); /* ← Add this if not present */
}

.io-input-kw .io-input-wrapper {
    flex-wrap: wrap; /* Allow items to wrap to new lines */
    min-height: 42px; /* Or whatever your standard input height is */
    height: auto; /* Override any fixed height from base io-input */
    align-items: center; /* Keep items vertically centered */
}

/* Ensure chips container can wrap */
.io-input-kw-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--io-space-xs);
    flex: 0 0 auto;
    max-width: 100%; /* Prevent overflow */
}

/* Make sure the input field stays on the same line or wraps gracefully */
.io-input-kw .io-input-field {
    flex: 1 1 120px; /* Grow, shrink, basis 120px */
    min-width: 120px;
}