/**
 * Evidence Snippets管理画面専用スタイル
 * 
 * プロジェクトルール準拠:
 * - main-rules.md: Refactor段階で!importantを除去
 * - 適切なCSS実装への改善
 */

/* ===== レイアウト基本構造 ===== */
.snippets-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.snippets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e1e5e9;
}

.snippets-title {
    font-size: 24px;
    font-weight: 600;
    color: #24292f;
    margin: 0;
}

.collection-breadcrumb {
    font-size: 14px;
    color: #656d76;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.breadcrumb-separator {
    color: #d0d7de;
}

/* ===== フィルター・検索エリア ===== */
.snippets-filters {
    background: #f6f8fa;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-label {
    font-size: 12px;
    font-weight: 600;
    color: #24292f;
    text-transform: uppercase;
}

.filter-input {
    padding: 6px 12px;
    border: 1px solid #d0d7de;
    border-radius: 4px;
    font-size: 14px;
    color: #24292f;
    background-color: #ffffff;
    min-width: 150px;
}

.filter-input:focus {
    outline: none;
    border-color: #0969da;
    box-shadow: 0 0 0 2px rgba(9, 105, 218, 0.1);
}

.tag-filter {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tag-chip {
    background-color: #ddf4ff;
    color: #0969da;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.tag-chip:hover {
    background-color: #b6e3ff;
}

.tag-chip.active {
    background-color: #0969da;
    color: white;
}

/* ===== スニペットリスト ===== */
.snippets-list {
    background: white;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    overflow: hidden;
}

.snippet-item {
    display: flex;
    flex-direction: column;
    padding: 16px;
    border-bottom: 1px solid #d0d7de;
    transition: background-color 0.2s ease;
}

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

.snippet-item:hover {
    background-color: #f6f8fa;
}

.snippet-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.snippet-title {
    font-size: 16px;
    font-weight: 600;
    color: #24292f;
    margin: 0;
    flex: 1;
}

.snippet-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 12px;
    color: #656d76;
}

.snippet-type {
    background-color: #f1f8ff;
    color: #0969da;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 500;
}

.snippet-usage {
    display: flex;
    align-items: center;
    gap: 4px;
}

.usage-count {
    font-weight: 600;
    color: #24292f;
}

.snippet-content {
    color: #656d76;
    font-size: 14px;
    line-height: 1.5;
    margin: 8px 0;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.snippet-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 8px 0;
}

.snippet-tag {
    background-color: #f6f8fa;
    color: #656d76;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid #d0d7de;
}

.snippet-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

/* ===== ボタンスタイル ===== */
.btn-snippet {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    border: 1px solid;
}

.btn-snippet-primary {
    background-color: #0969da;
    color: white;
    border-color: #0969da;
}

.btn-snippet-primary:hover {
    background-color: #0860ca;
    border-color: #0860ca;
}

.btn-snippet-secondary {
    background-color: #f6f8fa;
    color: #24292f;
    border-color: #d0d7de;
}

.btn-snippet-secondary:hover {
    background-color: #f3f4f6;
    border-color: #d0d7de;
}

.btn-snippet-danger {
    background-color: #da3633;
    color: white;
    border-color: #da3633;
}

.btn-snippet-danger:hover {
    background-color: #c93c37;
    border-color: #c93c37;
}

.btn-snippet-success {
    background-color: #1a7f37;
    color: white;
    border-color: #1a7f37;
}

.btn-snippet-success:hover {
    background-color: #116329;
    border-color: #116329;
}

/* ===== スニペット編集フォーム ===== */
.snippet-form {
    background: white;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
}

.snippet-form-group {
    margin-bottom: 16px;
}

.snippet-form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #24292f;
    margin-bottom: 8px;
}

.snippet-form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    font-size: 14px;
    color: #24292f;
    background-color: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.snippet-form-input:focus {
    outline: none;
    border-color: #0969da;
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
}

.snippet-form-textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    font-size: 14px;
    color: #24292f;
    background-color: #ffffff;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.snippet-form-textarea:focus {
    outline: none;
    border-color: #0969da;
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
}

.snippet-form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    font-size: 14px;
    color: #24292f;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 8px center;
    background-repeat: no-repeat;
    background-size: 16px 16px;
    padding-right: 32px;
    appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.snippet-form-select:focus {
    outline: none;
    border-color: #0969da;
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
}

/* ===== タグ入力 ===== */
.tags-input-container {
    border: 1px solid #d0d7de;
    border-radius: 6px;
    padding: 8px;
    background-color: #ffffff;
    min-height: 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tags-input-container:focus-within {
    border-color: #0969da;
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
}

.tag-input-chip {
    background-color: #0969da;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tag-remove {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.tag-remove:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.tag-input-field {
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: #24292f;
    flex: 1;
    min-width: 100px;
    padding: 4px;
}

/* ===== 統計・使用状況 ===== */
.snippet-stats {
    background: #f6f8fa;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #0969da;
    display: block;
}

.stat-label {
    font-size: 12px;
    color: #656d76;
    text-transform: uppercase;
    font-weight: 600;
    margin-top: 4px;
}

/* ===== 空状態 ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #656d76;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: #24292f;
    margin-bottom: 8px;
}

.empty-state-description {
    font-size: 14px;
    color: #656d76;
    margin-bottom: 24px;
}

/* ===== ローディング状態 ===== */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #d0d7de;
    border-radius: 50%;
    border-top-color: #0969da;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    color: #656d76;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== 使用頻度インジケーター ===== */
.usage-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #656d76;
}

.usage-bar {
    width: 40px;
    height: 4px;
    background-color: #f1f3f4;
    border-radius: 2px;
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    background-color: #1a7f37;
    transition: width 0.3s ease;
}

.usage-bar-fill.high {
    background-color: #1a7f37;
}

.usage-bar-fill.medium {
    background-color: #fb8500;
}

.usage-bar-fill.low {
    background-color: #656d76;
}

/* ===== レスポンシブ対応 ===== */
@media (max-width: 768px) {
    .snippets-container {
        padding: 16px;
    }
    
    .snippets-header {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }
    
    .snippets-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .snippet-header {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }
    
    .snippet-actions {
        justify-content: flex-start;
    }
    
    .snippet-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .snippet-stats {
        grid-template-columns: 1fr;
    }
    
    .snippet-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-snippet {
        justify-content: center;
    }
}

/* ===== アクセシビリティ ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* フォーカス可能要素のアウトライン */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 2px solid #0969da;
    outline-offset: 2px;
}

/* ===== ユーティリティクラス ===== */
.hidden {
    display: none;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-2 {
    margin-top: 8px;
}

.mt-4 {
    margin-top: 16px;
}

.mb-2 {
    margin-bottom: 8px;
}

.mb-4 {
    margin-bottom: 16px;
}

.p-2 {
    padding: 8px;
}

.p-4 {
    padding: 16px;
}

.flex {
    display: flex;
}

.flex-1 {
    flex: 1;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 8px;
}

.gap-4 {
    gap: 16px;
}
