/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
    min-height: 100vh;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main content */
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Input section */
.input-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.input-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #495057;
    font-size: 1.1rem;
}

.input-group textarea {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 200px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.input-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-group textarea.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.help-text {
    margin-top: 0.5rem;
    color: #6c757d;
    font-size: 0.875rem;
}

/* Button group */
.button-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.4);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Error section */
.error-section {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 2rem;
}

.error-message {
    color: #721c24;
    font-weight: 500;
}

/* Results section */
.results-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.results-section h2 {
    color: #495057;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

/* Summary */
.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    text-align: center;
}

.summary-label {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #495057;
}

/* No differences message */
.no-differences {
    text-align: center;
    padding: 3rem 1rem;
    background: #d4edda;
    border-radius: 8px;
    border: 1px solid #c3e6cb;
}

.no-differences p {
    font-size: 1.2rem;
    color: #155724;
    font-weight: 500;
}

/* Table */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

/* Table Controls */
.table-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    justify-content: flex-end;
    width: 100%;
}

.btn-control {
    background: #6c757d;
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-control:hover {
    background: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
}

.differences-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.differences-table th {
    background: #f8f9fa;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}

.differences-table td {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    vertical-align: top;
}

.differences-table tr:nth-child(even) {
    background: #f8f9fa;
}

.differences-table tr:hover {
    background: #e9ecef;
}

/* Row Toggle Button */
.row-toggle-btn {
    background: none;
    border: none;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 3px;
    color: #495057;
    transition: all 0.2s ease;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.row-toggle-btn:hover {
    background: #dee2e6;
    color: #212529;
}

.row-toggle-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Toggle Cell */
.toggle-cell {
    width: 30px;
    text-align: center;
    padding: 0.5rem 0.25rem;
}

/* Collapsed Row Styles */
.difference-row.collapsed .value-cell {
    display: none;
}

.difference-row.collapsed td:nth-child(3) {
    font-style: italic;
    color: #6c757d;
}

.difference-row.collapsed td:nth-child(3):after {
    content: " (collapsed)";
    font-size: 0.75rem;
    color: #adb5bd;
}

/* Transition for smooth collapse/expand */
.difference-row {
    transition: background-color 0.2s ease;
}

.difference-row.collapsed {
    background: #f8f9fa;
}

/* Code-like styling for values */
.differences-table .value-cell {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    background: #f8f9fa;
    border-radius: 4px;
    padding: 0.5rem;
    word-break: break-all;
}

/* Key path styling */
.differences-table td:nth-child(2) {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-weight: 600;
    color: #495057;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
    font-size: 0.875rem;
}

/* Responsive design */
@media (max-width: 768px) {
    .input-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .button-group {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 200px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    main {
        padding: 0 0.5rem;
    }
    
    .input-section,
    .results-section {
        padding: 1rem;
    }
    
    .summary {
        grid-template-columns: 1fr;
    }
    
    .table-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .btn-control {
        flex: 1;
        min-width: 100px;
        max-width: 120px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* Focus styles for better accessibility */
button:focus,
textarea:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-primary {
        background: #000;
        border: 2px solid #fff;
    }
    
    .differences-table th {
        background: #000;
        color: #fff;
    }
}
