/* =========================================
   DESIGN SYSTEM & VARIABLES
========================================= */
:root {
    --bg-primary: #070b13;
    --bg-secondary: #0d1527;
    --card-bg: rgba(15, 23, 42, 0.45);
    --card-bg-hover: rgba(20, 30, 55, 0.6);
    --card-border: rgba(255, 255, 255, 0.07);
    --card-border-active: rgba(99, 102, 241, 0.4);
    
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #64748b;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --gradient-accent: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-compare: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    --gradient-card: linear-gradient(145deg, rgba(20, 28, 47, 0.4) 0%, rgba(10, 15, 28, 0.4) 100%);
    
    /* Colors */
    --indigo: #6366f1;
    --cyan: #06b6d4;
    --emerald: #10b981;
    --amber: #f59e0b;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.5);
    --glow-indigo: 0 0 15px rgba(99, 102, 241, 0.3);
    --glow-emerald: 0 0 15px rgba(16, 185, 129, 0.3);
    
    /* Curves */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    /* Transitions */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================
   BASE STYLES
========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.1) 0px, transparent 50%),
        radial-gradient(at 50% 50%, rgba(15, 23, 42, 0.5) 0px, transparent 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    padding: 24px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(7, 11, 19, 0.5);
}
::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.2);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.4);
}

