/* Reset và cài đặt cơ bản */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    padding: 10px;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    background-color: white;
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Header */
.header {
    background: linear-gradient(to right, #2c3e50, #4a6491);
    color: white;
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.header-content h1 {
    font-size: 1.9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
    margin-top: 6px;
}

.home-btn {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    text-decoration: none;
    padding: 13px 24px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.95rem;
}

.home-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Main content */
.main-content {
    padding: 28px;
}

/* Input section */
.input-section {
    margin-bottom: 32px;
}

.text-input-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    margin-bottom: 28px;
}

.text-input-box {
    border: 1px solid #e1e5eb;
    border-radius: 12px;
    overflow: hidden;
    background-color: #f9fafc;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.03);
}

.text-input-box:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    border-color: #c1c9d6;
}

.text-header {
    background-color: #f1f5f9;
    padding: 16px 22px;
    border-bottom: 1px solid #e1e5eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.text-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #2d3748;
}

.text-stats {
    display: flex;
    align-items: center;
    gap: 12px;
}

.text-stats .stat {
    font-size: 0.87rem;
    color: #64748b;
    background-color: #e2e8f0;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 500;
}

.stat-badge {
    font-size: 0.8rem;
    color: white;
    background-color: #3b82f6;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.stat-badge#badge1 {
    background-color: #3b82f6;
}

.stat-badge#badge2 {
    background-color: #10b981;
}

textarea {
    width: 100%;
    height: 320px;
    padding: 20px;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 1.02rem;
    resize: vertical;
    background-color: white;
    line-height: 1.7;
    transition: all 0.2s ease;
}

textarea:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px #3b82f6;
}

.text-actions {
    padding: 14px 22px;
    background-color: #f8fafc;
    border-top: 1px solid #e1e5eb;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Controls section */
.controls-section {
    background-color: #f8fafc;
    padding: 24px;
    border-radius: 14px;
    border: 1px solid #e1e5eb;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.03);
}

.mode-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 24px;
}

.mode-selector h3, .comparison-options h3 {
    font-size: 1.15rem;
    margin-bottom: 16px;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-buttons {
    display: flex;
    gap: 16px;
}

.mode-btn {
    padding: 14px 24px;
    background-color: #e2e8f0;
    border: 1px solid #cbd5e0;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.mode-btn.active {
    background-color: #3b82f6;
    color: white;
    border-color: #2563eb;
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.mode-btn:hover:not(.active) {
    background-color: #cbd5e0;
    transform: translateY(-2px);
}

.option-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    color: #4b5563;
}

.option-checkbox input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #3b82f6;
}

