/* ── CodeStack Text Diff ── */

.csdiff-container {

    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.csdiff-container h3 {
    margin: 0 0 5px 0;
    font-size: 22px;
}

.csdiff-container > p {
    color: #666;
    font-size: 14px;
    margin: 0 0 20px 0;
}

.csdiff-inputs {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.csdiff-input-col {
    flex: 1;
    min-width: 300px;
}

.csdiff-input-col label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 14px;
}

.csdiff-textarea {
    width: 100%;
    height: 220px;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-family: "Courier New", monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.csdiff-textarea:focus {
    outline: none;
    border-color: #2271b1;
}

/* ── Опции ── */
.csdiff-options {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
    margin: 18px 0;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 6px;
}

.csdiff-options label {
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.csdiff-options select {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 13px;
}

/* ── Кнопки ── */
.csdiff-button {
    display: inline-block;
    padding: 10px 24px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
    margin-right: 8px;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.csdiff-button:hover {
    background: #135e96;
}

.csdiff-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.csdiff-button-secondary {
    background: #fff;
    color: #2271b1;
    border: 2px solid #2271b1;
}

.csdiff-button-secondary:hover {
    background: #f0f6fc;
}

/* ── Статистика ── */
.csdiff-stats {
    margin: 15px 0;
}

.csdiff-stats-inner {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.csdiff-stat {
    font-size: 14px;
    font-weight: 600;
}

.csdiff-stat-add { color: #28a745; }
.csdiff-stat-del { color: #dc3545; }
.csdiff-stat-mod { color: #e69500; }
.csdiff-stat-total { color: #666; }

/* ── Результат ── */
.csdiff-result {
    margin-top: 20px;
}

.csdiff-toolbar {
    display: flex;
    gap: 18px;
    padding: 10px 16px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
}

.csdiff-legend {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.csdiff-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

.csdiff-dot-add { background: #d4edda; border: 1px solid #28a745; }
.csdiff-dot-del { background: #f8d7da; border: 1px solid #dc3545; }
.csdiff-dot-mod { background: #fff3cd; border: 1px solid #e69500; }

.csdiff-output {
    border: 1px solid #e0e0e0;
    border-radius: 0 0 6px 6px;
    overflow-x: auto;
    background: #fff;
    max-height: 600px;
    overflow-y: auto;
}

.csdiff-row {
    display: flex;
    font-family: "Courier New", monospace;
    font-size: 13px;
    line-height: 1.5;
    border-bottom: 1px solid #f0f0f0;
    min-width: max-content;
}

.csdiff-row:last-child {
    border-bottom: none;
}

.csdiff-num {
    display: inline-block;
    width: 44px;
    text-align: right;
    padding: 3px 8px 3px 4px;
    color: #999;
    user-select: none;
    flex-shrink: 0;
    font-size: 12px;
}

.csdiff-num-old {
    background: #f5f5f5;
    border-right: 1px solid #eee;
}

.csdiff-num-new {
    background: #f9f9f9;
    border-right: 1px solid #eee;
}

.csdiff-sym {
    display: inline-block;
    width: 28px;
    text-align: center;
    padding: 3px 0;
    font-weight: bold;
    flex-shrink: 0;
    user-select: none;
}

.csdiff-text {
    padding: 3px 8px;
    white-space: pre-wrap;
    flex: 1;
    word-break: break-word;
    min-width: 300px;
}

/* ── Типы строк ── */
.csdiff-unchanged {
    background: #fff;
}
.csdiff-unchanged .csdiff-text { color: #444; }

.csdiff-added {
    background: #d4edda;
}
.csdiff-added .csdiff-text { color: #155724; }
.csdiff-added .csdiff-sym { color: #28a745; }

.csdiff-removed {
    background: #f8d7da;
}
.csdiff-removed .csdiff-text { color: #721c24; }
.csdiff-removed .csdiff-sym { color: #dc3545; }

.csdiff-modified {
    background: #fff3cd;
}
.csdiff-modified .csdiff-text { color: #856404; }
.csdiff-modified .csdiff-sym { color: #e69500; }

.csdiff-mod-old {
    color: #dc3545;
    text-decoration: line-through;
    opacity: 0.8;
    padding: 1px 0;
}

.csdiff-mod-new {
    color: #155724;
    font-weight: 600;
    padding: 1px 0;
}

.csdiff-mod-tag {
    font-size: 11px;
    opacity: 0.6;
    margin-right: 4px;
}

/* ── Подсветка синтаксиса ── */
.csdiff-syn-kw { color: #0066cc; font-weight: 600; }
.csdiff-syn-str { color: #28a745; }
.csdiff-syn-com { color: #999; font-style: italic; }
.csdiff-syn-var { color: #d6336c; }
.csdiff-syn-tag { color: #8b5cf6; }
.csdiff-syn-attr { color: #e69500; }
.csdiff-syn-num { color: #663399; }

/* ── Ошибка ── */
.csdiff-error {
    margin-top: 15px;
    padding: 12px 16px;
    background: #ffe6e6;
    color: #b00020;
    border-radius: 6px;
    font-size: 14px;
}

/* ── Мобильная адаптация ── */
@media (max-width: 768px) {
    .csdiff-inputs {
        flex-direction: column;
    }
    .csdiff-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .csdiff-num {
        width: 32px;
        font-size: 11px;
        padding: 3px 4px;
    }
    .csdiff-sym {
        width: 20px;
    }
    .csdiff-text {
        font-size: 12px;
    }
}
