/* Scoped styles for Text Diff App */

:root {
    --diff-bg: rgba(23, 23, 23, 0.8);
    --diff-primary: #3b82f6;
    /* Blue-500 */
    --diff-primary-hover: #2563eb;
    /* Blue-600 */
    --diff-border: rgba(255, 255, 255, 0.1);
    --diff-add-bg: rgba(16, 185, 129, 0.2);
    /* Emerald-500 optimized opacity */
    --diff-del-bg: rgba(239, 68, 68, 0.2);
    /* Red-500 optimized opacity */
    --diff-add-text: #34d399;
    --diff-del-text: #f87171;
}

.app-container {
    padding: 1rem;
    /* display: flex; */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.main-card {
    background: var(--diff-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--diff-border);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    width: 98%;
    /* Almost full width with slight margin */
    max-width: none;
    /* Remove max-width limit */
    overflow: hidden;
    height: 85vh;
    /* Fixed height relative to viewport */
    margin-top: 2rem;
}

.header-section {
    padding: 1rem 2rem;
    /* Reduce padding */
    border-bottom: 1px solid var(--diff-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    /* Prevent shrinking */
}

.brand h1 {
    font-size: 2rem;
    font-weight: 600;
    background: linear-gradient(to right, #60a5fa, #3b82f6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.25rem;
}

.brand p {
    color: #94a3b8;
    font-size: 0.9rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.sync-scroll-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #94a3b8;
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.sync-scroll-label:hover {
    color: #e2e8f0;
}

.sync-scroll-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.sync-scroll-label input[type="checkbox"]:checked {
    background: var(--diff-primary);
    border-color: var(--diff-primary);
}

.sync-scroll-label input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 10px;
}

#compare-btn {
    background: linear-gradient(135deg, var(--diff-primary), var(--diff-primary-hover));
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#compare-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* Diff Container & Panes */
.diff-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    /* Hide container overflow */
    min-height: 0;
    /* Important for flex child scrolling */
}

.pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Prevent flexitem overflow */
}

.left-pane {
    border-right: 1px solid var(--diff-border);
}

.pane-header {
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--diff-border);
}

.pane-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: #e2e8f0;
}

.upload-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.file-name {
    font-size: 0.8rem;
    color: #94a3b8;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.upload-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Code Editor / Diff View */
.code-editor {
    flex: 1;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.4);
    color: #cbd5e1;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    overflow-y: scroll;
    /* Always show scrollbar and allow scrolling */
    white-space: pre;
    /* Use 'pre' to prevent wrapping so horizontal scroll works if needed, or 'pre-wrap' if wrapping desired. Diff usually pre. */
    word-break: normal;
}

.code-editor:empty:before {
    content: attr(placeholder);
    color: rgba(148, 163, 184, 0.5);
}

/* Diff Styling */
.diff-line {
    display: block;
    /* Ensure full width highlight */
    padding: 0 0.5rem;
    min-height: 1.5em;
    /* Match line height */
}

.diff-added {
    background-color: var(--diff-add-bg);
    color: var(--diff-add-text);
}

.diff-removed {
    background-color: var(--diff-del-bg);
    color: var(--diff-del-text);
}

.line-number {
    display: inline-block;
    width: 30px;
    color: #64748b;
    user-select: none;
    text-align: right;
    margin-right: 10px;
    font-size: 0.8em;
}

/* Responsive */
@media (max-width: 768px) {
    .diff-container {
        flex-direction: column;
    }

    .left-pane {
        border-right: none;
        border-bottom: 1px solid var(--diff-border);
        height: 50%;
    }

    .main-card {
        height: auto;
        min-height: auto;
    }

    .code-editor {
        min-height: 300px;
    }
}