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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e0e0e0;
    min-height: 100vh;
    padding: 20px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 46, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay.visible {
    display: flex;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #4a5568;
    border-top: 4px solid #f59e0b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner p {
    color: #f59e0b;
    font-size: 1.1rem;
    font-weight: 600;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 5px;
}

.subtitle {
    color: #888;
    font-size: 1rem;
}

/* Upload Section */
.upload-section {
    margin-bottom: 30px;
}

.upload-area {
    border: 2px dashed #4a5568;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.02);
}

.upload-area:hover {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.05);
}

.upload-area.dragover {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.upload-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 10px;
}

.upload-prompt p {
    margin: 5px 0;
}

.upload-hint {
    color: #666;
    font-size: 0.85rem;
}

.upload-status {
    margin-top: 15px;
    padding: 15px;
    border-radius: 8px;
    display: none;
}

.upload-status.success {
    display: block;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid #10b981;
    color: #10b981;
}

.upload-status.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    color: #ef4444;
}

/* Controls Section */
.controls-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
}

.pv-selection {
    margin-bottom: 20px;
}

.pv-selection label {
    font-weight: 600;
    color: #f59e0b;
    display: block;
    margin-bottom: 8px;
}

.pv-dropdown {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #4a5568;
    border-radius: 8px;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 1rem;
    cursor: pointer;
    margin-bottom: 10px;
}

.pv-dropdown:hover {
    border-color: #f59e0b;
}

.pv-info {
    padding: 10px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 8px;
    font-size: 0.9rem;
    color: #f59e0b;
}

.pv-time-info {
    line-height: 1.6;
}

.time-control {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.time-control label {
    font-weight: 600;
    color: #f59e0b;
}

.time-control input[type="time"] {
    padding: 10px 15px;
    border: 1px solid #4a5568;
    border-radius: 8px;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 1rem;
}

.time-slider {
    flex: 1;
    min-width: 200px;
    height: 8px;
    border-radius: 4px;
    background: #4a5568;
    outline: none;
    -webkit-appearance: none;
}

.time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #f59e0b;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.time-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #f59e0b;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.service-input {
    padding: 10px 15px;
    border: 1px solid #4a5568;
    border-radius: 8px;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 1rem;
    width: 200px;
}

.btn-primary {
    padding: 10px 25px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
    border-radius: 8px;
    color: #1a1a2e;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(245, 158, 11, 0.3);
}

.time-range-info {
    margin-top: 10px;
    color: #888;
    font-size: 0.9rem;
}

/* PV Position Info */
.pv-position-info {
    margin-top: 20px;
}

.position-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #4a5568;
    border-radius: 12px;
    padding: 20px;
}

.position-card h3 {
    color: #f59e0b;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.status-badge {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    margin-bottom: 15px;
}

