/* ===========================================
   Note Tags Styling
   =========================================== */

/* Tag Selector Component */
.tag-selector {
    position: relative;
    margin-bottom: 1rem;
}

.selected-tags {
    min-height: 40px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 8px;
}

.tag-placeholder {
    color: #999;
    font-style: italic;
}

.tag-dropdown-btn {
    width: 100%;
    padding: 10px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.tag-dropdown-btn:hover {
    background: #e9ecef;
}

.tag-dropdown-btn i {
    font-size: 1rem;
}

/* Tag Dropdown */
.tag-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
}

.tag-search {
    padding: 12px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.tag-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.tag-search input:focus {
    outline: none;
    border-color: #007bff;
}

/* Tag Categories */
.tag-categories {
    padding: 8px;
}

.tag-category {
    margin-bottom: 12px;
}

.tag-category:last-child {
    margin-bottom: 0;
}

.tag-category-header {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #666;
    padding: 8px 8px 6px;
    border-bottom: 1px solid #eee;
    margin-bottom: 6px;
}

.tag-category-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 8px;
}

/* Tag Pill (Clickable in Dropdown) */
.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 16px;
    font-size: 0.85rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    background: #f8f9fa;
    color: #495057;
}

.tag-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tag-pill.selected {
    border-color: currentColor;
    font-weight: 500;
}

/* Tag Chip (Selected Tags Display) */
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 12px;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
}

.tag-chip-remove {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0.8;
    transition: opacity 0.2s, background 0.2s;
}

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

/* Category-Specific Colors */
.tag-category-doctrine .tag-pill {
    background: #e8daef;
    color: #6c3483;
}

.tag-category-doctrine .tag-pill.selected {
    background: #8e44ad;
    color: #fff;
}

.tag-category-themes .tag-pill {
    background: #aed6f1;
    color: #1b4f72;
}

.tag-category-themes .tag-pill.selected {
    background: #3498db;
    color: #fff;
}

.tag-category-practical .tag-pill {
    background: #fad7a0;
    color: #a04000;
}

.tag-category-practical .tag-pill.selected {
    background: #e67e22;
    color: #fff;
}

.tag-category-study .tag-pill {
    background: #abebc6;
    color: #186a3b;
}

.tag-category-study .tag-pill.selected {
    background: #27ae60;
    color: #fff;
}

.tag-category-other .tag-pill {
    background: #fadbd8;
    color: #922b21;
}

.tag-category-other .tag-pill.selected {
    background: #e74c3c;
    color: #fff;
}

/* Tags on Note Cards */
.note-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.note-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.note-tag:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.note-tag i {
    font-size: 0.75rem;
}

/* Hidden State */
.tag-category[style*="display: none"] {
    display: none !important;
}

/* Tag Autocomplete Dropdown */
.tag-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1050;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

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

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: #f8f9fa;
}

.autocomplete-item.create-new {
    color: #007bff;
    font-weight: 500;
    background: #f0f8ff;
}

.autocomplete-item.create-new:hover {
    background: #e3f2ff;
}

.autocomplete-item.create-new i {
    font-size: 1rem;
}

.autocomplete-tag-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
}

.autocomplete-tag-name {
    flex: 1;
    font-weight: 500;
}

.autocomplete-tag-category {
    font-size: 0.8rem;
    color: #666;
    text-transform: capitalize;
}

.autocomplete-no-results {
    padding: 12px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* Admin Tag Management */
.manage-tag-category {
    margin-bottom: 2rem;
}

.manage-tag-category h4 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #ddd;
}

.manage-tag-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.manage-tag-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #ddd;
}

.tag-color-preview {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
}

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

.manage-tag-item .tag-slug {
    color: #666;
    font-size: 0.85rem;
    font-family: monospace;
}

.manage-tag-item .tag-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.9rem;
    border: none;
    background: #007bff;
    color: white;
    border-radius: 4px;
    cursor: pointer;
}

.btn-small:hover {
    background: #0056b3;
}

.btn-small.btn-danger {
    background: #dc3545;
}

.btn-small.btn-danger:hover {
    background: #c82333;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .tag-dropdown {
        max-height: 300px;
    }

    .tag-pill {
        font-size: 0.8rem;
        padding: 4px 8px;
    }

    .tag-chip {
        font-size: 0.8rem;
        padding: 3px 8px 3px 10px;
    }

    .note-tag {
        font-size: 0.75rem;
        padding: 2px 8px;
    }

    .tag-autocomplete-dropdown {
        max-height: 250px;
    }

    .autocomplete-item {
        padding: 8px 10px;
    }

    .manage-tag-item {
        flex-wrap: wrap;
    }

    .manage-tag-item .tag-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
