/**
 * Progressive Tags CSS - Enhanced Hierarchical Tag System
 * Styles for the three-tier progressive smart discovery interface
 */

/* ===== PROGRESSIVE TAG INPUT CONTAINER ===== */
.progressive-tag-input {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
}

/* ===== TAG SECTIONS ===== */
.tag-section {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1rem;
    backdrop-filter: blur(10px);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.section-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
}

.section-content {
    width: 100%;
}

/* ===== BEHAVIOR DESCRIPTION ===== */
.behavior-textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    transition: border-color 0.2s ease;
}

.behavior-textarea:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 2px rgba(79, 172, 254, 0.2);
}

.behavior-textarea::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* ===== AI SUGGESTIONS SECTION ===== */
.ai-controls {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.btn-ai-generate, .btn-browse-manual {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px; /* Touch target */
}

.btn-ai-generate {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex: 1;
    min-width: 140px;
}

.btn-ai-generate:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-ai-generate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-browse-manual {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex: 1;
    min-width: 140px;
}

.btn-browse-manual:hover {
    background: rgba(255, 255, 255, 0.15);
}

.ai-suggestions-container {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-prompt-message {
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    font-size: 0.9rem;
    font-style: italic;
}

/* AI Loading State */
.ai-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top: 2px solid #4facfe;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

/* AI Suggestions Result */
.ai-suggestions-result {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ai-confidence-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: fit-content;
}

.confidence-high {
    background: rgba(34, 197, 94, 0.2);
    color: #10b981;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.confidence-medium {
    background: rgba(251, 191, 36, 0.2);
    color: #f59e0b;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.confidence-low {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.ai-reasoning {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    font-style: italic;
    line-height: 1.4;
}

.ai-suggested-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ai-actions {
    display: flex;
    justify-content: flex-end;
}

.btn-add-all-ai {
    padding: 0.5rem 1rem;
    background: rgba(79, 172, 254, 0.2);
    color: #4facfe;
    border: 1px solid rgba(79, 172, 254, 0.3);
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add-all-ai:hover {
    background: rgba(79, 172, 254, 0.3);
}

/* AI Messages */
.ai-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

.ai-message-warning {
    background: rgba(251, 191, 36, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.ai-message-error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.ai-message-info {
    background: rgba(79, 172, 254, 0.1);
    color: #4facfe;
    border: 1px solid rgba(79, 172, 254, 0.2);
}

.ai-no-results {
    text-align: center;
    padding: 1.5rem;
    color: rgba(255, 255, 255, 0.7);
}

.no-results-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.no-results-text {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.no-results-suggestion {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* ===== SELECTED TAGS SECTION ===== */
.tag-count {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    font-weight: 500;
}

.selected-tags-container {
    min-height: 60px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.1);
}

.no-tags-message {
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    font-style: italic;
    font-size: 0.9rem;
    padding: 1rem 0;
}

.selected-tag-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
}

.selected-tag-icon {
    font-size: 1rem;
}

.selected-tag-name {
    font-weight: 500;
    color: #fff;
}


.remove-tag-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    min-width: 24px;
    min-height: 24px;
}

.remove-tag-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* ===== FAVORITE TAGS SECTION ===== */
.favorite-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ===== QUICK CATEGORIES SECTION ===== */
.category-section-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.collapse-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.collapse-btn:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.05);
}

.show-more-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.show-more-btn:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
}

.quick-categories-container, .expanded-categories-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.category-card {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

.category-header {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    cursor: pointer;
    transition: background 0.2s ease;
    min-height: 44px; /* Touch target */
}

.category-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.category-icon {
    font-size: 1.2rem;
    margin-right: 0.75rem;
}

.category-info {
    flex: 1;
}

.category-name {
    font-weight: 500;
    color: #fff;
    margin-bottom: 0.25rem;
}

.category-count {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

.category-expand-btn {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    padding: 0.25rem;
}

.category-tags {
    padding: 0 0.75rem 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ===== MANUAL SEARCH SECTION ===== */
.search-input-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 2px rgba(79, 172, 254, 0.2);
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.search-btn {
    padding: 0.75rem 1rem;
    background: rgba(79, 172, 254, 0.2);
    color: #4facfe;
    border: 1px solid rgba(79, 172, 254, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 44px;
}

.search-btn:hover {
    background: rgba(79, 172, 254, 0.3);
}

.search-results {
    max-height: 300px;
    overflow-y: auto;
}

.search-results-summary {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.direct-matches h4, .category-matches h4 {
    color: #fff;
    font-size: 0.9rem;
    margin: 0 0 0.5rem 0;
    font-weight: 600;
}

.direct-matches-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.category-matches {
    margin-top: 1rem;
}

.category-match {
    margin-bottom: 0.75rem;
}

.category-match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.match-count {
    font-size: 0.8rem;
    opacity: 0.8;
}

.category-match-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.search-no-results {
    text-align: center;
    padding: 1.5rem;
    color: rgba(255, 255, 255, 0.7);
}

.search-error {
    color: #ef4444;
    text-align: center;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px;
}

/* ===== TAG PILLS ===== */
.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid;
    border-radius: 20px;
    color: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    user-select: none;
    min-height: 36px; /* Touch target */
}

.tag-pill:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.1);
}

.tag-pill.selected {
    background: rgba(79, 172, 254, 0.2);
    border-color: #4facfe !important;
    color: #4facfe !important;
    box-shadow: 0 0 0 2px rgba(79, 172, 254, 0.3);
}

.tag-pill:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Specific tag pill types */
.favorite-tag {
    border-style: dashed;
}

.ai-suggested-tag {
    position: relative;
}

.ai-suggested-tag::before {
    content: "✨";
    font-size: 0.7rem;
    position: absolute;
    top: -2px;
    right: -2px;
    background: rgba(138, 43, 226, 0.8);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-result-tag .tag-category-name {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-left: 0.25rem;
}

/* ===== TAG LIMIT MESSAGE ===== */
.tag-limit-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    z-index: 10000;
    backdrop-filter: blur(10px);
    animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    10%, 90% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ===== MOBILE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
    .progressive-tag-input {
        gap: 1rem;
    }
    
    .tag-section {
        padding: 0.75rem;
    }
    
    .ai-controls {
        flex-direction: column;
    }
    
    .btn-ai-generate, .btn-browse-manual {
        min-width: unset;
        width: 100%;
    }
    
    .category-header {
        padding: 0.5rem 0.75rem;
    }
    
    .tag-pill {
        min-height: 44px; /* Larger touch targets on mobile */
        padding: 0.6rem 0.9rem;
    }
    
    .search-input-container {
        flex-direction: column;
    }
    
    .search-btn {
        width: 100%;
    }
    
    .selected-tag-item {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .remove-tag-btn {
        margin-left: 0;
        min-width: 44px;
        min-height: 44px;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    .tag-pill,
    .btn-ai-generate,
    .btn-browse-manual,
    .category-header,
    .search-btn {
        transition: none;
    }
    
    .tag-pill:hover:not(:disabled) {
        transform: none;
    }
}

/* Focus styles for keyboard navigation */
.tag-pill:focus,
.btn-ai-generate:focus,
.btn-browse-manual:focus,
.search-btn:focus,
.remove-tag-btn:focus {
    outline: 2px solid #4facfe;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .tag-section {
        border-color: rgba(255, 255, 255, 0.3);
    }
    
    .tag-pill {
        border-width: 2px;
    }
    
    .search-input,
    .behavior-textarea {
        border-color: rgba(255, 255, 255, 0.4);
    }
}