/* public/css/textdiff.css */

.diff-app {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* オプションバー (WinMerge風) */
.options-bar {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 15px;
}

.options-title {
    font-size: 0.95rem;
    color: #1e293b;
    margin-bottom: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.options-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #334155;
    cursor: pointer;
}

.option-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* 入力エディタ領域 */
.editor-row {
    display: flex;
    gap: 20px;
}

.pane-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: bold;
    color: #475569;
}

.pane-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-sm {
    font-size: 0.75rem;
    padding: 2px 8px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    cursor: pointer;
    color: #64748b;
}
.btn-sm:hover {
    background: #e2e8f0;
}

.btn-upload {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ファイル選択の input 本体は見た目のボタン（label）で隠す */
.file-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.pane-textarea {
    width: 100%;
    height: 180px;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-family: monospace, sans-serif;
    font-size: 16px;
    resize: vertical;
    box-sizing: border-box;
    background-color: #fafafa;
}

/* 💡 「折り返して表示する」オプションは、比較結果ビューだけでなく
         左右の入力欄にも同じように効かせています（wrap属性はJS側で切り替え） */
.pane-textarea[wrap="off"] {
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}
.pane-textarea[wrap="soft"] {
    white-space: pre-wrap;
    overflow-wrap: break-word;
    overflow-x: hidden;
}

/* 比較結果ビュー */
.result-section {
    margin-top: 10px;
}

.result-title {
    font-size: 1rem;
    color: #1e293b;
    margin-bottom: 10px;
    font-weight: bold;
}

.diff-result-container {
    display: flex;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    max-height: 400px;
}

/* 💡 左右それぞれが自前のスクロール領域を持ちます。
         同期はJS側（textdiff.js）でscrollLeft/scrollTopを揃えています。 */
.diff-pane {
    flex: 1;
    min-width: 0;
    font-family: monospace, sans-serif;
    font-size: 0.85rem;
    box-sizing: border-box;
    overflow: auto;
}

.diff-pane + .diff-pane {
    border-left: 1px solid #cbd5e1;
}

.diff-row {
    display: flex;
    align-items: stretch;
    min-height: 22px;
}

.line-num {
    width: 45px;
    padding: 2px 6px;
    text-align: right;
    color: #94a3b8;
    background: #f8fafc;
    user-select: none;
    border-right: 1px solid #e2e8f0;
    flex-shrink: 0;
    position: sticky;
    left: 0;
}

.line-text {
    padding: 2px 10px;
    white-space: pre;
    word-break: normal;
    flex: 1;
}

/* 折り返しオプション（デフォルトOFF＝上のpre/nowrap相当）をONにしたとき */
.diff-result-container.wrap-on .diff-pane {
    overflow-x: hidden;
}
.diff-result-container.wrap-on .line-text {
    white-space: pre-wrap;
    word-break: break-all;
}

/* 変更行の中で、実際に文字が異なっている部分（空白差分も含む） */
.diff-char-highlight {
    background-color: #ffa940;
    color: #3d2600;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.06);
}

/* WinMerge風ハイライトカラー */
.diff-row.normal {
    background-color: #ffffff;
}
.diff-row.added {
    background-color: #e6ffed; /* 追加：薄い緑 */
}
.diff-row.added .line-text {
    background-color: #acf2bd;
}
.diff-row.removed {
    background-color: #ffeef0; /* 削除：薄い赤 */
}
.diff-row.removed .line-text {
    background-color: #fdb8c0;
}
.diff-row.modified {
    background-color: #fffbdd; /* 変更：薄い黄色 */
}
.diff-row.modified .line-text {
    background-color: #fff5b1;
}
.diff-row.empty {
    background-color: #f1f5f9;
}

/* モバイル対応 */
@media (max-width: 768px) {
    .editor-row {
        flex-direction: column;
    }
}