/**
 * Text Diff Tool Styles
 * Extends main.css with tool-specific styling
 * Full support for light, dark, and auto themes
 */

.text-diff-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Input Sections - Side by Side */
.text-diff-inputs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.input-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color, #1f2937);
}

.textarea-wrapper {
    position: relative;
}

.diff-textarea {
    width: 100%;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    border: 2px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    background: var(--bg-color, #ffffff);
    color: var(--text-color, #1f2937);
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.diff-textarea:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 3px var(--primary-color-alpha, rgba(59, 130, 246, 0.1));
}

.diff-textarea::placeholder {
    color: var(--text-muted, #6b7280);
    opacity: 0.6;
}

/* Options Container */
.options-container {
    padding: 1.25rem;
    background: var(--card-bg, #f8f9fa);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
}

.options-title {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color, #1f2937);
}

.options-grid {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.option-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.option-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color, #3b82f6);
}

.checkbox-label {
    font-size: 0.95rem;
    color: var(--text-color, #1f2937);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.compare-btn,
.swap-btn,
.btn-copy,
.btn-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.compare-btn {
    background: var(--primary-color, #3b82f6);
    color: white;
    flex: 1;
}

.compare-btn:hover {
    background: var(--primary-dark, #2563eb);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.swap-btn {
    background: var(--secondary-color, #6366f1);
    color: white;
}

.swap-btn:hover {
    background: var(--secondary-dark, #4f46e5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-copy {
    background: var(--success-color, #10b981);
    color: white;
}

.btn-copy:hover {
    background: var(--success-dark, #059669);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-clear {
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-color, #1f2937);
    border: 2px solid var(--border-color, #e5e7eb);
}

.btn-clear:hover {
    background: var(--bg-tertiary, #e5e7eb);
    border-color: var(--text-muted, #6b7280);
}

/* Statistics Container */
.stats-container {
    padding: 1.25rem;
    background: var(--card-bg, #f8f9fa);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
}

.stats-title {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color, #1f2937);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1.5rem;
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted, #6b7280);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color, #3b82f6);
}

.stat-added .stat-value {
    color: var(--success-color, #10b981);
}

.stat-removed .stat-value {
    color: var(--error-color, #ef4444);
}

.stat-modified .stat-value {
    color: var(--warning-color, #f59e0b);
}

/* Output Container */
.output-container {
    margin-top: 1rem;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.output-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color, #1f2937);
}

.diff-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
}

.legend-item::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-added {
    color: var(--success-dark, #059669);
    background: var(--success-light, #d1fae5);
}

.legend-added::before {
    background: var(--success-color, #10b981);
}

.legend-removed {
    color: var(--error-dark, #dc2626);
    background: var(--error-light, #fee2e2);
}

.legend-removed::before {
    background: var(--error-color, #ef4444);
}

.legend-modified {
    color: var(--warning-dark, #d97706);
    background: var(--warning-light, #fef3c7);
}

.legend-modified::before {
    background: var(--warning-color, #f59e0b);
}

/* Diff Output */
.diff-output {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    border: 2px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    background: var(--bg-color, #ffffff);
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

.diff-line {
    display: flex;
    align-items: flex-start;
    padding: 0.25rem 1rem;
    min-height: 1.6em;
}

.line-number {
    display: inline-block;
    min-width: 3rem;
    margin-right: 1rem;
    text-align: right;
    color: var(--text-muted, #6b7280);
    user-select: none;
    font-size: 0.85rem;
}

.line-prefix {
    display: inline-block;
    width: 1.5rem;
    font-weight: 600;
    user-select: none;
}

.line-content {
    flex: 1;
    word-break: break-all;
    white-space: pre-wrap;
}

.diff-line-equal {
    background: var(--bg-color, #ffffff);
    color: var(--text-color, #1f2937);
}

.diff-line-equal .line-prefix {
    color: var(--text-muted, #6b7280);
}

.diff-line-added {
    background: var(--success-light, #d1fae5);
    color: var(--success-dark, #059669);
}

.diff-line-added .line-prefix {
    color: var(--success-color, #10b981);
}

.diff-line-removed {
    background: var(--error-light, #fee2e2);
    color: var(--error-dark, #dc2626);
}

.diff-line-removed .line-prefix {
    color: var(--error-color, #ef4444);
}

/* Identical Message */
.identical-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    background: var(--success-light, #d1fae5);
    border: 2px solid var(--success-color, #10b981);
    border-radius: 8px;
    text-align: center;
}

.identical-message svg {
    color: var(--success-color, #10b981);
    margin-bottom: 1rem;
}

.identical-message p {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--success-dark, #059669);
}

/* Copy Notification */
.copy-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: var(--success-color, #10b981);
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-weight: 600;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .text-diff-inputs {
        grid-template-columns: 1fr;
    }

    .options-grid {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .compare-btn,
    .swap-btn,
    .btn-copy,
    .btn-clear {
        width: 100%;
    }

    .output-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .diff-legend {
        width: 100%;
    }

    .copy-notification {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }

    .line-number {
        min-width: 2rem;
        margin-right: 0.5rem;
    }
}

/* Dark Theme Support - System Preference */
@media (prefers-color-scheme: dark) {
    .diff-textarea {
        background: #1e293b;
        border-color: #334155;
        color: #e2e8f0;
    }

    .options-container,
    .stats-container {
        background: #1e293b;
        border-color: #334155;
    }

    .options-title,
    .stats-title,
    .output-title,
    .input-label,
    .checkbox-label {
        color: #e2e8f0;
    }

    .btn-clear {
        background: #1e293b;
        border-color: #334155;
        color: #e2e8f0;
    }

    .btn-clear:hover {
        background: #334155;
        border-color: #475569;
    }

    .stat-label {
        color: #94a3b8;
    }

    .diff-output {
        background: #1e293b;
        border-color: #334155;
    }

    .diff-line-equal {
        background: #1e293b;
        color: #e2e8f0;
    }

    .line-number {
        color: #64748b;
    }

    .diff-line-added {
        background: rgba(16, 185, 129, 0.15);
        color: #6ee7b7;
    }

    .diff-line-removed {
        background: rgba(239, 68, 68, 0.15);
        color: #fca5a5;
    }

    .legend-added {
        color: #6ee7b7;
        background: rgba(16, 185, 129, 0.15);
    }

    .legend-removed {
        color: #fca5a5;
        background: rgba(239, 68, 68, 0.15);
    }

    .legend-modified {
        color: #fcd34d;
        background: rgba(245, 158, 11, 0.15);
    }

    .identical-message {
        background: rgba(16, 185, 129, 0.15);
        border-color: #10b981;
    }

    .identical-message p {
        color: #6ee7b7;
    }
}

/* Light Theme Explicit Override */
[data-theme="light"] .diff-textarea {
    background: #ffffff;
    border-color: #e5e7eb;
    color: #1f2937;
}

[data-theme="light"] .options-container,
[data-theme="light"] .stats-container {
    background: #f8f9fa;
    border-color: #e5e7eb;
}

[data-theme="light"] .options-title,
[data-theme="light"] .stats-title,
[data-theme="light"] .output-title,
[data-theme="light"] .input-label,
[data-theme="light"] .checkbox-label {
    color: #1f2937;
}

[data-theme="light"] .btn-clear {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #1f2937;
}

[data-theme="light"] .btn-clear:hover {
    background: #e5e7eb;
    border-color: #6b7280;
}

[data-theme="light"] .stat-label {
    color: #6b7280;
}

[data-theme="light"] .diff-output {
    background: #ffffff;
    border-color: #e5e7eb;
}

[data-theme="light"] .diff-line-equal {
    background: #ffffff;
    color: #1f2937;
}

[data-theme="light"] .line-number {
    color: #6b7280;
}

[data-theme="light"] .diff-line-added {
    background: #d1fae5;
    color: #059669;
}

[data-theme="light"] .diff-line-removed {
    background: #fee2e2;
    color: #dc2626;
}

[data-theme="light"] .legend-added {
    color: #059669;
    background: #d1fae5;
}

[data-theme="light"] .legend-removed {
    color: #dc2626;
    background: #fee2e2;
}

[data-theme="light"] .legend-modified {
    color: #d97706;
    background: #fef3c7;
}

[data-theme="light"] .identical-message {
    background: #d1fae5;
    border-color: #10b981;
}

[data-theme="light"] .identical-message p {
    color: #059669;
}

/* Dark Theme Explicit Override */
[data-theme="dark"] .diff-textarea {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .options-container,
[data-theme="dark"] .stats-container {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .options-title,
[data-theme="dark"] .stats-title,
[data-theme="dark"] .output-title,
[data-theme="dark"] .input-label,
[data-theme="dark"] .checkbox-label {
    color: #e2e8f0;
}

[data-theme="dark"] .btn-clear {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .btn-clear:hover {
    background: #334155;
    border-color: #475569;
}

[data-theme="dark"] .stat-label {
    color: #94a3b8;
}

[data-theme="dark"] .diff-output {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .diff-line-equal {
    background: #1e293b;
    color: #e2e8f0;
}

[data-theme="dark"] .line-number {
    color: #64748b;
}

[data-theme="dark"] .diff-line-added {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
}

[data-theme="dark"] .diff-line-removed {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

[data-theme="dark"] .legend-added {
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.15);
}

[data-theme="dark"] .legend-removed {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.15);
}

[data-theme="dark"] .legend-modified {
    color: #fcd34d;
    background: rgba(245, 158, 11, 0.15);
}

[data-theme="dark"] .identical-message {
    background: rgba(16, 185, 129, 0.15);
    border-color: #10b981;
}

[data-theme="dark"] .identical-message p {
    color: #6ee7b7;
}
