﻿/* ============================================
   TAG AUTOCOMPLETE COMPONENT
   Professional autocomplete with smooth UX
   ============================================ */

.tag-autocomplete-container {
    position: relative;
    margin-bottom: 1rem;
}

/* Input Wrapper */
.tag-autocomplete-input-wrapper {
    position: relative;
}

    .tag-autocomplete-input-wrapper input {
        padding-right: 2.5rem;
    }

.autocomplete-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    pointer-events: none;
    font-size: 1rem;
}

.autocomplete-spinner {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
}

/* Dropdown Suggestions */
.tag-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 320px;
    overflow-y: auto;
    background: white;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    margin-top: -1px;
}

.tag-suggestion-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid #f1f3f5;
}

    .tag-suggestion-item:hover:not(.disabled) {
        background-color: #f8f9fa;
    }

    .tag-suggestion-item.disabled {
        opacity: 0.5;
        cursor: not-allowed;
        background-color: #f8f9fa;
    }

    .tag-suggestion-item:last-child {
        border-bottom: none;
    }

.tag-suggestion-icon,
.tag-suggestion-icon-placeholder {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
}

.tag-suggestion-icon-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #e9ecef;
    color: #6c757d;
    font-size: 1.25rem;
}

.tag-suggestion-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

    .tag-suggestion-content strong {
        font-size: 0.938rem;
        color: #212529;
    }

    .tag-suggestion-content small {
        font-size: 0.813rem;
        line-height: 1.3;
    }

/* Create New Tag Button */
.tag-create-new {
    background-color: #f8f9fa;
    border-top: 2px solid #dee2e6;
}

    .tag-create-new:hover {
        background-color: #e9ecef;
    }

    .tag-create-new i {
        font-size: 1.5rem;
    }

/* Selected Tags Container */
.selected-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background-color: #f8f9fa;
    border-radius: 6px;
    min-height: 50px;
}

.selected-tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

    .selected-tag-badge:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
    }

.selected-tag-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    border-radius: 4px;
}

.btn-remove-tag {
    background: none;
    border: none;
    color: white;
    padding: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.2s;
}

    .btn-remove-tag:hover {
        background-color: rgba(255, 255, 255, 0.2);
    }

    .btn-remove-tag i {
        font-size: 1rem;
    }

/* Popular Tags Section */
.popular-tags-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

.popular-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.popular-tag-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 16px;
    transition: all 0.2s;
}

    .popular-tag-btn:hover {
        background-color: #667eea;
        border-color: #667eea;
        color: white;
    }

.popular-tag-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

/* Scrollbar Styling */
.tag-autocomplete-dropdown::-webkit-scrollbar {
    width: 8px;
}

.tag-autocomplete-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.tag-autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

    .tag-autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
        background: #a0aec0;
    }

/* Responsive Design */
@media (max-width: 768px) {
    .tag-autocomplete-dropdown {
        max-height: 240px;
    }

    .selected-tags-container {
        padding: 0.5rem;
    }

    .selected-tag-badge {
        font-size: 0.813rem;
        padding: 0.375rem 0.625rem;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .tag-autocomplete-dropdown {
        background-color: #1a1a1a;
        border-color: #3a3a3a;
    }

    .tag-suggestion-item {
        border-color: #2a2a2a;
    }

        .tag-suggestion-item:hover:not(.disabled) {
            background-color: #2a2a2a;
        }

    .tag-suggestion-content strong {
        color: #e9ecef;
    }

    .selected-tags-container {
        background-color: #2a2a2a;
    }
}

/* ============================================
   DRAGGABLE TAG BADGES (Product Tag Section)
   Enhanced visual feedback for drag and drop
   ============================================ */

/* Base tag badge styling */
.badge.tag-badge {
    padding: 0.5rem 0.75rem;
    cursor: grab;
    transition: all 0.2s ease;
    user-select: none;
}

.badge.tag-badge:hover {
    background-color: #e9ecef !important;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Drag handle styling */
.drag-handle {
    color: #6c757d;
    font-size: 1.25rem;
    line-height: 1;
}

.drag-handle:hover {
    color: #495057;
}

/* Tag order badge */
.tag-order-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    background-color: #0d6efd;
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Tag name */
.tag-name {
    flex: 1;
    font-weight: 500;
}

/* Dragging state */
.tag-dragging {
    cursor: grabbing !important;
    opacity: 0.5;
    transform: scale(0.95) rotate(2deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Drop target state */
.tag-drop-target {
    border: 2px dashed #0d6efd !important;
    background-color: #e7f3ff !important;
    transform: scale(1.02);
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.1);
}

/* Dark mode support */
[data-bs-theme="dark"] .badge.tag-badge {
    background-color: #2b3035 !important;
    color: #fff;
}

[data-bs-theme="dark"] .badge.tag-badge:hover {
    background-color: #343a40 !important;
}

[data-bs-theme="dark"] .tag-drop-target {
    background-color: #1a3a52 !important;
    border-color: #4a9eff !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .badge.tag-badge {
        font-size: 0.875rem;
        padding: 0.4rem 0.6rem;
    }
    
    .drag-handle {
        font-size: 1rem;
    }
    
    .tag-order-badge {
        min-width: 20px;
        height: 20px;
        font-size: 0.688rem;
    }
}
