:root {
    --bg-color: #f3f4f6;
    --panel-bg: #ffffff;
    --text-color: #1f2937;
    --border-color: #e5e7eb;
}

.dark {
    --bg-color: #0f172a;
    --panel-bg: #1e293b;
    --text-color: #f1f5f9;
    --border-color: #334155;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* --- Graph Styles --- */
#graph-container {
    width: 100vw;
    height: 100vh;
    cursor: grab;
}
#graph-container:active {
    cursor: grabbing;
}

.node circle {
    stroke-width: 2px;
    transition: stroke 0.3s ease;
    /* Only animate stroke via CSS, position via D3 */
    cursor: pointer;
}

.node.disabled circle {
    fill: #94a3b8 !important;
    /* Gray for disabled */
    animation: none !important;
}

.node text {
    font-family: sans-serif;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    fill: var(--text-color);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.link {
    fill: none;
    stroke: #9ca3af;
    /* Default Grey */
    stroke-width: 2px;
    transition: stroke 0.3s;
}

/* --- Animations --- */
@keyframes dash-flow {
    to {
        stroke-dashoffset: -20;
    }
}

@keyframes blink-animation {
    0%,
    100% {
        opacity: 1;
        stroke-opacity: 1;
    }
    50% {
        opacity: 0.3;
        stroke-opacity: 0.3;
    }
}

.link.up {
    stroke: #22c55e;
    stroke-dasharray: 5, 5;
    animation: dash-flow 1s linear infinite;
}

.link.down {
    stroke: #ef4444;
    stroke-dasharray: 5, 5;
    animation: blink-animation 1s step-end infinite;
}

.node.down circle {
    animation: blink-animation 1s step-end infinite;
    fill: #ef4444 !important;
}

.node.unknown circle {
    fill: #9ca3af !important;
}

/* --- UI Panels --- */
.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(8px);
}

/* Context Menu specific */
.context-menu {
    position: absolute;
    z-index: 50;
    display: none;
    border-radius: 0.5rem;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.1s ease, transform 0.1s ease;
}
.context-menu.active {
    display: block;
    opacity: 1;
    transform: scale(1);
}

/* Sidebar Animation Logic */
#nav-panel {
    /* Ensure it starts off-screen */
    transform: translateX(100%);
    /* Smooth slide animation */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#nav-panel.active {
    /* Slide in to view */
    transform: translateX(0);
}

#device-menu {
    min-width: 150px;
}

/* Tooltip */
#tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    z-index: 60;
    white-space: pre-line;
    transition: opacity 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* --- Toasts --- */
@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast {
    animation: toast-in 0.3s ease-out;
    pointer-events: auto;
    /* Re-enable clicks specifically for toasts */
}
