/**
 * Tag System - Centralized CSS
 *
 * Consistent styling for tags/badges across the entire SigmaBlox platform.
 * Used for mission areas, TRL levels, hardware/software types, and more.
 */

/* ====================
   BASE TAG STYLES
   ==================== */

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    transition: all 0.2s ease;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Tag Icon */
.tag-icon {
    font-size: 11px;
    line-height: 1;
}

.tag-label {
    font-size: 11px;
    font-weight: 600;
}

/* ====================
   TAG SIZES
   ==================== */

.tag-small {
    padding: 4px 10px;
    font-size: 11px;
}

.tag-small .tag-icon {
    font-size: 11px;
}

.tag-small .tag-label {
    font-size: 11px;
}

.tag-large {
    padding: 8px 16px;
    font-size: 14px;
}

.tag-large .tag-icon {
    font-size: 14px;
}

.tag-large .tag-label {
    font-size: 14px;
}

/* ====================
   TAG INTERACTIONS
   ==================== */

.tag-clickable {
    cursor: pointer;
    user-select: none;
}

.tag-clickable:hover {
    opacity: 0.85;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

/* Tag with close/remove button */
.tag-removable {
    padding-right: 8px;
}

.tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
    padding: 0;
}

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

.tag-remove svg {
    width: 10px;
    height: 10px;
}

/* ====================
   TAG GROUPS
   ==================== */

.tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.tag-group-small {
    gap: 6px;
}

.tag-group-large {
    gap: 10px;
}

/* Tag group with label */
.tag-group-labeled {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tag-group-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ====================
   TAG LIST (Vertical)
   ==================== */

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

.tag-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ====================
   TAG FILTER (For search/filter UIs)
   ==================== */

.tag-filter {
    position: relative;
}

.tag-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--color-white, #ffffff);
    border: 2px solid var(--color-light-gray, #e5e7eb);
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-dark-gray, #374151);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tag-filter-toggle:hover {
    border-color: var(--color-mid-gray, #d1d5db);
    background: var(--color-lighter-gray, #f9fafb);
}

.tag-filter-toggle.active {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
}

.tag-filter-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 200px;
    background: var(--color-white, #ffffff);
    border: 1px solid var(--color-light-gray, #e5e7eb);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 8px;
    z-index: 1000;
    display: none;
}

.tag-filter-dropdown.active {
    display: block;
}

.tag-filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.tag-filter-option:hover {
    background: #f3f4f6;
}

.tag-filter-option.selected {
    background: #eff6ff;
    color: #1d4ed8;
}

.tag-filter-option input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

/* ====================
   TAG COUNTER
   ==================== */

.tag-counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 4px;
}

/* ====================
   RESPONSIVE
   ==================== */

@media (max-width: 768px) {
    .tag {
        font-size: 0.8125rem;
        padding: 5px 10px;
    }

    .tag-large {
        font-size: 0.875rem;
        padding: 7px 14px;
    }

    .tag-group {
        gap: 6px;
    }

    .tag-filter-dropdown {
        left: auto;
        right: 0;
    }
}

/* ====================
   UTILITY CLASSES
   ==================== */

/* Hide tags on mobile */
@media (max-width: 640px) {
    .tag-hide-mobile {
        display: none;
    }
}

/* Show only count on small screens */
@media (max-width: 640px) {
    .tag-collapse-mobile .tag-label {
        display: none;
    }

    .tag-collapse-mobile {
        padding: 6px 10px;
    }
}

/* ====================
   TAG ANIMATIONS
   ==================== */

@keyframes tagFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tag-fade-in {
    animation: tagFadeIn 0.2s ease-out;
}

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

.tag-slide-in {
    animation: tagSlideIn 0.3s ease-out;
}

/* ====================
   TAG STATES
   ==================== */

.tag-selected {
    box-shadow: 0 0 0 2px currentColor;
    opacity: 1 !important;
}

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

.tag-loading {
    position: relative;
    color: transparent;
}

.tag-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: tagSpin 0.6s linear infinite;
}

@keyframes tagSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ====================
   ACCESSIBILITY
   ==================== */

.tag:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.tag-clickable[aria-pressed="true"] {
    box-shadow: 0 0 0 2px currentColor;
}

/* Screen reader only */
.tag-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
