/* ===================
   tagmatch.css - タグマッチングタブ専用
   =================== */

/* ===================
   タグマッチングヘッダー
   =================== */
.tagmatch-header {
    text-align: center;
    margin-bottom: 20px;
}

.tagmatch-header h2 {
    margin: 0 0 5px 0;
    font-size: var(--font-size-xl);
}

.tagmatch-description {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin: 0;
}

/* ===================
   ルール設定パネル
   =================== */
.tagmatch-rules-panel {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 15px;
    margin-bottom: 15px;
}

.tagmatch-rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 8px;
}

.tagmatch-rules-header h4 {
    margin: 0;
    font-size: var(--font-size-md);
    color: var(--text-secondary);
}

.tagmatch-rules-actions {
    display: flex;
    gap: 8px;
}

/* ===================
   ルールリスト
   =================== */
.tagmatch-rules-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 15px;
}

.tagmatch-rules-empty {
    text-align: center;
    padding: 30px 15px;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    background: var(--bg-base);
    border-radius: var(--radius-md);
    border: 2px dashed var(--border-color);
}

/* ===================
   各ルール行
   =================== */
.tagmatch-rule {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.tagmatch-rule-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    font-weight: bold;
    flex-shrink: 0;
    margin-top: 2px;
}

.tagmatch-rule-body {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    min-width: 0;
}

.tagmatch-rule-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.tagmatch-rule-field label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.tagmatch-rule-field select {
    padding: 8px 10px;
    font-size: var(--font-size-md);
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    min-width: 180px;
}

.tagmatch-rule-field select:focus {
    outline: none;
    border-color: var(--border-focus);
}

.tagmatch-rule-negate {
    justify-content: flex-end;
}

.tagmatch-rule-negate .column-checkbox-item {
    background: transparent;
    border: none;
    padding: 6px 0;
}

.tagmatch-rule-remove {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--color-danger);
    color: var(--color-danger);
    font-size: var(--font-size-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    margin-top: 2px;
    transition: all var(--transition-fast);
}

.tagmatch-rule-remove:hover {
    background: var(--color-danger);
    color: #fff;
}

/* ===================
   ルール間の区切り
   =================== */
.tagmatch-rule-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 0;
}

.tagmatch-rule-logic-label {
    font-size: var(--font-size-xs);
    font-weight: bold;
    padding: 2px 14px;
    border-radius: var(--radius-full);
    border: 1px solid;
    background: var(--bg-base);
}

/* ===================
   ロジック切り替え
   =================== */
.tagmatch-logic-section {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.tagmatch-logic-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.tagmatch-logic-toggle {
    display: flex;
    gap: 6px;
}

/* ===================
   実行ボタン
   =================== */
.tagmatch-execute-btn {
    width: 100%;
    padding: 12px;
    font-size: var(--font-size-lg);
    font-weight: bold;
}

/* ===================
   サマリー
   =================== */
.tagmatch-summary {
    margin-bottom: 15px;
}

.tagmatch-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.tagmatch-summary-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 12px 15px;
    text-align: center;
    border-left: 3px solid var(--border-color);
}

/* ===================
   結果テーブル
   =================== */
.tagmatch-result-table {
    font-size: var(--font-size-md);
}

.tagmatch-result-table th {
    font-size: var(--font-size-sm);
    vertical-align: bottom;
    line-height: 1.3;
}

.tagmatch-result-table td:nth-child(1),
.tagmatch-result-table th:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 5;
    min-width: 80px;
}

.tagmatch-result-table th:nth-child(1) {
    z-index: var(--z-sticky-header);
    background: var(--table-header-bg);
}

.tagmatch-result-table tr:nth-child(even) td:nth-child(1) {
    background: var(--table-row-even);
}

.tagmatch-result-table tr:nth-child(odd) td:nth-child(1) {
    background: var(--table-row-odd);
}

/* ===================
   値入力
   =================== */
.tagmatch-value-input-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tagmatch-value-input-wrap input[type="number"] {
    width: 100px;
    padding: 8px 10px;
    font-size: var(--font-size-md);
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.tagmatch-value-input-wrap input[type="number"]:focus {
    outline: none;
    border-color: var(--border-focus);
}

.tagmatch-value-unit {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ===================
   位置ボタン
   =================== */
.tagmatch-position-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tagmatch-position-buttons .tm-pos-btn {
    padding: 5px 12px;
    font-size: var(--font-size-sm);
    min-width: 50px;
    text-align: center;
}

/* ===================
   レスポンシブ
   =================== */
@media (max-width: 480px) {
    .tagmatch-rules-panel {
        padding: 10px;
    }

    .tagmatch-rules-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .tagmatch-rule {
        flex-direction: column;
        gap: 8px;
        padding: 10px;
    }

    .tagmatch-rule-number {
        width: 24px;
        height: 24px;
        font-size: var(--font-size-xs);
    }

    .tagmatch-rule-body {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .tagmatch-rule-field select {
        min-width: 100%;
    }

    .tagmatch-rule-remove {
        align-self: flex-end;
        margin-top: 0;
    }

    .tagmatch-logic-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .tagmatch-logic-toggle {
        width: 100%;
    }

    .tagmatch-logic-toggle .logic-btn {
        flex: 1;
    }

    .tagmatch-summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .tagmatch-value-input-wrap input[type="number"] {
        width: 80px;
    }

    .tagmatch-position-buttons {
        gap: 3px;
    }

    .tagmatch-position-buttons .tm-pos-btn {
        padding: 4px 8px;
        font-size: var(--font-size-xs);
        min-width: 44px;
        flex: 1;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .tagmatch-rule-field select {
        min-width: 150px;
    }
}