.status-badge.at_station {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.status-badge.between {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.status-badge.not-started {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.status-badge.completed {
    background: rgba(139, 92, 246, 0.2);
    color: #8b5cf6;
}

.position-details {
    display: grid;
    gap: 10px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-row:last-child {
    border-bottom: none;
}

.info-row .label {
    color: #888;
    font-size: 0.9rem;
}

.info-row .value {
    color: #e0e0e0;
    font-weight: 500;
}

.info-row .value.deviation.early {
    color: #3b82f6;
}

.info-row .value.deviation.late {
    color: #ef4444;
}

.info-row .value.deviation.on-time {
    color: #10b981;
}

/* Timeline */
.timeline {
    margin-top: 20px;
    padding: 20px 0;
    overflow-x: auto;
}

.timeline-track {
    position: relative;
    height: 60px;
    min-width: 800px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
}

.timeline-station {
    position: absolute;
    transform: translateX(-50%);
    text-align: center;
    bottom: 0;
}

.timeline-dot {
    width: 10px;
    height: 10px;
    background: #4a5568;
    border-radius: 50%;
    margin: 0 auto 5px;
}

.timeline-station.current .timeline-dot {
    background: #10b981;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.timeline-station.prev .timeline-dot {
    background: #3b82f6;
}

.timeline-station.next .timeline-dot {
    background: #f59e0b;
}

.timeline-name {
    font-size: 0.65rem;
    color: #888;
    white-space: nowrap;
}

.timeline-station.current .timeline-name {
    color: #10b981;
    font-weight: 600;
}

.timeline-train {
    position: absolute;
    transform: translateX(-50%);
    top: 5px;
}

.timeline-train-dot {
    font-size: 1.5rem;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Visualization */
.visualization-section {
    margin-bottom: 30px;
}

.adjacent-info {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid #f59e0b;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    display: none;
}

.adjacent-info.visible {
    display: block;
}

.adjacent-info h3 {
    color: #f59e0b;
    margin-bottom: 15px;
}

.adjacent-trains {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.adjacent-train {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    flex: 1;
    min-width: 200px;
}

.adjacent-train.current {
    border: 2px solid #f59e0b;
}

.adjacent-train.ahead {
    border-left: 3px solid #10b981;
}

.adjacent-train.behind {
    border-left: 3px solid #3b82f6;
}

.track-container {
    margin-bottom: 30px;
}

.track-label {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.track {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 30px 20px;
    min-height: 120px;
    overflow-x: auto;
    overflow-y: visible;
}

.stations {
    position: relative;
    height: 30px;
    margin-bottom: 20px;
    min-width: 100%;
}

.station {
    position: absolute;
    transform: translateX(-50%);
    text-align: center;
}

.station-dot {
    width: 12px;
    height: 12px;
    background: #4a5568;
    border-radius: 50%;
    margin: 0 auto 5px;
}

.station-name {
    font-size: 0.7rem;
    color: #888;
    white-space: nowrap;
}

.trains {
    position: relative;
    min-height: 60px;
    min-width: 100%;
}

.train {
    position: absolute;
    transform: translateX(-50%);
    text-align: center;
    cursor: pointer;
    /* NO transition/animation - trains appear immediately */
}

.train:hover {
    transform: translateX(-50%) scale(1.1);
    z-index: 10;
}

.train-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin: 0 auto 5px;
    border: 2px solid transparent;
}

.train-dot.at-station {
    background: #10b981;
}

.train-dot.between {
    background: #f59e0b;
}

.train-dot.on-time {
    border-color: #10b981;
}

.train-dot.early {
    border-color: #3b82f6;
}

.train-dot.late {
    border-color: #ef4444;
}

.train-dot.highlight {
    background: #f59e0b !important;
    border-color: #fff !important;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.6);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 15px rgba(245, 158, 11, 0.6); }
    50% { box-shadow: 0 0 25px rgba(245, 158, 11, 0.9); }
}

.train-label {
    font-size: 0.65rem;
    color: #e0e0e0;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.7);
    padding: 2px 5px;
    border-radius: 3px;
}

.train-pv {
    font-size: 0.6rem;
    color: #888;
}

/* Legend */
.legend {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #888;
}

.legend-item .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-item .dot.at-station { background: #10b981; }
.legend-item .dot.between { background: #f59e0b; }
.legend-item .dot.on-time { background: transparent; border: 2px solid #10b981; }
.legend-item .dot.early { background: transparent; border: 2px solid #3b82f6; }
.legend-item .dot.late { background: transparent; border: 2px solid #ef4444; }
.legend-item .dot.highlight { background: #f59e0b; border: 2px solid #fff; }

/* Train List */
.train-list-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
}

.train-list-section h3 {
    margin-bottom: 15px;
    color: #f59e0b;
}

.train-lists {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .train-lists {
        grid-template-columns: 1fr;
    }
}

.train-list h4 {
    color: #888;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.train-list ul {
    list-style: none;
    max-height: 400px;
    overflow-y: auto;
}

.train-list li {
    padding: 8px 12px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.train-list li:hover {
    background: rgba(255, 255, 255, 0.08);
}

.train-list li.highlight {
    background: rgba(245, 158, 11, 0.2);
    border-left: 3px solid #f59e0b;
}

.train-info {
    display: flex;
    gap: 10px;
    align-items: center;
}

.train-service {
    font-weight: 600;
    color: #f59e0b;
}

.train-status {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
}

.train-status.at-station {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.train-status.between {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.deviation {
    font-size: 0.75rem;
}

.deviation.early {
    color: #3b82f6;
}

.deviation.late {
    color: #ef4444;
}

.deviation.on-time {
    color: #10b981;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5a6578;
}