/* css/main.css */

/* Design Tokens */
:root {
    --bg: #0a0a0a;
    --surface: #111111;
    --surface-hover: #1a1a1a;
    --border: #242424;
    --text: #e8e8e8;
    --text-muted: #5a5a5a;
    --green: #00e676;
    --red: #ff1744;
    --white: #ffffff;
    --font-sans: 'Montserrat', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
    --transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 13px;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font-sans);
    font-weight: 700;
}

b, strong {
    font-weight: 700;
}

.font-mono {
    font-family: var(--font-mono);
}

.highlight-white { color: var(--white); }
.highlight-green { color: var(--green); font-weight: 600; }
.highlight-red { color: var(--red); font-weight: 600; }
.text-red { color: var(--red); }
.text-muted { color: var(--text-muted); }

/* Buttons */
.btn {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 13px;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background-color: var(--white);
    color: var(--bg);
}

.btn-primary:hover {
    background-color: #cccccc;
    box-shadow: 0 0 15px rgba(255,255,255,0.2);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    border-color: var(--text-muted);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    background: var(--surface);
    border-color: var(--text-muted);
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
}
.btn-text:hover { color: var(--white); }

/* Intro Overlay */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.overlay-content {
    max-width: 600px;
    text-align: center;
    position: relative;
    width: 100%;
    margin: 0 20px;
}

.intro-slide {
    display: none;
    animation: fadeInSlideUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.intro-slide.active {
    display: block;
}

@keyframes fadeInSlideUp {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

.intro-slide h1 {
    font-size: 48px;
    letter-spacing: 4px;
    margin-bottom: 10px;
    font-weight: 800;
}

.intro-slide h2 {
    font-size: 32px;
    margin-bottom: 24px;
    font-weight: 700;
}

.intro-slide .subtitle {
    font-size: 18px;
    color: var(--text-muted);
    margin-bottom: 30px;
    letter-spacing: 1px;
}

.intro-slide .description {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 40px;
    color: #aaaaaa;
}

.concept-visual {
    height: 150px;
    margin: 0 auto 30px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.anim-node {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--white);
    position: absolute;
    box-shadow: 0 0 10px rgba(255,255,255,0.5);
}

.anim-node.core { z-index: 2; }
.anim-node.end { transform: translateX(80px); background: var(--red); box-shadow: 0 0 15px rgba(255,23,68,0.5);}

.anim-ring {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--white);
    border-radius: 50%;
    animation: ripple 2s infinite ease-out;
}

@keyframes ripple {
    0% { width: 20px; height: 20px; opacity: 1; }
    100% { width: 150px; height: 150px; opacity: 0; }
}

.anim-path {
    position: absolute;
    height: 2px;
    width: 0;
    background: var(--white);
    left: 50%;
    margin-left: -40px;
    animation: drawPath 2s infinite ease-in-out;
}

@keyframes drawPath {
    0% { width: 0; transform: translateX(0); }
    50% { width: 80px; transform: translateX(0); }
    100% { width: 0; transform: translateX(80px); }
}

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

.algo-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: 8px;
    text-align: left;
}

.algo-card h3 {
    margin-bottom: 10px;
    font-size: 16px;
    color: var(--white);
}

.algo-card p {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}

