/* Evolving Vehicles - Styles */
/* Dark theme with green (#22c55e) accents */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #1e1e1e;
    color: #e0e0e0;
    min-height: 100vh;
    overflow: hidden;
    user-select: none;
}

/* Header */
header {
    height: 50px;
    background: #22c55e;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    color: white;
}

.subtitle {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
}

.header-right {
    display: flex;
    gap: 10px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: transparent;
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: white;
}

/* Main Container */
.main-container {
    display: flex;
    height: calc(100vh - 50px);
    margin-top: 50px;
}

/* Controls Panel */
.controls-panel {
    width: 300px;
    background: #252526;
    border-right: 1px solid #3c3c3c;
    overflow-y: auto;
    flex-shrink: 0;
    padding: 15px;
}

.control-section {
    background: #2d2d2d;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.control-section.collapsed .section-content {
    display: none;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.section-header:hover {
    background: #363636;
}

.section-header h3 {
    font-size: 0.95rem;
    font-weight: 500;
    color: #e0e0e0;
}

.section-toggle {
    font-size: 0.7rem;
    color: #888;
    transition: transform 0.2s;
}

.control-section.collapsed .section-toggle {
    transform: rotate(-90deg);
}

.section-content {
    padding: 12px 16px;
    padding-top: 0;
}

/* Control Groups */
.control-group {
    margin-bottom: 12px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    display: block;
    font-size: 0.85rem;
    color: #aaa;
    margin-bottom: 6px;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-row input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #3c3c3c;
    -webkit-appearance: none;
    appearance: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #22c55e;
    cursor: pointer;
    border: none;
}

.slider-row input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #22c55e;
    cursor: pointer;
    border: none;
}

.value-display {
    min-width: 40px;
    text-align: right;
    font-size: 0.85rem;
    color: #22c55e;
    font-weight: 500;
}

/* Buttons */
.button-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.control-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #3c3c3c;
    border-radius: 6px;
    background: #2d2d2d;
    color: #e0e0e0;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.control-btn:hover:not(:disabled) {
    background: #3c3c3c;
    border-color: #22c55e;
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.control-btn.primary {
    background: #22c55e;
    border-color: #22c55e;
    color: white;
}

.control-btn.primary:hover:not(:disabled) {
    background: #16a34a;
}

.btn-icon {
    font-size: 0.75rem;
}

/* Speed Buttons */
.speed-buttons {
    display: flex;
    gap: 4px;
}

.speed-btn {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    background: #2d2d2d;
    color: #aaa;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.speed-btn:hover {
    background: #3c3c3c;
}

.speed-btn.active {
    background: #22c55e;
    border-color: #22c55e;
    color: white;
}

/* Run Mode Buttons */
.run-mode-buttons {
    display: flex;
    gap: 4px;
}

.run-mode-btn {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    background: #2d2d2d;
    color: #aaa;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.run-mode-btn:hover {
    background: #3c3c3c;
}

.run-mode-btn.active {
    background: #22c55e;
    border-color: #22c55e;
    color: white;
}

/* Vehicle Progress */
.vehicle-progress {
    font-size: 1.2rem;
    font-weight: 600;
    color: #22c55e;
    margin-bottom: 8px;
}

.progress-bar {
    height: 6px;
    background: #3c3c3c;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #22c55e;
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Terrain Grid */
.terrain-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.terrain-btn {
    padding: 10px;
    border: 1px solid #3c3c3c;
    border-radius: 6px;
    background: #2d2d2d;
    color: #e0e0e0;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.terrain-btn:hover {
    background: #3c3c3c;
    border-color: #22c55e;
}

.terrain-btn.active {
    background: #22c55e;
    border-color: #22c55e;
    color: white;
}

/* Physics Controls */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #22c55e;
}

.control-hint {
    font-size: 0.75rem;
    color: #888;
    margin-top: 4px;
    margin-bottom: 0;
}

