/* BSP Tag Multiselect - Odoo Many2Many Style */

.tag_multiselect_container {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 8px;
}

.tag_input_wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    border: 1.5px solid #ccc;
    border-radius: 4px;
    background: white;
    min-height: 42px;
    align-items: center;
    transition: all 0.2s ease;
    cursor: text;
}

.tag_input_wrapper:focus-within {
    border-color: #1a5f5f;
    box-shadow: 0 0 0 3px rgba(26, 95, 95, 0.1);
    outline: none;
}

.tag_input_wrapper.disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.tag_item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #e8f4f3;
    color: #1a5f5f;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid #c8e6e6;
    white-space: nowrap;
    animation: slideInTag 0.2s ease;
}

@keyframes slideInTag {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tag_item:hover {
    background: #d4eae8;
    border-color: #a8dcd9;
}

.tag_item_label {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag_remove_btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    background: none;
    border: none;
    color: #1a5f5f;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.tag_remove_btn:hover {
    background: rgba(26, 95, 95, 0.15);
    color: #0d3535;
    transform: scale(1.1);
}

.tag_search_input {
    flex: 1;
    min-width: 150px;
    border: none;
    outline: none;
    padding: 4px 0;
    font-size: 14px;
    font-family: inherit;
    background: transparent;
}

.tag_search_input::placeholder {
    color: #999;
}

/* Dropdown for suggestions */
.tag_dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    animation: slideDown 0.2s ease;
}

.tag_dropdown.active {
    display: block;
}

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

.tag_dropdown_item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #333;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.15s ease;
}

.tag_dropdown_item:last-child {
    border-bottom: none;
}

.tag_dropdown_item:hover {
    background: #f9f9f9;
}

.tag_dropdown_item.selected {
    background: #e8f4f3;
    color: #1a5f5f;
    font-weight: 500;
}

.tag_dropdown_item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #fafafa;
}

.tag_dropdown_item.disabled:hover {
    background: #fafafa;
}

.tag_dropdown_item_checkbox {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #1a5f5f;
}

.tag_dropdown_empty {
    padding: 20px 16px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* Hidden input to store selected values */
.tag_hidden_input {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .tag_item {
        font-size: 12px;
        padding: 5px 8px;
    }

    .tag_search_input {
        min-width: 100px;
        font-size: 13px;
    }

    .tag_dropdown {
        max-height: 250px;
    }

    .tag_dropdown_item {
        padding: 10px 12px;
        font-size: 12px;
    }
}

/* Focus states for accessibility */
.tag_remove_btn:focus {
    outline: 2px solid #1a5f5f;
    outline-offset: 2px;
}

.tag_dropdown_item:focus {
    outline: none;
    background: #e8f4f3;
}

/* Loading state */
.tag_multiselect_container.loading .tag_dropdown {
    pointer-events: none;
    opacity: 0.6;
}

.tag_dropdown_loading {
    padding: 20px 16px;
    text-align: center;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tag_dropdown_loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #1a5f5f;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Error state */
.tag_multiselect_container.error .tag_input_wrapper {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.tag_multiselect_error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
}

/* Success state */
.tag_multiselect_container.success .tag_input_wrapper {
    border-color: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}
