/**
 * Special Labels Unified CSS (Cleaned)
 * Versione ottimizzata senza riferimenti a .show
 */

/* ========================================
   1. BASE COMPONENTS
   =======
.option-icon i {
    font-size: 20px;
}

.option-content {
    flex: 1;
    min-width: 0;
}

.option-label {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 2px;
}

.option-description {
    font-size: 12px;
    color: #6c757d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-hidden {
    display: none !important;
}

/* ========================================
   3. ICON PICKER
   ======================================== */

   .icon-picker-container {
    position: relative;
    max-width: 100%;
    overflow: visible !important;
}

.icon-picker-trigger {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
    background: white;
    transition: all 0.2s ease;
}

.icon-picker-trigger:hover {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.icon-picker-trigger i:first-child {
    margin-right: 8px;
}

.icon-picker-popup {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 9999;
    max-width: 100%;
}

#manageSpecialLabelsModal .icon-picker-popup {
    position: fixed !important;
    left: 50% !important;
    transform: translateX(-50%);
    top: 50% !important;
    margin-top: -250px;
    width: 90%;
    max-width: 600px;
    height: 500px;
    overflow: visible !important;
    display: flex;
    flex-direction: column;
    z-index: 10000;
}

.icon-picker-header {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    flex-shrink: 0;
}

.icon-picker-categories {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 8px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    flex-shrink: 0;
}

.icon-picker-categories::-webkit-scrollbar {
    height: 6px;
}

.icon-picker-categories::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.icon-picker-categories::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.category-btn {
    padding: 4px 12px;
    border: 1px solid transparent;
    background: white;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.category-btn:hover {
    border-color: #dee2e6;
}

.category-btn.active {
    background: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

.icon-picker-grid-wrapper {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden;
    min-height: 0;
    max-height: 300px;
}

.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
    gap: 4px;
    padding: 8px;
    width: 100%;
    box-sizing: border-box;
}

.icon-item,
.icon-picker-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    aspect-ratio: 1;
    position: relative;
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

.icon-item:hover,
.icon-picker-item:hover {
    background: #e9ecef;
    transform: scale(1.05);
}

.icon-item i,
.icon-picker-item i {
    font-size: 24px;
    color: #495057;
}

.icon-tooltip {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.icon-item:hover .icon-tooltip {
    opacity: 1;
}

.no-results-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem 1rem;
    color: #6c757d;
    font-size: 14px;
    font-style: italic;
}

/* ========================================
   4. COLOR PICKER
   ======================================== */

.color-picker-wrapper {
    position: relative;
    width: 60px;
    height: 38px;
}

.color-picker-wrapper input[type="color"] {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.color-picker-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 1px solid #ced4da;
    border-radius: 4px;
    pointer-events: none;
}

/* ========================================
   5. LABEL MANAGEMENT
   ======================================== */

.label-item {
    transition: all 0.2s ease;
}

.label-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.label-item.deleting {
    transform: translateX(-100%) scale(0.8);
    opacity: 0;
    filter: blur(1px);
}

.option-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    flex-shrink: 0;
}

/* ========================================
   6. SCROLLBAR PERSONALIZZATE
   ======================================== */

.icon-picker-grid-wrapper::-webkit-scrollbar,
.options-container::-webkit-scrollbar {
    width: 8px;
}

.icon-picker-grid-wrapper::-webkit-scrollbar-track,
.options-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.icon-picker-grid-wrapper::-webkit-scrollbar-thumb,
.options-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.icon-picker-grid-wrapper::-webkit-scrollbar-thumb:hover,
.options-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.icon-picker-grid-wrapper,
.options-container {
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

/* ========================================
   7. RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .special-label-dropdown {
        max-width: 100%;
    }
    
    .dropdown-menu.special-labels-menu {
        max-width: calc(100vw - 20px);
    }
    
    .icon-picker-popup {
        position: fixed;
        left: 8px;
        right: 8px;
        bottom: 8px;
    }
    
    #manageSpecialLabelsModal .icon-picker-popup {
        width: calc(100vw - 20px);
        left: 10px !important;
        transform: none;
    }
    
    .icon-picker-categories {
        flex-wrap: nowrap;
    }
    
    .icon-picker-grid {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    }
}

/* ========================================
   8. UTILITIES
   ======================================== */

.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.is-disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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