/* ==========================================================================
   COMPARE DIFF TOOL — Silver Cat Tools
   ========================================================================== */

.text-gradient-amber {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 50%, #d946ef 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
}

.tool-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 110px 24px 60px;
}

.tool-page-header {
    text-align: center;
    margin-bottom: 32px;
}
.tool-page-header h1 {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 800;
    margin: 16px 0 12px;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
.tool-page-header p {
    color: var(--text-secondary);
    max-width: 720px;
    margin: 0 auto;
    line-height: 1.6;
}
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 16px;
    transition: color 0.3s;
}
.back-link svg { width: 18px; height: 18px; fill: currentColor; }
.back-link:hover { color: var(--text-primary); }

/* ---------- INPUT GRID ---------- */
.compare-inputs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.tool-panel {
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.05);
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
    flex-wrap: wrap;
}
.panel-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
.panel-title svg { color: var(--primary-color); }
.dot-old, .dot-new {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.dot-old { background: #ef4444; box-shadow: 0 0 8px rgba(239, 68, 68, 0.5); }
.dot-new { background: #22c55e; box-shadow: 0 0 8px rgba(34, 197, 94, 0.5); }

.header-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.action-btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.action-btn-sm:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.08);
}
.file-upload-label { cursor: pointer; }

.editor-container {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
}
.editor-textarea {
    width: 100%;
    min-height: 240px;
    padding: 14px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.55;
    resize: vertical;
    outline: none;
}
.editor-textarea.mono {
    font-family: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
    font-size: 0.88rem;
    line-height: 1.5;
}
.editor-textarea::placeholder { color: var(--text-secondary); opacity: 0.6; }

.input-meta {
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    opacity: 0.85;
}

/* ---------- CONTROLS BAR ---------- */
.compare-controls-bar {
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 14px 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px 24px;
    margin-bottom: 24px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.05);
}
.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.control-actions { margin-left: auto; }
.control-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.segmented {
    display: inline-flex;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}
.seg-btn {
    padding: 7px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.seg-btn:hover { color: var(--text-primary); }
.seg-btn.active {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff;
    box-shadow: 0 2px 10px rgba(245, 158, 11, 0.35);
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #f59e0b;
    cursor: pointer;
}
.checkbox-label:hover { color: var(--text-primary); }

.btn-action-main.btn-compare {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-action-main.btn-compare:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.45);
}
.btn-action-main.btn-compare:active { transform: translateY(0); }

/* ---------- RESULT ---------- */
.result-panel { padding-bottom: 8px; }
.diff-nav-controls {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.diff-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}
.diff-nav-btn:hover:not(:disabled) {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}
.diff-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.diff-nav-counter {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 32px;
    text-align: center;
    user-select: none;
    font-variant-numeric: tabular-nums;
}

.stats-pills {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
}
.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 600;
}
.stat-pill.stat-add { background: rgba(34, 197, 94, 0.18); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.stat-pill.stat-del { background: rgba(239, 68, 68, 0.18); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.stat-pill.stat-eq  { background: rgba(148, 163, 184, 0.18); color: var(--text-secondary); border: 1px solid var(--border-color); }

.diff-output {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    font-family: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.55;
    max-height: 70vh;
    overflow-y: auto;
}

/* SPLIT VIEW */
.diff-split-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.diff-cell {
    display: grid;
    grid-template-columns: 48px 1fr;
    align-items: start;
    min-height: 22px;
    padding: 1px 0;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
}
.diff-cell:last-child { border-right: none; }
.diff-cell .ln {
    user-select: none;
    text-align: right;
    color: var(--text-secondary);
    opacity: 0.55;
    padding: 1px 10px 1px 8px;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.78rem;
}
.diff-cell .code {
    padding: 1px 12px 1px 10px;
    white-space: pre;
    overflow-x: auto;
    color: var(--text-primary);
}
.diff-cell.add { background: rgba(34, 197, 94, 0.12); }
.diff-cell.add .ln { color: #4ade80; opacity: 0.9; background: rgba(34, 197, 94, 0.18); border-right-color: rgba(34, 197, 94, 0.25); }
.diff-cell.del { background: rgba(239, 68, 68, 0.12); }
.diff-cell.del .ln { color: #f87171; opacity: 0.9; background: rgba(239, 68, 68, 0.18); border-right-color: rgba(239, 68, 68, 0.25); }
.diff-cell.empty { background: rgba(0, 0, 0, 0.18); }
.diff-cell.empty .ln, .diff-cell.empty .code { opacity: 0.3; }

/* UNIFIED VIEW */
.diff-unified-row {
    display: grid;
    grid-template-columns: 40px 40px 22px 1fr;
    align-items: start;
    min-height: 22px;
    padding: 1px 0;
}
.diff-unified-row .ln {
    user-select: none;
    text-align: right;
    color: var(--text-secondary);
    opacity: 0.55;
    padding: 1px 8px;
    font-size: 0.78rem;
}
.diff-unified-row .marker {
    text-align: center;
    user-select: none;
    font-weight: 700;
    color: var(--text-secondary);
    opacity: 0.7;
}
.diff-unified-row .code {
    padding: 1px 12px;
    white-space: pre;
    overflow-x: auto;
    color: var(--text-primary);
}
.diff-unified-row.add { background: rgba(34, 197, 94, 0.12); }
.diff-unified-row.add .marker, .diff-unified-row.add .ln { color: #4ade80; opacity: 0.95; }
.diff-unified-row.del { background: rgba(239, 68, 68, 0.12); }
.diff-unified-row.del .marker, .diff-unified-row.del .ln { color: #f87171; opacity: 0.95; }
.diff-unified-row.eq { background: transparent; }

.empty-diff {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.empty-diff svg { color: #22c55e; margin-bottom: 12px; }
.empty-diff p { margin: 0; font-weight: 500; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) {
    .compare-inputs-grid { grid-template-columns: 1fr; }
    .compare-controls-bar { gap: 12px; }
    .control-actions { margin-left: 0; }
    .btn-action-main.btn-compare { width: 100%; justify-content: center; }
    .diff-split-row { grid-template-columns: 1fr; }
    .diff-cell:first-child { border-right: none; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
}
@media (max-width: 600px) {
    .tool-container { padding: 90px 14px 40px; }
    .tool-panel { padding: 16px; }
    .panel-header { flex-direction: column; align-items: flex-start; }
    .stats-pills { width: 100%; }
}