.gravity-presets {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.gravity-preset-btn {
    flex: 1;
    min-width: 60px;
    padding: 6px 8px;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    background: #2d2d2d;
    color: #aaa;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.gravity-preset-btn:hover {
    background: #3c3c3c;
    border-color: #22c55e;
}

.gravity-preset-btn.active {
    background: #22c55e;
    border-color: #22c55e;
    color: white;
}

.gravity-preset-btn.gravity-extreme {
    border-color: #ef4444;
    color: #ef4444;
}

.gravity-preset-btn.gravity-extreme:hover {
    background: #ef4444;
    color: white;
}

.gravity-preset-btn.gravity-extreme.active {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}

/* Radio Group */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #e0e0e0;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: #22c55e;
    cursor: pointer;
}

.mode-description {
    font-size: 0.8rem;
    color: #888;
    font-style: italic;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.stat-item {
    background: #252526;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: #888;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e0e0e0;
}

.stat-value.highlight {
    color: #22c55e;
}

/* Viewer Panel */
.viewer-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #1e1e1e;
}

/* Terrain Container */
.terrain-container {
    flex: 1;
    position: relative;
    min-height: 250px;
    background: #1a1a2e;
}

#mainCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 10;
}

.canvas-overlay.hidden {
    display: none;
}

.overlay-content h2 {
    font-size: 2rem;
    color: #22c55e;
    margin-bottom: 15px;
}

.overlay-content p {
    font-size: 1rem;
    color: #aaa;
    margin-bottom: 10px;
    max-width: 450px;
}

.overlay-content .instruction {
    color: #e0e0e0;
    margin-top: 20px;
}

.vehicle-status {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #22c55e;
    font-weight: 500;
}

.status-separator {
    color: #666;
    margin: 0 8px;
}

#statusGeneration {
    color: #f59e0b;
    font-weight: 600;
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #3c3c3c;
    border-radius: 6px;
    padding: 4px 8px;
}

.zoom-btn {
    width: 28px;
    height: 28px;
    background: #2d2d2d;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.zoom-btn:hover {
    background: rgba(34, 197, 94, 0.3);
    border-color: #22c55e;
}

.zoom-level {
    color: #888;
    font-size: 0.8rem;
    min-width: 20px;
    text-align: center;
}

/* Bottom Panels */
.bottom-panels {
    display: flex;
    height: 180px;
    border-top: 1px solid #3c3c3c;
}

.viz-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #252526;
    overflow: hidden;
    border-right: 1px solid #3c3c3c;
}

.viz-panel:last-child {
    border-right: none;
}

.viz-header {
    padding: 8px 12px;
    background: #2d2d2d;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 500;
    border-bottom: 1px solid #3c3c3c;
}

.viz-subtitle {
    font-size: 0.75rem;
    color: #888;
    font-weight: normal;
}

/* Genome Panel */
.genome-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.genome-diagram {
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#genomeCanvas {
    width: 180px;
    height: 110px;
}

.genome-stats {
    flex: 1;
    padding: 8px 10px;
    overflow-y: auto;
    min-width: 0;
}

.gene-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid #3c3c3c;
    font-size: 0.8rem;
}

.gene-row:last-child {
    border-bottom: none;
}

.gene-label {
    color: #aaa;
}

.gene-value {
    color: #22c55e;
    font-weight: 500;
}

/* Results Panel */
.results-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: #2d2d2d;
    border-radius: 4px;
    font-size: 0.8rem;
}

.result-item.current {
    background: #22c55e;
    color: white;
}

.result-item.best {
    border: 1px solid #22c55e;
}

.result-rank {
    font-weight: 600;
    min-width: 30px;
}

.result-speed {
    color: #888;
    font-size: 0.75rem;
}

.result-distance {
    color: #22c55e;
    min-width: 40px;
    text-align: right;
}

.result-item.current .result-distance,
.result-item.current .result-speed {
    color: white;
}

/* Graph Panel */
.graph-panel {
    min-width: 200px;
}

