/**
 * Column Settings Modal - Common CSS
 * 表示項目設定モーダル用共通スタイル
 */

/* モーダル背景 */
.csm-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2100;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.csm-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* モーダル本体 */
.csm-modal {
    width: min(900px, 96vw);
    max-height: min(680px, 90vh);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: translateY(10px);
    transition: transform 0.2s ease;
}

.csm-backdrop.active .csm-modal {
    transform: translateY(0);
}

/* ヘッダー */
.csm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light, #e5e7eb);
    flex-shrink: 0;
}

.csm-header h2 {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary, #1f2937);
}

.csm-close-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-light, #e5e7eb);
    background: var(--bg-primary, #fff);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-secondary, #5f6368);
    transition: all 0.15s;
}

.csm-close-btn:hover {
    background: var(--bg-hover, #f9fafb);
    border-color: var(--text-secondary, #5f6368);
}

/* ボディ（左右2ペイン） */
.csm-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* 左ペイン：項目選択 */
.csm-pane-left {
    padding: 16px 18px;
    border-right: 1px solid var(--border-light, #e5e7eb);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* 右ペイン：表示中（並び順） */
.csm-pane-right {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* 検索ボックス */
.csm-search {
    margin-bottom: 12px;
    flex-shrink: 0;
}

.csm-search input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 6px;
    background: var(--bg-primary, #fff);
    font-size: 13px;
    color: var(--text-primary, #1f2937);
    transition: border-color 0.15s;
}

.csm-search input:focus {
    outline: none;
    border-color: var(--primary-blue, #00796b);
}

.csm-search input::placeholder {
    color: var(--text-placeholder, #d1d5db);
}

/* 項目リスト */
.csm-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* カテゴリ見出し */
.csm-category {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #5f6368);
    padding: 10px 0 6px 0;
    border-top: 1px solid var(--border-light, #e5e7eb);
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.csm-category:first-child {
    margin-top: 0;
    border-top: none;
    padding-top: 0;
}

/* 項目行 */
.csm-item {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 8px 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.1s;
    user-select: none;
}

.csm-item:hover {
    background: var(--bg-hover, #f9fafb);
}

.csm-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary-blue, #00796b);
    flex-shrink: 0;
}

.csm-item-label {
    font-size: 13px;
    color: var(--text-primary, #1f2937);
    flex: 1;
}

.csm-item-source {
    font-size: 11px;
    color: var(--text-tertiary, #9ca3af);
    flex-shrink: 0;
}

/* 右ペイン：表示中ヘッダー */
.csm-selected-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light, #e5e7eb);
    margin-bottom: 12px;
    flex-shrink: 0;
}

.csm-selected-header strong {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1f2937);
}

.csm-clear-btn {
    border: none;
    background: none;
    color: var(--primary-blue, #00796b);
    cursor: pointer;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.1s;
}

.csm-clear-btn:hover {
    background: var(--bg-hover, #f9fafb);
}

/* 表示中リスト（D&D対応） */
.csm-selected-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}

/* 表示中アイテム */
.csm-selected-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 6px;
    background: var(--bg-primary, #fff);
    cursor: grab;
    transition: box-shadow 0.15s, border-color 0.15s;
    user-select: none;
}

.csm-selected-item:hover {
    border-color: var(--primary-blue, #00796b);
}

.csm-selected-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.csm-selected-item.drag-over {
    border-color: var(--primary-blue, #00796b);
    box-shadow: 0 0 0 2px var(--primary-blue-light, #e0f2f1);
}

.csm-drag-handle {
    color: var(--text-tertiary, #9ca3af);
    font-size: 14px;
    cursor: grab;
    flex-shrink: 0;
}

.csm-selected-item-label {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary, #1f2937);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.csm-remove-btn {
    border: none;
    background: none;
    color: var(--text-tertiary, #9ca3af);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.1s, background 0.1s;
    flex-shrink: 0;
}

.csm-remove-btn:hover {
    color: var(--status-danger-text, #dc2626);
    background: var(--status-danger-bg, #fee2e2);
}

/* ヒント */
.csm-hint {
    margin-top: 10px;
    text-align: center;
    color: var(--text-tertiary, #9ca3af);
    font-size: 11px;
    flex-shrink: 0;
}

/* 警告文（セグメント用） */
.csm-warning {
    font-size: 11px;
    color: var(--status-warning-text, #b06000);
    margin-bottom: 12px;
    padding: 8px 10px;
    background: var(--status-warning-bg, #fef7e0);
    border-radius: 6px;
    flex-shrink: 0;
}

/* フッター */
.csm-footer {
    border-top: 1px solid var(--border-light, #e5e7eb);
    padding: 14px 20px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* カスタム項目設定リンク */
.csm-custom-fields-link {
    font-size: 12px;
    color: var(--text-secondary, #5f6368);
    text-decoration: none;
    transition: color 0.15s;
    margin-right: auto;
}

.csm-custom-fields-link:hover {
    color: var(--primary-blue, #00796b);
    text-decoration: underline;
}

.csm-btn {
    border-radius: 6px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.csm-btn-secondary {
    border: 1px solid var(--border-light, #e5e7eb);
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #1f2937);
}

.csm-btn-secondary:hover {
    background: var(--bg-hover, #f9fafb);
    border-color: var(--text-secondary, #5f6368);
}

.csm-btn-primary {
    border: 1px solid var(--primary-blue, #00796b);
    background: var(--primary-blue, #00796b);
    color: #fff;
}

.csm-btn-primary:hover {
    background: var(--primary-blue-hover, #00695c);
    border-color: var(--primary-blue-hover, #00695c);
}

.csm-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 空状態 */
.csm-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary, #9ca3af);
    font-size: 13px;
}

/* レスポンシブ対応 */
@media (max-width: 640px) {
    .csm-body {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    .csm-pane-left {
        border-right: none;
        border-bottom: 1px solid var(--border-light, #e5e7eb);
    }

    .csm-modal {
        max-height: 95vh;
    }
}

/* ========================================
 * カンバン表示項目設定
 * ======================================== */

/* カンバン項目非表示 */
.kanban-board.kanban-hide-company_name [data-column="company_name"],
.kanban-board.kanban-hide-assignees [data-column="assignees"],
.kanban-board.kanban-hide-amount [data-column="amount"],
.kanban-board.kanban-hide-created_at [data-column="created_at"],
.kanban-board.kanban-hide-source [data-column="source"] {
    display: none;
}

/* カスタム項目はデフォルト非表示（設定でONにすると表示） */
.kanban-card-custom-field {
    display: none;
}

/* 金額・日付が両方非表示の場合、区切り線も非表示 */
.kanban-board.kanban-hide-amount.kanban-hide-created_at .kanban-card-divider {
    display: none;
}

/* disabled項目のスタイル（カンバン非対応） */
.csm-item.csm-item-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.csm-item.csm-item-disabled input[type="checkbox"] {
    cursor: not-allowed;
}

.csm-item-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

.csm-item-badge-disabled {
    background: var(--bg-tertiary, #f3f4f6);
    color: var(--text-tertiary, #9ca3af);
}

.csm-item-badge-required {
    background: var(--status-info-bg, #e0f2fe);
    color: var(--status-info-text, #0369a1);
}
