﻿/* ===== 標籤系統樣式 ===== */

/* 自訂標籤樣式 */
.custom-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    margin: 0.25rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
    min-height: 2rem;
    line-height: 1.2;
    max-width: 100%;
    word-break: break-word;
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

    .custom-tag:hover {
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    /* 標籤移除按鈕 */
    .custom-tag .tag-remove-btn {
        margin-left: 0.5rem;
        background: rgba(255, 255, 255, 0.3);
        border: none;
        border-radius: 50%;
        width: 1.2rem;
        height: 1.2rem;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 0.75rem;
        color: inherit;
        transition: all 0.2s ease;
        flex-shrink: 0;
        opacity: 0.8;
    }

        .custom-tag .tag-remove-btn:hover {
            background: rgba(255, 255, 255, 0.5);
            opacity: 1;
            transform: scale(1.1);
        }

        .custom-tag .tag-remove-btn:focus {
            outline: 2px solid rgba(255, 255, 255, 0.8);
            outline-offset: 1px;
            opacity: 1;
        }

        .custom-tag .tag-remove-btn:active {
            transform: scale(0.95);
        }

/* 標籤容器樣式 */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 3rem;
    align-items: flex-start;
    padding: 0.5rem 0;
}

    .tags-container:empty::after {
        content: "尚未設定標籤";
        color: #6c757d;
        font-style: italic;
        padding: 1rem;
    }

/* 標籤載入動畫 */
.tag-loading {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

    .tag-loading::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 1rem;
        height: 1rem;
        margin: -0.5rem 0 0 -0.5rem;
        border: 2px solid transparent;
        border-top: 2px solid currentColor;
        border-radius: 50%;
        animation: tag-spin 1s linear infinite;
    }

@keyframes tag-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* 標籤淡入動畫 */
.tag-fade-in {
    animation: tagFadeIn 0.3s ease-in-out;
}

@keyframes tagFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 標籤淡出動畫 */
.tag-fade-out {
    animation: tagFadeOut 0.3s ease-in-out forwards;
}

@keyframes tagFadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* 特殊標籤類型樣式 */
.custom-tag.tag-system {
    border-style: dashed;
}

.custom-tag.tag-ai {
    position: relative;
    overflow: hidden;
}

    .custom-tag.tag-ai::before {
        content: "";
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
        animation: shimmer 2s infinite;
    }

@keyframes shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

.custom-tag.tag-urgent {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* 標籤工具提示增強 */
.custom-tag[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

/* 無障礙增強 */
.custom-tag:focus-within {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.custom-tag .tag-remove-btn[aria-label]:focus::after {
    content: attr(aria-label);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1001;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .custom-tag {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
        margin: 0.2rem;
    }

        .custom-tag .tag-remove-btn {
            width: 1.1rem;
            height: 1.1rem;
            font-size: 0.7rem;
            margin-left: 0.4rem;
        }

    .tags-container {
        gap: 0.3rem;
    }
}

@media (max-width: 576px) {
    .custom-tag {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
        margin: 0.15rem;
        min-height: 1.8rem;
    }

        .custom-tag .tag-remove-btn {
            width: 1rem;
            height: 1rem;
            font-size: 0.625rem;
            margin-left: 0.375rem;
        }

    .tags-container {
        gap: 0.25rem;
        min-height: 2.5rem;
    }
}

/* 高對比度模式支援 */
@media (prefers-contrast: high) {
    .custom-tag {
        border-width: 2px;
    }

        .custom-tag .tag-remove-btn {
            background: rgba(255, 255, 255, 0.8);
            border: 1px solid rgba(0, 0, 0, 0.3);
        }
}

/* 減少動畫模式支援 */
@media (prefers-reduced-motion: reduce) {
    .custom-tag,
    .custom-tag .tag-remove-btn {
        transition: none;
    }

        .custom-tag:hover {
            transform: none;
            box-shadow: none;
        }

    .tag-fade-in,
    .tag-fade-out {
        animation: none;
    }

    .custom-tag.tag-ai::before {
        animation: none;
    }

    .custom-tag.tag-urgent {
        animation: none;
    }
}

/* 深色模式支援 */
@media (prefers-color-scheme: dark) {
    .custom-tag .tag-remove-btn {
        background: rgba(0, 0, 0, 0.3);
    }

        .custom-tag .tag-remove-btn:hover {
            background: rgba(0, 0, 0, 0.5);
        }

    .tags-container:empty::after {
        color: #adb5bd;
    }
}

/* 標籤顏色預設方案 */
.custom-tag.tag-primary {
    background-color: #007bff;
    color: white;
    border-color: #0056b3;
}

.custom-tag.tag-secondary {
    background-color: #6c757d;
    color: white;
    border-color: #545b62;
}

.custom-tag.tag-success {
    background-color: #28a745;
    color: white;
    border-color: #1e7e34;
}

.custom-tag.tag-danger {
    background-color: #dc3545;
    color: white;
    border-color: #bd2130;
}

.custom-tag.tag-warning {
    background-color: #ffc107;
    color: #212529;
    border-color: #d39e00;
}

.custom-tag.tag-info {
    background-color: #17a2b8;
    color: white;
    border-color: #117a8b;
}

.custom-tag.tag-light {
    background-color: #f8f9fa;
    color: #212529;
    border-color: #dee2e6;
}

.custom-tag.tag-dark {
    background-color: #343a40;
    color: white;
    border-color: #1d2124;
}

/* 標籤大小變體 */
.custom-tag.tag-sm {
    font-size: 0.75rem;
    padding: 0.375rem 0.5rem;
    min-height: 1.5rem;
}

    .custom-tag.tag-sm .tag-remove-btn {
        width: 1rem;
        height: 1rem;
        font-size: 0.625rem;
        margin-left: 0.375rem;
    }

.custom-tag.tag-lg {
    font-size: 1rem;
    padding: 0.625rem 1rem;
    min-height: 2.5rem;
}

    .custom-tag.tag-lg .tag-remove-btn {
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.875rem;
        margin-left: 0.625rem;
    }
