body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 20px auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 20px 30px;
}

h1 {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
}
h2 {
    color: #16a085;
    margin-top: 20px;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 1px solid #1abc9c;
    text-align: center;
}
h3 {
    color: #2980b9;
    margin-top: 5px;
    margin-bottom: 10px;
    font-size: 1.1em;
    text-align: center;
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: #3498db;
    text-decoration: none;
    padding: 8px 15px;
    border: 1px solid #3498db;
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s;
}

.back-link:hover {
    background-color: #3498db;
    color: #fff;
}

.controls {
    text-align: center;
    margin-bottom: 25px;
    padding: 15px;
    background-color: #ecf0f1;
    border-radius: 5px;
}
.controls button {
    padding: 10px 18px;
    margin: 0 8px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}
.controls button:hover:not(:disabled) {
    background-color: #2980b9;
}
.controls button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}
.controls label {
    margin-left: 15px;
    margin-right: 5px;
}
.controls input[type="range"] {
    vertical-align: middle;
}

.simulation-area {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    min-height: 300px; /* Ensure area has height */
}

.network-topology {
    flex: 1; /* Takes up half the space */
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 15px;
    position: relative; /* Needed for absolute positioning of routers/links */
    background-color: #fdfdfd;
}

#topology-map {
    position: relative;
    width: 100%;
    height: 250px; /* Adjust as needed */
}

.router {
    position: absolute;
    width: 50px;
    height: 50px;
    background-color: #e74c3c;
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.2em;
    border: 2px solid #c0392b;
    z-index: 2;
    cursor: default;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
}

#links-svg {
    pointer-events: none; /* Allow clicks to pass through SVG */
}

.link {
    stroke: #7f8c8d;
    stroke-width: 3;
    z-index: 1;
}

.routing-tables {
    flex: 1; /* Takes up the other half */
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 15px;
    background-color: #fdfdfd;
    overflow-y: auto; /* Add scroll if tables get long */
    max-height: 400px; /* Limit height */
}

.table-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Responsive columns */
    gap: 15px;
}

.router-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    margin-bottom: 15px;
}

.router-table th, .router-table td {
    border: 1px solid #ddd;
    padding: 6px 8px;
    text-align: center;
}

.router-table th {
    background-color: #ecf0f1;
    color: #34495e;
}

.router-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.message-log {
    margin-top: 20px;
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 15px;
    background-color: #fdfdfd;
}

#log-output {
    height: 150px;
    overflow-y: scroll;
    background-color: #fff;
    border: 1px solid #eee;
    padding: 10px;
    font-family: monospace;
    font-size: 0.9em;
    white-space: pre-wrap; /* Wrap long lines */
}

/* Animation for RIP update packets */
.rip-packet {
    position: absolute;
    width: 15px;
    height: 10px;
    background-color: #f1c40f;
    border: 1px solid #f39c12;
    border-radius: 3px;
    z-index: 5;
    opacity: 0; /* Start hidden */
    transition: opacity 0.2s ease-in-out;
}

/* Highlight updated table rows */
.updated-row {
    animation: highlight 1s ease-out;
}

@keyframes highlight {
    from { background-color: #f1c40f; }
    to { background-color: inherit; }
}