/* TagInput Component Styles - Obsidian Style */
.tag-input-container {
    position: relative;
    margin: 12px 0;
    max-width: 100%;
    min-width: 0; /* allow flex children to shrink on small screens */
    box-sizing: border-box;
}

.tag-input-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 12px;
    background: #ffffff;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex: 1 1 auto;
    overflow-x: hidden; /* guard against horizontal scroll from inner content */
}

.tag-input-wrapper:focus-within {
    border-color: #4c8cff;
    box-shadow: 0 0 0 3px rgba(76, 140, 255, 0.1);
}

.tag-input-field {
    flex: 1;
    min-width: 120px;
    border: none;
    outline: none;
    font-size: 14px;
    padding: 4px 0;
    background: transparent;
    color: #333;
    width: 100%;
    min-width: 0; /* prevent input from forcing container wider than viewport */
}

.tag-input-field::placeholder {
    color: #999;
}

.selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 100%;
    min-width: 0; /* allow flex children to shrink on small screens */
    box-sizing: border-box;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(102, 126, 234, 0.3);
    max-width: 200px;
    overflow: hidden;
}

.tag-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

.tag-item.tag-custom-color {
    background: var(--tag-color);
}

.tag-name {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.tag-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    line-height: 1;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.tag-remove:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Suggestions Dropdown */
.tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
    margin-top: 2px;
}

.tag-suggestion-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    transition: background-color 0.15s ease;
}

.tag-suggestion-item:last-child {
    border-bottom: none;
}

.tag-suggestion-item:hover,
.tag-suggestion-item.highlighted {
    background: #f8f9fa;
}

.tag-suggestion-item.create-new {
    color: #4c8cff;
    font-weight: 500;
}

.tag-suggestion-item.create-new::before {
    content: '+ ';
    font-weight: bold;
}

.tag-suggestion-name {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.tag-suggestion-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--tag-color, #667eea);
    background: var(--tag-color, #667eea);
    flex-shrink: 0;
}

/* Help text */
.tag-input-help {
    margin-top: 4px;
    font-size: 12px;
    color: #666;
    text-align: left;
}

/* Filter buttons */
.tag-filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
}

.tag-filter-label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-right: 8px;
    align-self: center;
}

.tag-filter-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 16px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    color: #666;
    margin: 5px;
}

.tag-filter-item:hover {
    border-color: #4c8cff;
    color: #4c8cff;
    text-decoration: none;
}

.tag-filter-item.active {
    background: #4c8cff;
    border-color: #4c8cff;
    color: white;
}

.tag-filter-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tag-color, #667eea);
    flex-shrink: 0;
}

.tag-filter-count {
    background: rgba(0, 0, 0, 0.1);
    color: inherit;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    margin-left: 4px;
}

.tag-filter-item.active .tag-filter-count {
    background: rgba(255, 255, 255, 0.2);
}

.tag-filter-clear {
    background: #f5f5f5;
    color: #666;
    border: 1px solid #ddd;
}

.tag-filter-clear:hover {
    background: #eee;
    border-color: #ccc;
}

/* Feed items with tags */
.feed-item .feed-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.feed-item .tag-item {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
}

/* Responsive styles */
@media (max-width: 768px) {
    .tag-input-container {
        margin: 8px 0;
        width: 100%;
        overflow-x: hidden;
    }
    
    .tag-input-wrapper {
        padding: 6px 8px;
        min-height: 42px;
        gap: 4px;
    }
    
    .tag-input-field {
        min-width: 80px;
        font-size: 15px;
    }
    
    .tag-item {
        padding: 3px 8px;
        font-size: 13px;
        max-width: 150px;
    }
    
    .tag-suggestions {
        max-height: 180px;
        border-radius: 6px;
        margin-top: 1px;
    }
    
    .tag-suggestion-item {
        padding: 10px 12px;
    }
    
    .tag-input-help {
        font-size: 11px;
        padding: 0 4px;
    }
}

@media (max-width: 480px) {
    .tag-input-wrapper {
        padding: 4px 6px;
        min-height: 40px;
    }
    
    .tag-input-field {
        font-size: 14px;
        min-width: 60px;
    }
    
    .tag-item {
        padding: 2px 6px;
        font-size: 12px;
        max-width: 120px;
    }
    
    .tag-remove {
        width: 14px;
        height: 14px;
        font-size: 9px;
    }
    
    .tag-suggestions {
        max-height: 160px;
        font-size: 13px;
    }
    
    .tag-suggestion-item {
        padding: 8px 10px;
    }
    
    .tag-input-help {
        font-size: 10px;
    }
}

/* Anti-overflow and embedding fixes */
.input-group .tag-input-container {
    flex: 1 1 auto;
    min-width: 0;
}

@media (max-width: 768px) {
    /* If parent uses .input-group, allow wrap on small screens */
    .input-group {
        flex-wrap: wrap;
    }
    .input-group > * {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }
}

/* Animation for tag addition */
@keyframes tagAppear {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.tag-item.newly-added {
    animation: tagAppear 0.3s ease-out;
}

/* Custom scrollbar for suggestions */
.tag-suggestions::-webkit-scrollbar {
    width: 6px;
}

.tag-suggestions::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.tag-suggestions::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.tag-suggestions::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