.action-buttons {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 15px 26px;
    border: none;
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.97rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.primary-btn {
    background-color: #3b82f6;
    color: white;
}

.primary-btn:hover {
    background-color: #2563eb;
}

.success-btn {
    background-color: #10b981;
    color: white;
}

.success-btn:hover {
    background-color: #059669;
}

.secondary-btn {
    background-color: #6b7280;
    color: white;
}

.secondary-btn:hover {
    background-color: #4b5563;
}

.warning-btn {
    background-color: #f59e0b;
    color: white;
}

.warning-btn:hover {
    background-color: #d97706;
}

.small-btn {
    padding: 9px 18px;
    font-size: 0.87rem;
    font-weight: 500;
}

/* Results section */
.results-section {
    margin-top: 32px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid #e1e5eb;
    flex-wrap: wrap;
    gap: 20px;
}

.results-header h2 {
    font-size: 1.5rem;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 12px;
}

.results-actions {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.legend {
    display: flex;
    gap: 20px;
    background-color: #f8fafc;
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid #e1e5eb;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #64748b;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.legend-color.removed {
    background-color: #fecaca;
    border: 1px solid #f87171;
}

.legend-color.added {
    background-color: #bbf7d0;
    border: 1px solid #4ade80;
}

.legend-color.changed {
    background-color: #fef3c7;
    border: 1px solid #fbbf24;
}

.legend-color.merged {
    background-color: #dbeafe;
    border: 1px solid #60a5fa;
}

.results-buttons {
    display: flex;
    gap: 12px;
}

.comparison-mode-info {
    margin-bottom: 20px;
}

.mode-info {
    background-color: #e0f2fe;
    color: #0369a1;
    padding: 14px 20px;
    border-radius: 10px;
    border-left: 4px solid #0ea5e9;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
}

.mode-info i {
    font-size: 1.1rem;
}

/* Comparison view */
.comparison-view {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    margin-bottom: 32px;
    transition: all 0.3s ease;
}

.comparison-view.zoomed {
    grid-template-columns: 1fr;
}

.comparison-view.zoomed .comparison-column {
    grid-column: span 2;
}

.comparison-column {
    border: 1px solid #e1e5eb;
    border-radius: 12px;
    overflow: hidden;
    background-color: #f9fafc;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.03);
    transition: all 0.3s ease;
}

.comparison-column.zoomed {
    height: 600px;
}

.comparison-header {
    background-color: #f1f5f9;
    padding: 16px 22px;
    border-bottom: 1px solid #e1e5eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.comparison-header h4 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #2d3748;
}

.diff-summary {
    display: flex;
    gap: 12px;
}

.diff-count {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
}

.diff-count.added {
    background-color: #dcfce7;
    color: #166534;
}

.diff-count.removed {
    background-color: #fee2e2;
    color: #991b1b;
}

.diff-count.changed {
    background-color: #fef3c7;
    color: #92400e;
}

.comparison-content {
    padding: 0;
    height: 380px;
    overflow-y: auto;
    background-color: white;
    line-height: 1.7;
    font-size: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    position: relative;
    transition: height 0.3s ease;
}

.comparison-content.zoomed {
    height: 500px;
}

.comparison-content .placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #94a3b8;
    text-align: center;
    padding: 40px;
}

.comparison-content .placeholder i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.comparison-content .placeholder p {
    font-size: 1rem;
    max-width: 300px;
}

/* Diff highlighting styles */
.diff-line {
    padding: 6px 20px;
    display: flex;
    min-height: 28px;
    align-items: center;
    border-left: 4px solid transparent;
    transition: background-color 0.2s ease;
}

.diff-line:hover {
    background-color: #f8fafc;
}

.diff-line-number {
    min-width: 40px;
    color: #94a3b8;
    font-size: 0.85rem;
    text-align: right;
    padding-right: 15px;
    user-select: none;
}

.diff-line-content {
    flex: 1;
    white-space: pre-wrap;
    word-wrap: break-word;
    padding-left: 10px;
    border-left: 1px solid #e2e8f0;
}

.diff-line.removed {
    background-color: #fef2f2;
    border-left-color: #f87171;
}

.diff-line.added {
    background-color: #f0fdf4;
    border-left-color: #4ade80;
}

.diff-line.changed {
    background-color: #fffbeb;
    border-left-color: #fbbf24;
}

.diff-char.removed {
    background-color: #fecaca;
    color: #991b1b;
    text-decoration: line-through;
    padding: 1px 2px;
    border-radius: 3px;
    margin: 0 1px;
}

.diff-char.added {
    background-color: #bbf7d0;
    color: #166534;
    padding: 1px 2px;
    border-radius: 3px;
    margin: 0 1px;
    font-weight: 500;
}

.diff-char.changed {
    background-color: #fde68a;
    color: #92400e;
    padding: 1px 2px;
    border-radius: 3px;
    margin: 0 1px;
    font-weight: 500;
}

.diff-word {
    padding: 2px 4px;
    border-radius: 4px;
    margin: 0 2px;
    transition: all 0.2s ease;
}

.diff-word.removed {
    background-color: #fecaca;
    color: #991b1b;
    text-decoration: line-through;
}

.diff-word.added {
    background-color: #bbf7d0;
    color: #166534;
    font-weight: 500;
}

.diff-word.changed {
    background-color: #fde68a;
    color: #92400e;
    font-weight: 500;
}

/* Detailed results */
.detailed-results {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 28px;
}

.stats-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stats-card {
    border: 1px solid #e1e5eb;
    border-radius: 12px;
    padding: 22px;
    background-color: #f9fafc;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.03);
}

.stats-card h4 {
    font-size: 1.1rem;
    margin-bottom: 22px;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background-color: white;
    border-radius: 10px;
    border-left: 4px solid #3b82f6;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.stat-label {
    font-size: 0.92rem;
    color: #64748b;
    font-weight: 500;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2d3748;
}

.stat-value.added {
    color: #10b981;
}

.stat-value.removed {
    color: #ef4444;
}

.stat-value.changed {
    color: #f59e0b;
}

.merged-panel {
    display: flex;
    flex-direction: column;
}

.merged-result {
    border: 1px solid #e1e5eb;
    border-radius: 12px;
    overflow: hidden;
    background-color: #f9fafc;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.03);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.merged-header {
    background-color: #f1f5f9;
    padding: 18px 22px;
    border-bottom: 1px solid #e1e5eb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.merged-header h4 {
    font-size: 1.1rem;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 10px;
}

.merged-info {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background-color: #e0f2fe;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #0369a1;
}

.merged-info i {
    margin-top: 2px;
    flex-shrink: 0;
}

.merged-actions {
    display: flex;
    gap: 12px;
}

.merged-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    background-color: white;
    line-height: 1.7;
    font-size: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.merged-content .placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #94a3b8;
    text-align: center;
    padding: 40px;
}

