/**
 * PopRace.org - Tags UI Styles
 * 
 * Styling for tags sidebar and modals.
 * V21 Design System: Navy (#1e3a5f, #0f1e2e), Gold (#d4a574, #f4c430), Cream (#f5e6d3)
 * 
 * @version 1.0.0
 */

/* ==========================================================================
   Tags Sidebar
   ========================================================================== */

/* Fix: match dark theme and design system */
.collection-tags {
    background: var(--navy);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    color: var(--cream);
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
}

.tags-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gold);
}

.tags-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--cream);
    margin: 0;
}

.create-tag-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--gold), var(--bright-gold));
    color: var(--dark-navy);
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.create-tag-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212, 165, 116, 0.4);
}

.create-tag-btn:active {
    transform: translateY(0);
}

.create-tag-btn .icon {
    font-size: 18px;
    line-height: 1;
}

/* Empty State */
.tags-empty {
    text-align: center;
    padding: 32px 16px;
}

.tags-empty .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.tags-empty .empty-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--cream);
    margin-bottom: 6px;
}

.tags-empty .empty-hint {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.4;
}

/* Tags Cloud */
.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.tag-item:hover {
    transform: translateY(-1px);
}

.tag-item.active .tag-label {
    box-shadow: 0 0 0 2px var(--tag-color), 0 2px 8px rgba(0, 0, 0, 0.15);
    font-weight: 600;
}

/* Tag Label */
.tag-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    border: 2px solid;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

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

.tag-name {
    line-height: 1;
}

.tag-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: currentColor;
    color: #fff;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

/* Tag Actions */
.tag-actions {
    display: inline-flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tag-item:hover .tag-actions {
    opacity: 1;
}

.tag-edit-btn,
.tag-delete-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--navy-light);
    border: 1px solid var(--gold);
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--cream);
}

.tag-edit-btn:hover {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--dark-navy);
    transform: scale(1.15);
}

.tag-delete-btn:hover {
    background: var(--color-error);
    border-color: var(--color-error);
    color: white;
    transform: scale(1.15);
}

/* ==========================================================================
   Tag Modal
   ========================================================================== */

.tag-modal {
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
}

.tag-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Color Picker (shared with sub-collections) */
.color-picker-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.color-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 8px;
}

.color-swatch {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}

.color-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.color-swatch.active {
    border-color: #1e3a5f;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1e3a5f;
}

.color-swatch.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-weight: bold;
    font-size: 16px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.color-custom {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 8px;
}

.color-custom input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.color-custom label {
    font-size: 14px;
    color: #6c757d;
    cursor: pointer;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .collection-tags {
        padding: 12px;
    }
    
    .tags-header h3 {
        font-size: 14px;
    }
    
    .create-tag-btn {
        padding: 5px 10px;
        font-size: 13px;
    }
    
    .create-tag-btn .text {
        display: none;
    }
    
    .tags-cloud {
        gap: 6px;
    }
    
    .tag-label {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    .tag-count {
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        font-size: 10px;
    }
    
    .tag-actions {
        opacity: 1; /* Always visible on mobile */
    }
    
    .tag-edit-btn,
    .tag-delete-btn {
        width: 28px;
        height: 28px;
    }
    
    .tag-modal {
        width: 95%;
        max-width: none;
    }
    
    .color-swatches {
        grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
        gap: 6px;
    }
    
    .color-swatch {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 480px) {
    .tags-empty {
        padding: 24px 12px;
    }
    
    .tags-empty .empty-icon {
        font-size: 40px;
    }
    
    .tags-empty .empty-text {
        font-size: 14px;
    }
    
    .tags-empty .empty-hint {
        font-size: 12px;
    }
    
    .tags-cloud {
        gap: 4px;
    }
    
    .tag-label {
        padding: 4px 8px;
        font-size: 11px;
        gap: 4px;
    }
    
    .tag-count {
        min-width: 16px;
        height: 16px;
        font-size: 9px;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .tag-label {
        border-width: 3px;
    }
    
    .color-swatch {
        border-width: 4px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .tag-item,
    .tag-label,
    .tag-edit-btn,
    .tag-delete-btn,
    .create-tag-btn,
    .color-swatch {
        transition: none;
    }
}

/* Focus Visible */
.tag-label:focus-visible,
.create-tag-btn:focus-visible,
.tag-edit-btn:focus-visible,
.tag-delete-btn:focus-visible,
.color-swatch:focus-visible {
    outline: 3px solid #f4c430;
    outline-offset: 2px;
}

/* ==========================================================================
   Scrollbar Styling
   ========================================================================== */

.collection-tags::-webkit-scrollbar {
    width: 6px;
}

.collection-tags::-webkit-scrollbar-track {
    background: rgba(212, 165, 116, 0.1);
    border-radius: 3px;
}

.collection-tags::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: 3px;
}

.collection-tags::-webkit-scrollbar-thumb:hover {
    background: var(--cream);
}
