/* Image Tags Styles */

/* Image Detail Page Tag Styles */
.image-info-sidebar .tag-input-container {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* タグ入力フィールド - 重複を削除し、CSS変数を使用した単一定義 */
.image-info-sidebar #new-tag-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary, #3a3a3a);  /* 入力欄用の背景色 */
    border: 1px solid var(--border-default, #404040);
    border-radius: var(--radius-md, 0.375rem);
    color: var(--text-primary, #ffffff);  /* 白色のテキスト */
    font-size: var(--font-size-sm, 0.875rem);
    transition: all var(--transition-fast, 0.2s);
}

.image-info-sidebar #new-tag-input:focus {
    outline: none;
    border-color: var(--color-primary, #4a9eff);
    background: var(--bg-secondary, #2d2d2d);  /* フォーカス時は少し明るく */
    color: var(--text-primary, #ffffff);  /* フォーカス時も白色を維持 */
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.image-info-sidebar #new-tag-input::placeholder {
    color: var(--text-muted, #999999);  /* プレースホルダーは薄い色 */
}

.image-info-sidebar #add-tag-btn {
    padding: 0.5rem;
    background: #4a90e2;
    border: none;
    border-radius: 0.375rem;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-info-sidebar #add-tag-btn:hover {
    background: #357abd;
}

.image-info-sidebar .no-tags {
    color: #888;
    font-style: italic;
    font-size: 0.875rem;
}

/* Tag styling for image detail page */
.image-info-sidebar .tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.image-info-sidebar .tag:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

.image-info-sidebar .tag-remove {
    background: none;
    border: none;
    color: inherit;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    padding: 0 0.125rem;
    margin-left: 0.125rem;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.image-info-sidebar .tag-remove:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Tag color classes */
.image-info-sidebar .tag-color-1 { background-color: #3b82f6; color: white; }
.image-info-sidebar .tag-color-2 { background-color: #ef4444; color: white; }
.image-info-sidebar .tag-color-3 { background-color: #10b981; color: white; }
.image-info-sidebar .tag-color-4 { background-color: #f59e0b; color: white; }
.image-info-sidebar .tag-color-5 { background-color: #8b5cf6; color: white; }
.image-info-sidebar .tag-color-6 { background-color: #06b6d4; color: white; }
.image-info-sidebar .tag-color-7 { background-color: #ec4899; color: white; }
.image-info-sidebar .tag-color-8 { background-color: #84cc16; color: white; }

.tags-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.tags-section label {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--secondary-text);
    font-weight: 600;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tags-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 32px;
}

.tags-list:empty::before {
    content: "タグがありません";
    color: var(--muted-text);
    font-size: var(--font-size-sm);
    font-style: italic;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    background: var(--primary-accent);
    color: white;
    border-radius: 16px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    position: relative;
    user-select: none;
}

.tag-item.clickable-tag {
    cursor: pointer;
}

.tag-item.clickable-tag:hover {
    background: #3b82f6;
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.tag-item .remove-tag {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.tag-item .remove-tag .material-symbols-outlined {
    font-size: 12px;
}

.tag-input-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.tag-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary, #3a3a3a);  /* 入力欄用の背景色 */
    border: 1px solid var(--border-default, #404040);
    border-radius: var(--radius-md, 0.375rem);
    color: var(--text-primary, #ffffff) !important;  /* 白色のテキスト（強制） */
    font-size: var(--font-size-sm, 0.875rem);
    transition: all var(--transition-fast, 0.2s);
}

.tag-input:focus {
    outline: none;
    border-color: var(--color-primary, #4a9eff);
    background: var(--bg-secondary, #2d2d2d);  /* フォーカス時は少し明るく */
    color: var(--text-primary, #ffffff) !important;  /* フォーカス時も白色を維持 */
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.tag-input::placeholder {
    color: var(--text-muted, #999999);  /* プレースホルダーは薄い色 */
}

.add-tag-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--primary-accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.add-tag-btn:hover {
    background: #3b82f6;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.add-tag-btn .material-symbols-outlined {
    font-size: 20px;
}

/* AI Tagging Button */
.ai-tagging-container {
    margin-top: 0.75rem;
}

.ai-tagging-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    justify-content: center;
}

.ai-tagging-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-tagging-btn:active {
    transform: translateY(0);
}

.ai-tagging-btn:disabled {
    background: #6b7280;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ai-tagging-btn .material-symbols-outlined {
    font-size: 18px;
}

/* Predefined tag colors */
.tag-item.tag-color-blue { background: #3b82f6; }
.tag-item.tag-color-green { background: #10b981; }
.tag-item.tag-color-purple { background: #8b5cf6; }
.tag-item.tag-color-pink { background: #ec4899; }
.tag-item.tag-color-orange { background: #f97316; }
.tag-item.tag-color-teal { background: #14b8a6; }
.tag-item.tag-color-red { background: #ef4444; }
.tag-item.tag-color-gray { background: #6b7280; }

/* Tag animations */
@keyframes tagAdded {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes tagHighlight {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.15);
        box-shadow: 0 0 10px rgba(74, 144, 226, 0.5);
    }
    50% {
        transform: scale(1.1);
    }
    75% {
        transform: scale(1.05);
    }
}

/* Visual feedback for duplicate tag */
.tag-item.duplicate-highlight {
    animation: shake 0.3s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Tag input visual feedback */
.tag-input.tag-added {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.tag-input.tag-exists {
    border-color: #f97316;
    background: rgba(249, 115, 22, 0.05);
}

/* Copy button styles */
.tag-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.75rem;
    background: var(--accent-color, #4a90e2);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: var(--font-size-sm, 0.875rem);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast, 0.2s);
    margin-left: 0.5rem;
    user-select: none;
}

.tag-copy-btn:hover {
    background: #3b82f6;
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.tag-copy-btn:active {
    transform: translateY(0) scale(1);
}

.tag-copy-btn .material-symbols-outlined {
    font-size: 16px;
}

/* Copy button animation for feedback */
.tag-copy-btn.copied {
    background: #10b981;
    animation: copySuccess 0.6s ease-out;
}

@keyframes copySuccess {
    0% {
        transform: scale(1);
        background: #10b981;
    }
    50% {
        transform: scale(1.1);
        background: #059669;
    }
    100% {
        transform: scale(1);
        background: #10b981;
    }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .tag-item {
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    }
    
    .tag-input {
        background: var(--bg-tertiary, #3a3a3a);
        border-color: var(--border-default, #404040);
        color: var(--text-primary, #ffffff) !important;
    }
    
    .tag-input:focus {
        background: var(--bg-secondary, #2d2d2d);
        border-color: var(--color-primary, #4a9eff);
        color: var(--text-primary, #ffffff) !important;
    }
    
    .tag-input.tag-added {
        background: rgba(16, 185, 129, 0.1);
    }
    
    .tag-input.tag-exists {
        background: rgba(249, 115, 22, 0.1);
    }
}