/* ============================================================================
   styles.css — Automotive-Inspired Dark Theme (Multi-Algorithm Edition)
   ============================================================================ */

/* ── Reset & Root Variables ──────────────────────────────────────────────── */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary:    #0d1117;
    --bg-secondary:  #161b22;
    --bg-card:       #1c2128;
    --bg-hover:      #252c35;
    --border:        #30363d;
    --text-primary:  #e6edf3;
    --text-secondary:#8b949e;
    --accent:        #00e5ff;
    --accent-dim:    rgba(0, 229, 255, 0.15);
    --green:         #00e676;
    --red:           #ff1744;
    --blue:          #448aff;
    --orange:        #ff9100;
    --purple:        #e040fb;
    --sidebar-width: 420px;
    --radius:        10px;
    --radius-sm:     6px;
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3 { font-weight: 700; letter-spacing: 0.02em; }

code {
    font-family: 'Fira Code', 'Cascadia Code', Consolas, monospace;
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--accent);
}

/* ── Utility ─────────────────────────────────────────────────────────────── */

.hidden { display: none !important; }
.accent { color: var(--accent); }
.fade-in { animation: fadeIn 0.35s ease-out; }

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

/* ── Header ──────────────────────────────────────────────────────────────── */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header__brand { display: flex; align-items: center; gap: 10px; }
.header__icon  { font-size: 1.6rem; }

.header__title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.header__subtitle {
    color: var(--text-secondary);
    font-size: 0.78rem;
    margin-left: 4px;
    border-left: 1px solid var(--border);
    padding-left: 10px;
}

.header__badge {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* ── Main Layout ─────────────────────────────────────────────────────────── */

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

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Panels ──────────────────────────────────────────────────────────────── */

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.panel__heading {
    font-size: 1rem;
    margin-bottom: 16px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Form ────────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 14px; }

.form-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.label-icon { font-size: 0.7rem; }

.select-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.92rem;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' 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 12px center;
    padding-right: 36px;
}

.select-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.select-input option {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn-row { display: flex; gap: 8px; margin-top: 4px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn--primary {
    flex: 1;
    background: var(--accent);
    color: var(--bg-primary);
}
.btn--primary:hover {
    background: #33ecff;
    box-shadow: 0 0 16px var(--accent-dim);
}
.btn--primary:active { transform: scale(0.97); }

.btn--secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 10px 14px;
    font-size: 1.1rem;
}
.btn--secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 10px 14px;
    font-size: 1rem;
}
.btn--ghost:hover { color: var(--red); }

.btn--compare {
    flex: 1;
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn--compare:hover {
    border-color: var(--purple);
    color: var(--purple);
    box-shadow: 0 0 12px rgba(224, 64, 251, 0.15);
}

.btn-icon { font-size: 1rem; }

/* ── Algorithm Selector ──────────────────────────────────────────────────── */

.algo-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.algo-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.algo-option:hover {
    border-color: var(--text-secondary);
    background: var(--bg-hover);
}

.algo-option.selected {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.algo-option input[type="radio"] {
    display: none;
}

.algo-radio {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s;
}

.algo-option.selected .algo-radio {
    border-color: var(--accent);
}

.algo-radio-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
    transition: background 0.2s;
}

.algo-option.selected .algo-radio-dot {
    background: var(--accent);
}

.algo-option-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.algo-option-info {
    flex: 1;
    min-width: 0;
}

.algo-option-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.algo-option-complexity {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-family: 'Fira Code', monospace;
}

.algo-badges {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.algo-badge {
    font-size: 0.62rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.algo-badge--weighted { background: rgba(0, 229, 255, 0.15); color: var(--accent); }
.algo-badge--unweighted { background: rgba(68, 138, 255, 0.15); color: var(--blue); }
.algo-badge--heuristic { background: rgba(0, 230, 118, 0.15); color: var(--green); }
.algo-badge--allpairs { background: rgba(224, 64, 251, 0.15); color: var(--purple); }
.algo-badge--negweights { background: rgba(255, 145, 0, 0.15); color: var(--orange); }

/* Algorithm detail tooltip */
.algo-detail {
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    min-height: 42px;
}

/* ── Error Panel ─────────────────────────────────────────────────────────── */

.error-panel {
    border-color: var(--red);
    background: rgba(255, 23, 68, 0.08);
}

.error-content { display: flex; align-items: flex-start; gap: 10px; }
.error-icon    { font-size: 1.3rem; flex-shrink: 0; }
.error-content p { color: #ff6b6b; font-size: 0.9rem; line-height: 1.5; }

/* ── Welcome Panel ───────────────────────────────────────────────────────── */

.welcome-panel h3 { color: var(--accent); margin-bottom: 8px; font-size: 1rem; }

.welcome-panel p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.6;
    margin-bottom: 14px;
}

.welcome-features { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.feature {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.feature span:first-child { font-size: 1rem; }

/* ── Result Panel ────────────────────────────────────────────────────────── */

.result-algo-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    flex-wrap: wrap;
}

.result-algo-name {
    font-weight: 700;
    font-size: 0.92rem;
}

.result-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.summary-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    text-align: center;
}

.summary-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 3px;
}

.summary-value {
    display: block;
    font-family: 'Orbitron', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
}

/* Algo note */
.algo-note {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    border-left: 3px solid var(--accent);
}
.algo-note:empty { display: none; }

/* ── Route Steps ─────────────────────────────────────────────────────────── */

.route-list { max-height: 300px; overflow-y: auto; padding-right: 4px; }

.route-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.route-step--start { border-color: var(--green); background: rgba(0, 230, 118, 0.06); }
.route-step--end   { border-color: var(--red);   background: rgba(255, 23, 68, 0.06); }

.step-icon { font-size: 0.9rem; flex-shrink: 0; }
.step-info { display: flex; flex-direction: column; }

.step-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.step-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
}

.route-connector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 4px 20px;
}

