* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 300;
}

.header p {
    font-size: 1.1em;
    opacity: 0.9;
    line-height: 1.6;
}

.tutorial {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    margin: 20px 0;
}

.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.tutorial h3 {
    margin: 0;
    color: #495057;
    font-size: 1.2em;
}

.tutorial-toggle {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tutorial-toggle:hover {
    background: #5a6268;
}

.tutorial-content {
    transition: all 0.3s ease;
    overflow: hidden;
}

.tutorial-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.step {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 8px 0;
}

.step-number {
    background: #007bff;
    color: white;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
    flex-shrink: 0;
}

.step-text {
    color: #495057;
    font-size: 0.95em;
    line-height: 1.4;
}

.tutorial-tip {
    margin-top: 15px;
    padding: 10px;
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    border-radius: 5px;
    color: #0c5460;
    font-size: 0.9em;
}

.controls {
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.data-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.data-container {
    background: white;
    border-radius: 10px;
    padding: 15px;
    border: 2px solid #e9ecef;
}

.data-container h3 {
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 1.2em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.add-row-btn {
    background: #28a745;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.add-row-btn:hover {
    background: #1e7e34;
    transform: scale(1.1);
}

.remove-row-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 5px;
}

.remove-row-btn:hover {
    background: #c82333;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}

.data-table th,
.data-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
    font-size: 0.9em;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
}

.data-table input {
    width: 100%;
    border: none;
    padding: 4px;
    font-size: 0.9em;
}

.data-table input:focus {
    outline: 2px solid #007bff;
    border-radius: 3px;
}

.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,123,255,0.4);
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40,167,69,0.4);
}

.btn-warning {
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
    color: #212529;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255,193,7,0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220,53,69,0.4);
}

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

.visualization {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    height: 900px;
}

.tree-row {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 750px;
}

.tree-container {
    flex: 1;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    border: 2px solid #e9ecef;
    position: relative;
    display: flex;
    flex-direction: column;
}

.tree-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.zoom-controls {
    display: flex;
    gap: 5px;
}

.zoom-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
}

.zoom-btn:hover {
    background: #0056b3;
}

.error-message {
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 10px;
    margin: 10px 0;
    text-align: center;
    font-weight: bold;
}

.info-message {
    color: #0c5460;
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    border-radius: 4px;
    padding: 10px;
    margin: 10px 0;
    text-align: center;
    font-weight: bold;
}

.tree-svg {
    width: 100%;
    flex: 1;
    background: white;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    min-height: 670px;
}

.tree-svg-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.stats {
    background: #e9ecef;
    padding: 12px;
    border-radius: 8px;
    margin-top: 10px;
}

.stats h4 {
    margin: 0 0 8px 0;
    color: #495057;
    font-size: 0.95em;
    text-align: center;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.stat-item {
    flex: 1;
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    background: white;
    border: 1px solid #dee2e6;
}

.stat-label {
    font-size: 0.75em;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 0.9em;
    color: #495057;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

.log-section {
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.log-container {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 15px;
    border-radius: 8px;
    height: 200px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.4;
}

.log-entry {
    margin-bottom: 5px;
    padding: 3px 0;
}

.log-info { color: #3498db; }
.log-success { color: #2ecc71; }
.log-warning { color: #f39c12; }
.log-error { color: #e74c3c; }

.node {
    cursor: pointer;
    transition: all 0.3s ease;
}

.node:hover {
    stroke-width: 3px;
}

.node-leaf {
    fill: #2ecc71;
    stroke: #27ae60;
}

.node-internal {
    fill: #3498db;
    stroke: #2980b9;
}

.node-root {
    fill: #e74c3c;
    stroke: #c0392b;
}

.node-highlighted {
    stroke: #f39c12;
    stroke-width: 4px;
    animation: pulse 1s infinite;
}

.node-different {
    fill: #e74c3c;
    stroke: #c0392b;
}

.node-trace {
    fill: #f39c12;
    stroke: #e67e22;
    stroke-width: 3px;
    animation: tracePulse 1s infinite;
}

.link-trace {
    stroke: #f39c12;
    stroke-width: 4px;
    animation: tracePulse 1s infinite;
}

@keyframes tracePulse {
    0% {
        opacity: 1;
        stroke-width: 3px;
    }
    50% {
        opacity: 0.7;
        stroke-width: 4px;
    }
    100% {
        opacity: 1;
        stroke-width: 3px;
    }
}

.link {
    fill: none;
    stroke: #95a5a6;
    stroke-width: 2px;
}

.link-highlighted {
    stroke: #f39c12;
    stroke-width: 4px;
    animation: pulse 1s infinite;
}

.node-label {
    font-size: 10px;
    font-family: 'Courier New', monospace;
    text-anchor: middle;
    pointer-events: none;
    fill: #2c3e50;
}

.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    max-width: 300px;
    word-wrap: break-word;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.sync-arrow {
    stroke: #e74c3c;
    stroke-width: 3px;
    stroke-dasharray: 10,5;
    animation: dash 2s linear infinite;
    fill: none;
    marker-end: url(#arrowhead);
}

@keyframes dash {
    to {
        stroke-dashoffset: -15;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tutorial {
    animation: fadeIn 0.5s ease-out;
}

.step {
    transition: all 0.3s ease;
}

.step:hover {
    background: rgba(0, 123, 255, 0.1);
    border-radius: 5px;
    padding-left: 10px;
}

.btn {
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.node {
    transition: all 0.3s ease;
}

@media (max-width: 1200px) {
    .tree-row {
        flex-direction: column;
    }
    
    .data-section {
        grid-template-columns: 1fr;
    }
} 