/* ==============================================
   UNIVERSAL TAGS MANAGER STYLES
   ============================================== */

/* Tag Display Styles */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px 2px 10px !important;
    font-size: 12px;
    font-weight: 400;
    border-radius: 20px;
    border: 1px solid;
    transition: all 0.2s ease;
    position: relative;
    margin: 0px;
    white-space: nowrap;
    line-height: 1.2;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tag Size Variations */
.tag-small {
    padding: 1px 6px;
    font-size: 10px;
    max-width: 100px;
}

.tag-large {
    padding: 4px 12px;
    font-size: 14px;
    font-weight: 600;
    max-width: 200px;
}

/* Tag Remove Button */
.tag-remove {
    margin-left: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 14px;
    line-height: 1;
    color: inherit;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
}

.tag:hover .tag-remove {
    opacity: 1;
}

.tag-remove:hover {
    background: rgba(0, 0, 0, 0.2);
    color: #dc2626;
}

/* Add Tag Button */
.add-tag-btn {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 500;
    color: #9ca3af;
    border: 1px dashed #d1d5db;
    border-radius: 20px;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 2px;
    line-height: 1.2;
}

.add-tag-btn:hover {
    color: #4b5563;
    border-color: #9ca3af;
    background: rgba(156, 163, 175, 0.05);
}

.add-tag-btn:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Item Tags Container */
.item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    min-height: 24px;
    align-items: center;
    margin-top: 8px;
}

/* Tag Filter Styles */
.tag-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
    padding: 8px 0;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
    border: 1px solid #e5e5e5;
    background: #f3f4f6;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.filter-tag:hover {
    background: #e5e5e5;
    transform: translateY(-1px);
}

.filter-tag.active {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
    font-weight: 600;
}

/* Tag Popup Styles */
.tag-popup {
    position: absolute;
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    padding: 16px;
    z-index: 1000;
    min-width: 280px;
    max-width: 400px;
    display: none;
    animation: popupFadeIn 0.2s ease;
}

.tag-popup.active {
    display: block;
}

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

.popup-title {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 8px;
    padding: 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popup-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
    min-height: 32px;
    align-items: flex-start;
}

.popup-tag {
    display: inline-flex;
    align-items: center;
    padding: 1px 25px 2px 9px;
    font-size: 12px;
    font-weight: 300;
    border-radius: 9px;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
}

.popup-tag:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.popup-tag-delete {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6b7280;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    line-height: 1;
    padding: 0;
    width: auto;
    height: auto;
}

.popup-tag:hover .popup-tag-delete {
    opacity: 1;
}

.popup-tag-delete:hover {
    color: #374151;
}

.popup-divider {
    height: 1px;
    background: #e5e5e5;
    margin: 12px 0;
}

.popup-input-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.popup-input {
    flex: 1;
    padding: 8px 12px;
    font-size: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.popup-input:focus {
    outline: none;
    border-color: #0366d6;
    box-shadow: none;
}

.popup-add-btn {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 500;
    background: white;
    color: #24292e;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 90px;
    height: 32px;
    line-height: 1;
    box-sizing: border-box;
}

.popup-add-btn:hover {
    background: #f6f8fa;
    border-color: #d1d5da;
}

.popup-add-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Content Tags Display in Right Panel */
.content-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.content-tag {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 20px;
    border: 1px solid;
}

/* No Tags State */
.no-tags {
    font-size: 14px;
    color: #9ca3af;
    font-style: italic;
}

/* List Item Tags (in sidebar) */
.link-tags,
.snippet-tags,
.expander-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
    min-height: 20px;
    align-items: center;
}

/* Tag Manager Dropdown/Select (for bulk operations) */
.tag-select {
    position: relative;
    display: inline-block;
}

.tag-select-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #4b5563;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tag-select-button:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.tag-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 4px;
}

.tag-select-option {
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f3f4f6;
}

.tag-select-option:hover {
    background: #f9fafb;
}

.tag-select-option:last-child {
    border-bottom: none;
}

/* Tag Management Section (for admin) */
.tag-management {
    background: #f9fafb;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 16px;
    margin: 16px 0;
}

.tag-management-header {
    display: flex;
    justify-content: between;
    align-items: center;
    margin-bottom: 12px;
}

.tag-management-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font-size: 12px;
}

.tag-item-name {
    font-weight: 500;
}

.tag-item-count {
    color: #6b7280;
    font-size: 11px;
}

.tag-item-delete {
    color: #dc2626;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.tag-item-delete:hover {
    background: #fee2e2;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .tag-popup {
        min-width: 250px;
        max-width: 90vw;
        left: 50% !important;
        transform: translateX(-50%);
    }
    
    .tag-filter {
        gap: 4px;
    }
    
    .filter-tag {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .tag {
        max-width: 120px;
        font-size: 11px;
    }
    
    .content-tag {
        font-size: 12px;
        padding: 4px 10px;
    }
}

/* Dark Mode Support (if needed) */
@media (prefers-color-scheme: dark) {
    .tag-popup {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .popup-input {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .popup-input:focus {
        border-color: #60a5fa;
    }
    
    .filter-tag {
        background: #374151;
        border-color: #4b5563;
        color: #d1d5db;
    }
    
    .filter-tag:hover {
        background: #4b5563;
    }
    
    .filter-tag.active {
        background: #1e40af;
        border-color: #3b82f6;
        color: #dbeafe;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .tag {
        border-width: 2px;
    }
    
    .filter-tag {
        border-width: 2px;
    }
    
    .tag-popup {
        border-width: 2px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .tag,
    .filter-tag,
    .popup-tag,
    .add-tag-btn,
    .tag-popup {
        transition: none;
    }
    
    @keyframes popupFadeIn {
        from, to {
            opacity: 1;
            transform: none;
        }
    }
}
