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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    line-height: 1.6;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
header {
    background: #2a2a2a;
    padding: 1.5rem 2rem;
    border-bottom: 2px solid #3a3a3a;
}

header h1 {
    font-size: 1.8rem;
    color: #4FC3F7;
    margin-bottom: 0.3rem;
}

header .subtitle {
    font-size: 0.9rem;
    color: #999;
}

/* Main Content Layout */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Control Panel */
.control-panel {
    width: 320px;
    background: #242424;
    padding: 1.5rem;
    overflow-y: auto;
    border-right: 1px solid #3a3a3a;
}

.panel-section {
    margin-bottom: 2rem;
}

.panel-section h3 {
    font-size: 1rem;
    color: #4FC3F7;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #3a3a3a;
}

.control-group {
    margin-bottom: 1rem;
}

.control-group label {
    display: block;
    font-size: 0.9rem;
    color: #bbb;
    margin-bottom: 0.4rem;
}

.control-group select,
.control-group input[type="text"] {
    width: 100%;
    padding: 0.6rem;
    background: #333;
    border: 1px solid #444;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.9rem;
}

.control-group select:focus,
.control-group input[type="text"]:focus {
    outline: none;
    border-color: #4FC3F7;
}

.control-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

.hint {
    font-size: 0.85rem;
    color: #777;
    font-style: italic;
}

/* Buttons */
button {
    padding: 0.6rem 1rem;
    background: #4FC3F7;
    color: #1a1a1a;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: #29B6F6;
}

button:active {
    background: #0288D1;
}

.btn-secondary {
    background: #555;
    color: #e0e0e0;
    margin-top: 0.5rem;
    width: 100%;
}

.btn-secondary:hover {
    background: #666;
}

.btn-control {
    width: calc(33.33% - 0.3rem);
    margin-right: 0.5rem;
    font-size: 0.85rem;
    padding: 0.5rem;
}

.btn-control:last-child {
    margin-right: 0;
}

/* Stats Display */
.info-panel {
    background: #2a2a2a;
    padding: 1rem;
    border-radius: 4px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid #333;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    font-size: 0.85rem;
    color: #999;
}

.stat-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: #4FC3F7;
}

/* Legend */
#legend-display {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid #444;
}

/* Cluster Toggles */
#cluster-toggles label {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    background: #2a2a2a;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

#cluster-toggles label:hover {
    background: #333;
}

#cluster-toggles input[type="checkbox"] {
    cursor: pointer;
}

.cluster-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.cluster-color-box {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    border: 1px solid #444;
}

/* Visualization Container */
.visualization-container {
    flex: 1;
    position: relative;
    background: #1a1a1a;
}

#canvas-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

#topology-canvas {
    width: 100%;
    height: 100%;
    cursor: grab;
}

#topology-canvas:active {
    cursor: grabbing;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(40, 40, 40, 0.95);
    color: #e0e0e0;
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    border: 1px solid #555;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    max-width: 250px;
}

.tooltip.show {
    opacity: 1;
}

.tooltip-title {
    font-weight: 600;
    color: #4FC3F7;
    margin-bottom: 0.3rem;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.8rem;
}

/* Loading Spinner */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 100;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #333;
    border-top-color: #4FC3F7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: #999;
    font-size: 0.9rem;
}

/* Footer */
footer {
    background: #2a2a2a;
    padding: 1rem 2rem;
    text-align: center;
    border-top: 1px solid #3a3a3a;
    font-size: 0.85rem;
    color: #777;
}

/* Scrollbar Styling */
.control-panel::-webkit-scrollbar {
    width: 8px;
}

.control-panel::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.control-panel::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

.control-panel::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .control-panel {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .control-panel {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid #3a3a3a;
    }

    .visualization-container {
        height: 60vh;
    }
}