.merged-content .placeholder i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.merged-content .placeholder p {
    font-size: 1rem;
    max-width: 400px;
}

/* Merged text styles */
.merged-text-part {
    padding: 2px 4px;
    border-radius: 4px;
    margin: 0 2px;
}

.merged-text-part.added {
    background-color: #bbf7d0;
    color: #166534;
}

.merged-text-part.removed {
    background-color: #fecaca;
    color: #991b1b;
    text-decoration: line-through;
}

.merged-text-part.merged {
    background-color: #dbeafe;
    color: #1e40af;
    font-weight: 500;
}

.merged-line {
    padding: 4px 0;
    border-left: 3px solid transparent;
    padding-left: 10px;
    margin-bottom: 4px;
}

.merged-line.added {
    border-left-color: #4ade80;
    background-color: #f0fdf4;
}

.merged-line.removed {
    border-left-color: #f87171;
    background-color: #fef2f2;
}

.merged-line.merged {
    border-left-color: #60a5fa;
    background-color: #eff6ff;
}

/* Footer */
.footer {
    background-color: #2d3748;
    color: #cbd5e0;
    text-align: center;
    padding: 22px;
    margin-top: 40px;
}

.footer p {
    margin: 10px 0;
    font-size: 0.92rem;
}

.footer a {
    color: #cbd5e0;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: white;
    text-decoration: underline;
}

/* Toastr customization */
.toast-success {
    background-color: #10b981 !important;
    border-radius: 8px !important;
}

.toast-error {
    background-color: #ef4444 !important;
    border-radius: 8px !important;
}

.toast-info {
    background-color: #3b82f6 !important;
    border-radius: 8px !important;
}

.toast-warning {
    background-color: #f59e0b !important;
    border-radius: 8px !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: #c1c9d6;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Responsive design */
@media (max-width: 1400px) {
    .detailed-results {
        grid-template-columns: 1fr;
    }
    
    .mode-controls {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

@media (max-width: 1200px) {
    .text-input-container {
        grid-template-columns: 1fr;
    }
    
    .comparison-view {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 992px) {
    .header {
        flex-direction: column;
        gap: 18px;
        text-align: center;
    }
    
    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 18px;
    }
    
    .results-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .action-buttons {
        justify-content: center;
    }
    
    .btn {
        flex: 1;
        min-width: 140px;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 18px;
    }
    
    .header {
        padding: 18px;
    }
    
    .comparison-content, .merged-content {
        height: 300px;
    }
    
    .comparison-content.zoomed {
        height: 400px;
    }
    
    .mode-buttons {
        flex-wrap: wrap;
    }
    
    .mode-btn {
        flex: 1;
        min-width: 100px;
        justify-content: center;
    }
    
    .text-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .text-stats {
        width: 100%;
        justify-content: space-between;
    }
    
    .legend {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .results-buttons {
        width: 100%;
        justify-content: center;
    }
    
    .merged-header {
        gap: 15px;
    }
}

@media (max-width: 576px) {
    .container {
        border-radius: 12px;
    }
    
    .main-content {
        padding: 15px;
    }
    
    .header-content h1 {
        font-size: 1.6rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .home-btn {
        width: 100%;
        justify-content: center;
    }
    
    .text-actions {
        justify-content: center;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .merged-actions {
        width: 100%;
    }
    
    .merged-actions .btn {
        width: auto;
        flex: 1;
    }
}