.btn-group {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* App Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.app-container.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.top-bar {
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

.brand {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 2px;
}

.global-actions {
    display: flex;
    gap: 10px;
}

.app-stats {
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.github-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
    margin-left: 16px;
}

.github-link:hover {
    color: var(--text);
    transform: scale(1.1);
}

.layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.panel {
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.left-panel { width: 220px; border-right: 1px solid var(--border); }
.right-panel { width: 280px; border-left: 1px solid var(--border); border-right: none; }

.canvas-container {
    flex: 1;
    position: relative;
    background: var(--bg);
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.control-group {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.control-group h3 {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 15px;
}

/* Radio List */
.radio-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: color 0.2s;
}

.radio-item:hover { color: var(--white); }

.radio-item input[type="radio"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--border);
    border-radius: 50%;
    margin-right: 10px;
    outline: none;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
}

.radio-item input[type="radio"]:checked {
    border-color: var(--white);
}

.radio-item input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 8px; height: 8px;
    background: var(--white);
    border-radius: 50%;
}

/* Dropdown */
.dropdown {
    width: 100%;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

.dropdown:focus { border-color: var(--text-muted); }

/* Slider */
.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.speed-label {
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-size: 11px;
}

input[type="range"] {
    flex: 1;
    appearance: none;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--white);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Legend */
.legend-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-list li {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
}

.color-box {
    width: 12px; height: 12px;
    border-radius: 2px;
    margin-right: 10px;
    display: inline-block;
}

.instructions {
    padding: 20px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Metrics */
.metrics-grid {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.metric-box {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.metric-value {
    font-size: 18px;
    color: var(--white);
    margin-bottom: 4px;
}

.metric-label {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.path-string {
    font-size: 12px;
    color: var(--green);
    background: var(--surface);
    padding: 10px;
    border-radius: 4px;
    text-align: center;
    word-break: break-all;
}

/* Route Table */
.route-table-section { flex: 1; display: flex; flex-direction: column; }
.route-table-section h3 { display: flex; justify-content: space-between; }
.selected-node-id { color: var(--white); font-family: var(--font-mono); }

.table-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    text-align: left;
}

th, td {
    padding: 8px 10px;
    font-size: 11px;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 10;
}

td { color: var(--text); }

/* Log */
.log-section { height: 250px; display: flex; flex-direction: column; }
.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.log-header h3 { margin-bottom: 0; }

.log-container {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-entry { display: flex; gap: 8px; }
.log-time { color: var(--text-muted); }
.log-msg { color: var(--text); flex: 1; }
.log-msg.algo { color: var(--white); font-weight: 600; }
.log-msg.success { color: var(--green); }
.log-msg.error { color: var(--red); }

/* Context Menu */
.context-menu {
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 5px 0;
    min-width: 160px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 100;
}

.context-menu.hidden { display: none; }

.context-menu ul { list-style: none; }
.context-menu li {
    padding: 8px 15px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.context-menu li:hover { background: var(--border); }

/* Mobile Responsive Design */
@media (max-width: 1280px) {
    .left-panel { width: 180px; }
    .right-panel { width: 200px; }
    .top-bar { padding: 0 12px; }
    .brand { font-size: 16px; }
    .btn-sm { padding: 5px 10px; font-size: 10px; }
    .control-group { padding: 15px; }
    .control-group h3 { font-size: 10px; }
}

@media (max-width: 900px) {
    .left-panel { width: 150px; }
    .right-panel { width: 150px; }
    .global-actions { gap: 5px; }
    .btn-sm { padding: 4px 8px; font-size: 9px; }
    table th, table td { padding: 6px 8px; font-size: 10px; }
    .metric-value { font-size: 16px; }
    .app-stats { font-size: 11px; }
    .instructions { padding: 15px; font-size: 11px; }
}

@media (max-width: 768px) {
    /* Hide panels on tablet/mobile */
    .left-panel { 
        display: none;
        position: fixed;
        left: 0;
        top: 50px;
        width: 100%;
        max-height: calc(100vh - 50px);
        border-right: none;
        border-bottom: 1px solid var(--border);
        z-index: 999;
        overflow-y: auto;
        overflow-x: hidden;
        background: var(--bg);
    }
    
    .left-panel.mobile-open { display: flex; }
    
    .right-panel { 
        display: none;
        position: fixed;
        right: 0;
        top: 50px;
        width: 100%;
        max-height: calc(100vh - 50px);
        border-left: none;
        border-bottom: 1px solid var(--border);
        z-index: 999;
        overflow-y: auto;
        overflow-x: hidden;
        background: var(--bg);
    }
    
    .right-panel.mobile-open { display: flex; }
    
    .layout { flex-direction: column; }
    .canvas-container { flex: 1; }
    
    .top-bar { 
        flex-wrap: nowrap;
        height: 50px;
        padding: 3px 3px;
        gap: 3px;
        align-items: center;
        justify-content: flex-start;
        overflow-x: visible;
    }
    
    .brand { 
        font-size: 13px;
        letter-spacing: 1px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .global-actions { 
        display: flex;
        gap: 3px;
        flex-shrink: 0;
    }
    
    .btn-sm { 
        padding: 6px 8px; 
        font-size: 10px;
        white-space: nowrap;
        letter-spacing: 0px;
        min-width: 32px;
        text-align: center;
        min-height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .app-stats { 
        font-size: 8px;
        white-space: nowrap;
        flex-shrink: 0;
        margin-left: auto;
        display: none;
    }
    
    .btn-panel-toggle {
        background: transparent;
        border: 1px solid var(--border);
        color: var(--text);
        padding: 6px 8px;
        font-size: 10px;
        text-transform: uppercase;
        font-weight: 600;
        cursor: pointer;
        transition: var(--transition);
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .btn-panel-toggle:hover {
        background: var(--surface);
        border-color: var(--text-muted);
    }
    
    .github-link { 
        width: 18px; 
        height: 18px; 
        margin-left: 4px;
        flex-shrink: 0;
    }
    
    .control-group { padding: 12px; }
    .control-group h3 { font-size: 9px; margin-bottom: 12px; }
    
    .metrics-grid { gap: 8px; }
    .metric-value { font-size: 14px; }
    .metric-label { font-size: 9px; }
    
    table th, table td { padding: 5px 6px; font-size: 9px; }
    .log-section { height: 150px; }
    .log-container { font-size: 9px; }
    
    /* Touch improvements */
    canvas { touch-action: none; -webkit-touch-callout: none; }
    button, input { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
    button:active, button:focus-visible { background-color: var(--surface-hover) !important; outline: 2px solid var(--white); outline-offset: 2px; }
}

@media (max-width: 480px) {
    body { font-size: 12px; }
    
    .top-bar { 
        padding: 3px 3px;
        gap: 2px;
        height: 46px;
        flex-wrap: nowrap;
        overflow-x: visible;
    }
    
    .brand { 
        font-size: 12px;
        letter-spacing: 0.5px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .global-actions { 
        display: flex;
        gap: 2px;
        flex-shrink: 0;
    }
    
    .btn-sm { 
        padding: 5px 6px; 
        font-size: 9px;
        letter-spacing: 0px;
        min-width: 28px;
        min-height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .btn-panel-toggle { 
        padding: 5px 6px; 
        font-size: 9px;
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .github-link { 
        width: 18px; 
        height: 18px; 
        margin-left: 3px;
        flex-shrink: 0;
    }
    
    .app-stats { display: none; }
    
    .left-panel { 
        top: 50px;
        max-height: calc(100vh - 50px);
    }
    
    .right-panel { 
        top: 50px; 
        max-height: calc(100vh - 50px);
    }
    
    .control-group { padding: 14px; margin-bottom: 0; border-bottom: 1px solid var(--border); }
    .control-group h3 { font-size: 10px; margin-bottom: 12px; }
    
    .radio-item { font-size: 12px; }
    .dropdown { font-size: 11px; }
    
    .intro-slide h1 { font-size: 32px; }
    .intro-slide h2 { font-size: 24px; }
    .intro-slide .subtitle { font-size: 14px; }
    .intro-slide .description { font-size: 13px; }
    
    .metrics-grid { gap: 6px; }
    .metric-box { padding: 8px; }
    .metric-value { font-size: 16px; }
    .metric-label { font-size: 8px; }
    
    .path-string { font-size: 10px; padding: 8px; }
    
    table th, table td { padding: 4px 5px; font-size: 8px; }
    .log-container { font-size: 8px; padding: 8px; }
    .log-entry { gap: 4px; }
    
    .context-menu { min-width: 120px; }
    .context-menu li { padding: 6px 10px; font-size: 11px; }
}