#graphCanvas {
    flex: 1;
    width: 100%;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #252526;
    border-radius: 12px;
    max-width: 500px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.selection-modal {
    max-width: 800px;
    width: 90%;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #22c55e;
    color: white;
    flex-wrap: wrap;
    gap: 5px;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
    width: 100%;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    opacity: 0.8;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(85vh - 120px);
}

.modal-footer {
    padding: 15px 20px;
    background: #2d2d2d;
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* Confirm Remove Modal */
.confirm-modal {
    max-width: 350px;
}

.confirm-modal .modal-body {
    text-align: center;
}

.confirm-subtitle {
    color: #888;
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Stats Modal */
.stats-modal {
    max-width: 500px;
}

.stats-modal .modal-body {
    padding: 15px;
}

/* Result item hover for clickable alive vehicles */
.result-item.clickable {
    cursor: pointer;
}

.result-item.clickable:hover {
    background: #3c3c3c;
}

.result-item.current.clickable:hover {
    background: #1da34d;
}

/* Selection Grid */
.selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.selection-card {
    background: #2d2d2d;
    border: 2px solid #3c3c3c;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.selection-card:hover {
    border-color: #22c55e;
}

.selection-card.selected {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.selection-card canvas {
    width: 100%;
    height: 80px;
    margin-bottom: 8px;
}

.selection-card .card-distance {
    font-size: 1rem;
    font-weight: 600;
    color: #22c55e;
}

.selection-card .card-rank {
    font-size: 0.8rem;
    color: #888;
}

.selection-info {
    text-align: center;
    font-size: 0.9rem;
    color: #aaa;
}

/* Help Section */
.help-section {
    margin-bottom: 20px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    font-size: 0.95rem;
    color: #22c55e;
    margin-bottom: 8px;
}

.help-section p {
    font-size: 0.85rem;
    color: #ccc;
    line-height: 1.5;
    margin-bottom: 6px;
}

.help-section ul {
    margin-left: 20px;
    margin-top: 8px;
}

.help-section li {
    font-size: 0.85rem;
    color: #ccc;
    line-height: 1.6;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1e1e1e;
}

::-webkit-scrollbar-thumb {
    background: #3c3c3c;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

/* Breeding Modal */
.breeding-modal {
    max-width: 650px;
    width: 95%;
}

.breeding-nav-info {
    font-size: 0.9rem;
    opacity: 0.9;
}

.breeding-body {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 10px;
}

.breeding-nav-btn {
    background: #3c3c3c;
    border: none;
    color: #e0e0e0;
    font-size: 1.5rem;
    width: 40px;
    height: 80px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.breeding-nav-btn:hover:not(:disabled) {
    background: #22c55e;
    color: white;
}

.breeding-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.breeding-content {
    flex: 1;
    text-align: center;
}

.breeding-elite-badge {
    display: none;
    background: #f59e0b;
    color: #000;
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.breeding-elite-badge.show {
    display: inline-block;
}

.breeding-parents {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.breeding-parent {
    background: #2d2d2d;
    border: 2px solid #3c3c3c;
    border-radius: 8px;
    padding: 10px;
    min-width: 120px;
}

.breeding-parent.parent1 {
    border-color: #3b82f6;
}

.breeding-parent.parent2 {
    border-color: #ef4444;
}

.parent-header {
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 5px;
}

#parent1Card .parent-header {
    color: #3b82f6;
}

#parent2Card .parent-header {
    color: #ef4444;
}

.parent-distance {
    font-size: 0.85rem;
    color: #22c55e;
    margin-top: 5px;
}

.breeding-plus {
    font-size: 1.5rem;
    color: #666;
}

.breeding-arrow {
    font-size: 1.5rem;
    color: #22c55e;
    margin: 8px 0;
}

.breeding-offspring {
    background: #2d2d2d;
    border: 2px solid #22c55e;
    border-radius: 8px;
    padding: 10px 15px;
    display: inline-block;
    margin-bottom: 15px;
}

.offspring-header {
    font-size: 0.85rem;
    color: #22c55e;
    margin-bottom: 5px;
}

.breeding-genes {
    max-height: 200px;
    overflow-y: auto;
}

.gene-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.gene-table th,
.gene-table td {
    padding: 6px 8px;
    text-align: center;
    border-bottom: 1px solid #3c3c3c;
}

.gene-table th {
    background: #2d2d2d;
    color: #aaa;
    font-weight: 500;
    position: sticky;
    top: 0;
}

.gene-table th:first-child,
.gene-table td:first-child {
    text-align: left;
}

.gene-table .parent1-col {
    color: #3b82f6;
}

.gene-table .parent2-col {
    color: #ef4444;
}

.gene-table td {
    color: #ccc;
}

.gene-table tr.from-parent1 td:nth-child(2) {
    background: rgba(59, 130, 246, 0.2);
    font-weight: 600;
}

.gene-table tr.from-parent2 td:nth-child(3) {
    background: rgba(239, 68, 68, 0.2);
    font-weight: 600;
}

.gene-table tr.from-parent1 td:last-child {
    color: #3b82f6;
}

.gene-table tr.from-parent2 td:last-child {
    color: #ef4444;
}

.gene-table tr.elite td:last-child {
    color: #f59e0b;
}

.gene-table tr.immigrant td:last-child {
    color: #06b6d4;  /* Cyan for immigrants */
}

/* Mutation indicator */
.gene-table tr.mutated td:last-child {
    position: relative;
}

.mutation-icon {
    color: #a855f7;
    font-weight: bold;
    margin-left: 4px;
    font-size: 1.1em;
}

.gene-table tr.mutated {
    background: linear-gradient(90deg, transparent 70%, rgba(168, 85, 247, 0.15) 100%);
}

/* Terrain Generator Modal */
.terrain-generator-modal {
    width: 750px;
    max-width: 95vw;
    max-height: 90vh;
}

.terrain-generator-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.terrain-preview-section {
    background: #1e1e1e;
    padding: 12px;
    border-radius: 6px;
}

#terrainPreviewCanvas {
    width: 100%;
    height: 200px;
    background: #0d1117;
    border-radius: 4px;
    cursor: grab;
}

#terrainPreviewCanvas:active {
    cursor: grabbing;
}

.preview-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.preview-zoom {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-zoom .zoom-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 1.1rem;
}

#previewZoomLevel {
    font-size: 0.85rem;
    color: #888;
    min-width: 80px;
    text-align: center;
}

.terrain-controls-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.terrain-control-group {
    background: #252526;
    padding: 12px;
    border-radius: 6px;
}

.terrain-control-group.full-width {
    grid-column: 1 / -1;
}

.terrain-control-group label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: #e0e0e0;
    font-weight: 500;
}

.terrain-control-group .slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.terrain-control-group input[type="range"] {
    flex: 1;
}

.terrain-control-group .value-display {
    min-width: 55px;
    text-align: right;
    font-family: monospace;
    color: #22c55e;
}

.slider-label-left,
.slider-label-right {
    font-size: 0.7rem;
    color: #888;
    min-width: 45px;
}

.slider-label-left {
    text-align: right;
}

.slider-label-right {
    text-align: left;
}

.terrain-import-export {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Responsive */
@media (max-width: 900px) {
    .main-container {
        flex-direction: column;
    }

    .controls-panel {
        width: 100%;
        max-height: 35vh;
        border-right: none;
        border-bottom: 1px solid #3c3c3c;
    }

    .viewer-panel {
        flex: 1;
        min-height: 65vh;
    }

    .bottom-panels {
        flex-direction: column;
        height: auto;
    }

    .viz-panel {
        height: 140px;
        border-right: none;
        border-bottom: 1px solid #3c3c3c;
    }

    .viz-panel:last-child {
        border-bottom: none;
    }
}
