:root {
    --bg-dark: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #10b981;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden; /* Prevent scrolling for full app feel */
    position: relative;
}

/* Dynamic background */
.background-animation {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(59, 130, 246, 0.15) 0%, rgba(15, 23, 42, 0) 50%),
                radial-gradient(circle at 80% 20%, rgba(16, 185, 129, 0.1) 0%, rgba(15, 23, 42, 0) 40%);
    animation: pulse 15s infinite alternate;
    z-index: -1;
}

@keyframes pulse {
    0% { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.1) translate(-2%, 2%); }
}

.main-layout {
    display: flex;
    height: 100vh;
    padding: 2rem;
    gap: 2rem;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Sidebar */
.sidebar {
    width: 380px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
}

.highlight {
    color: var(--primary);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.instructions {
    background: rgba(0,0,0,0.2);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid rgba(255,255,255,0.05);
}

.instructions h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.instructions ul {
    list-style-type: none;
    font-size: 0.85rem;
    color: rgba(148, 163, 184, 0.9);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.instructions strong {
    color: var(--primary);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

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

label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--panel-border);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

button#optimizeBtn {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

button#optimizeBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4);
}

button#optimizeBtn:active {
    transform: translateY(0);
}

button#optimizeBtn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

.hidden {
    display: none !important;
}

.result-container {
    margin-top: 2rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(16, 185, 129, 0.3);
    animation: slideUp 0.4s ease forwards;
}

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

.result-container h3 {
    color: var(--accent);
    margin-bottom: 1rem;
    text-align: center;
}

.route-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.node {
    background: var(--primary);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
}

.arrow {
    color: var(--text-muted);
    font-weight: bold;
    animation: fadeIn 0.3s ease backwards;
}

@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.distance-display {
    text-align: center;
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 1rem;
}

.highlight-value {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.4rem;
}

.error-container {
    margin-top: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid var(--danger);
    padding: 1rem;
    border-radius: 4px;
    color: var(--danger);
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#network {
    width: 100%;
    height: 100%;
    outline: none;
}

/* Vis.js manipulation UI styling to fit dark theme */
div.vis-network div.vis-manipulation {
    background: rgba(30, 41, 59, 0.9) !important;
    border-bottom: 1px solid var(--panel-border) !important;
    padding: 10px !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

div.vis-network div.vis-manipulation .vis-button {
    font-family: 'Inter', sans-serif !important;
    border-radius: 8px !important;
    margin: 0 5px !important;
    transition: all 0.2s !important;
    color: white !important;
}

div.vis-network div.vis-manipulation .vis-button:hover {
    background: rgba(59, 130, 246, 0.3) !important;
    box-shadow: none !important;
}