/* =========================================
   LAYOUT UTILITIES
========================================= */
.app-container {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.glass-card {
    background: var(--gradient-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: var(--transition-smooth);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow-lg);
}

/* =========================================
   HEADER STYLING
========================================= */
.glass-header {
    background: rgba(13, 21, 39, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 16px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: var(--glow-indigo);
    color: white;
}

.logo-text h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 30%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text p {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 400;
}

/* Status Indicator */
.header-status {
    display: flex;
    align-items: center;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.status-indicator.idle {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
    border-color: rgba(148, 163, 184, 0.2);
}

.status-indicator.running {
    background: rgba(16, 185, 129, 0.1);
    color: var(--emerald);
    border-color: rgba(16, 185, 129, 0.2);
    box-shadow: var(--glow-emerald);
}

.status-indicator.comparing {
    background: rgba(245, 158, 11, 0.1);
    color: var(--amber);
    border-color: rgba(245, 158, 11, 0.2);
}

.status-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
    display: inline-block;
}

.status-indicator.running .status-pulse {
    animation: status-glowing 1.5s infinite ease-in-out;
}

/* =========================================
   DASHBOARD GRID LAYOUT
========================================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    align-items: start;
}

/* =========================================
   SIDEBAR (CONTROLS)
========================================= */
.controls-sidebar {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-title i {
    color: var(--indigo);
    font-size: 18px;
}

.sidebar-title h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 700;
}

/* Form Groups */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tooltip {
    cursor: help;
    color: var(--text-dark);
    transition: var(--transition-fast);
}

.tooltip:hover {
    color: var(--text-muted);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i {
    position: absolute;
    left: 14px;
    color: var(--text-dark);
    font-size: 14px;
    pointer-events: none;
    transition: var(--transition-fast);
}

.input-with-icon input,
.input-with-icon select {
    padding-left: 40px !important;
}

.control-group input,
.control-group select {
    width: 100%;
    padding: 11px 14px;
    background: rgba(7, 11, 19, 0.6);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    color: white;
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition-fast);
}

.control-group input:focus,
.control-group select:focus {
    outline: none;
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: rgba(7, 11, 19, 0.8);
}

.control-group input:focus + i,
.control-group select:focus + i {
    color: var(--indigo);
}

/* Parameter Cards */
.parameter-card {
    background: rgba(7, 11, 19, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: fade-in-panel 0.3s ease-out;
}

.param-card-title {
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.param-card-title i {
    color: var(--indigo);
}

/* Button Group */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.btn {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: none;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.btn i {
    font-size: 14px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--glow-indigo);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn-outline:active {
    transform: translateY(0);
}

.btn-accent {
    background: var(--gradient-accent);
    color: white;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.2);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.35);
}

.btn-accent:active {
    transform: translateY(0);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.btn-danger:hover {
    background: var(--gradient-danger);
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3);
}

.btn-danger:active {
    transform: translateY(0);
}

/* Button Loading/Running States */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* =========================================
   MAIN WORKSPACE
========================================= */
.main-workspace {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Visualizer Canvas Card */
.canvas-card {
    padding: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header-title i {
    color: var(--indigo);
    font-size: 16px;
}

.card-header-title h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 700;
}

.badge {
    background: rgba(99, 102, 241, 0.1);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.canvas-container {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #090e18;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#routeCanvas {
    width: 100%;
    height: 520px;
    display: block;
    cursor: crosshair;
}

/* Canvas HUD Accents */
.canvas-hud-corners {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

.hud-corner {
    position: absolute;
    width: 12px;
    height: 12px;
    border-color: rgba(99, 102, 241, 0.4);
    border-style: solid;
}

.hud-corner.top-left {
    top: 12px;
    left: 12px;
    border-width: 2px 0 0 2px;
}
.hud-corner.top-right {
    top: 12px;
    right: 12px;
    border-width: 2px 2px 0 0;
}
.hud-corner.bottom-left {
    bottom: 12px;
    left: 12px;
    border-width: 0 0 2px 2px;
}
.hud-corner.bottom-right {
    bottom: 12px;
    right: 12px;
    border-width: 0 2px 2px 0;
}

/* =========================================
   REAL-TIME METRICS GRID
========================================= */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.metric-card {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.metric-card:hover {
    border-color: var(--card-border-active);
    transform: translateY(-2px);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.metric-icon.distance {
    background: rgba(99, 102, 241, 0.1);
    color: var(--indigo);
}

.metric-icon.iterations {
    background: rgba(6, 182, 212, 0.1);
    color: var(--cyan);
}

.metric-icon.time {
    background: rgba(16, 185, 129, 0.1);
    color: var(--emerald);
}

.metric-info h3 {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.metric-info p {
    font-family: 'Outfit', sans-serif;
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
}

.metric-info .unit {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

/* =========================================
   BOTTOM GRID: TABLE & CHART
========================================= */
.bottom-split-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 20px;
    align-items: start;
}

/* Benchmark Card & Table */
#benchmarkSection {
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.tableWrapper {
    flex: 1;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(7, 11, 19, 0.2);
}

#benchmarkTable {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

#benchmarkTable th,
#benchmarkTable td {
    padding: 14px 16px;
    font-size: 14px;
}

#benchmarkTable th {
    background: rgba(13, 21, 39, 0.6);
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#benchmarkTable td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

#benchmarkTable tbody tr {
    transition: var(--transition-fast);
}

#benchmarkTable tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Algorithm Row Badge Names */
.alg-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.alg-badge.hill-climbing {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.25);
}

.alg-badge.simulated-annealing {
    background: rgba(245, 158, 11, 0.15);
    color: #fde047;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.alg-badge.genetic-algorithm {
    background: rgba(6, 182, 212, 0.15);
    color: #67e8f9;
    border: 1px solid rgba(6, 182, 212, 0.25);
}

.winner-row {
    background: rgba(16, 185, 129, 0.04) !important;
}

.winner-row td {
    border-bottom: 1px solid rgba(16, 185, 129, 0.15) !important;
}

/* Convergence Chart Card */
#chartSection {
    padding: 24px;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* =========================================
   KEYFRAMES AND ANIMATIONS
========================================= */
@keyframes status-glowing {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes fade-in-panel {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================
   RESPONSIVE DESIGN (MEDIA QUERIES)
========================================= */
@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .controls-sidebar {
        position: static;
    }
}

@media (max-width: 768px) {
    body {
        padding: 12px;
    }
    
    .glass-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding: 20px;
    }
    
    .header-status {
        align-self: flex-end;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .bottom-split-grid {
        grid-template-columns: 1fr;
    }
    
    #routeCanvas {
        height: 380px;
    }
}