.connector-line {
    width: 2px;
    height: 18px;
    background: var(--accent);
    opacity: 0.4;
    border-radius: 1px;
}

.connector-distance {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    opacity: 0.7;
}

/* ── Comparison Panel ────────────────────────────────────────────────────── */

.comparison-table-wrap { overflow-x: auto; margin-bottom: 12px; }

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.comparison-table th {
    text-align: left;
    padding: 8px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.comparison-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

.comparison-table tbody tr {
    transition: background 0.15s;
    cursor: pointer;
}

.comparison-table tbody tr:hover {
    background: var(--bg-hover);
}

.comparison-table tbody tr.best-row {
    background: var(--accent-dim);
}

.cmp-algo-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    white-space: nowrap;
}

.cmp-algo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cmp-value { font-family: 'Orbitron', monospace; font-size: 0.82rem; }
.cmp-optimal { color: var(--green); }
.cmp-suboptimal { color: var(--orange); }
.cmp-na { color: var(--text-secondary); font-style: italic; }

.comparison-notes {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.6;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.comparison-notes:empty { display: none; }

.comparison-insight {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}
.comparison-insight:last-child { margin-bottom: 0; }

.insight-icon { flex-shrink: 0; font-size: 0.9rem; }

/* ── Map Canvas ──────────────────────────────────────────────────────────── */

.map-container {
    flex: 1;
    position: relative;
    background:
        radial-gradient(circle at 50% 50%, rgba(0, 229, 255, 0.03), transparent 70%),
        var(--bg-primary);
    overflow: hidden;
}

#map-canvas { width: 100%; height: 100%; display: block; }

.map-legend {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    gap: 16px;
    background: rgba(22, 27, 34, 0.9);
    backdrop-filter: blur(8px);
    padding: 10px 18px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot--start { background: var(--green); }
.dot--end   { background: var(--red);   }
.dot--via   { background: var(--accent); }

.line { width: 18px; height: 3px; border-radius: 2px; }
.line--route { background: var(--accent); }

/* ── Footer ──────────────────────────────────────────────────────────────── */

.footer {
    text-align: center;
    padding: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 960px) {
    .app { flex-direction: column; }

    .sidebar {
        width: 100%;
        min-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 55vh;
    }

    .map-container { min-height: 45vh; }
    .header__subtitle { display: none; }
    .map-legend { bottom: 8px; right: 8px; gap: 10px; padding: 6px 12px; }
}

@media (max-width: 500px) {
    .header { padding: 10px 16px; }
    .header__title { font-size: 1.1rem; }
    .header__badge { display: none; }
    .sidebar { padding: 14px; }
    .result-summary { grid-template-columns: 1fr 1fr; }
    .welcome-features { grid-template-columns: 1fr; }
    .map-legend { flex-wrap: wrap; gap: 6px; font-size: 0.68rem; }
    .comparison-table { font-size: 0.72rem; }
}
