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

:root {
    color-scheme: dark;
}

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

input, select, textarea {
    color-scheme: dark;
}

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

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

header h1 {
    font-size: 2.5rem;
    color: #00d4ff;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
    margin-bottom: 5px;
}

.tagline {
    font-size: 1.2rem;
    color: #888;
    font-style: italic;
}

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

.upload-box {
    border: 3px dashed #4a4a6a;
    border-radius: 15px;
    padding: 50px;
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-box:hover, .upload-box.drag-over {
    border-color: #00d4ff;
    background: rgba(0, 212, 255, 0.1);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.upload-icon {
    font-size: 3rem;
}

.upload-box p {
    font-size: 1.1rem;
    color: #b0b0b0;
}

.upload-box button {
    background: #00d4ff;
    border: none;
    padding: 8px 20px;
    border-radius: 5px;
    color: #1a1a2e;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-box button:hover {
    background: #00a8cc;
    transform: scale(1.05);
}

/* Stats Section */
.stats-section, .map-section, .elevation-section, .pace-section, .splits-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
}

h2 {
    color: #00d4ff;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
}

.stat-card {
    background: rgba(0, 212, 255, 0.1);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    border: 1px solid rgba(0, 212, 255, 0.2);
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 8px;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
}

/* Map Section */
#map {
    height: 400px;
    border-radius: 10px;
    overflow: hidden;
}

.map-legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.legend-color {
    width: 20px;
    height: 4px;
    border-radius: 2px;
}

.legend-color.flat {
    background: #4CAF50;
}

.legend-color.uphill {
    background: #f44336;
}

.legend-color.downhill {
    background: #2196F3;
}

/* Elevation Chart */
.chart-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
}

/* Pace Section */
.mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    background: rgba(0, 0, 0, 0.3);
    padding: 5px;
    border-radius: 10px;
    width: fit-content;
}

.mode-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #888;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.mode-btn:focus {
    outline: none;
}

.mode-btn:hover {
    color: #fff;
}

.mode-btn.active {
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    color: #1a1a2e;
}

.pace-mode {
    animation: fadeIn 0.3s ease;
}

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

.pace-description {
    color: #888;
    margin-bottom: 20px;
}

.pace-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.pace-input-group {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
}

.pace-input-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-weight: 500;
}

.terrain-icon {
    font-size: 1.2rem;
}

.pace-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pace-input-wrapper input {
    width: 60px;
    padding: 10px;
    border: 2px solid #4a4a6a;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.1rem;
    text-align: center;
}

.pace-input-wrapper input:focus {
    outline: none;
    border-color: #00d4ff;
}

.pace-input-wrapper span {
    color: #888;
}

/* Target Time Mode */
.target-time-input {
    background: rgba(0, 0, 0, 0.3);
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 25px;
    text-align: center;
}

.target-time-input label {
    display: block;
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 15px;
    color: #00d4ff;
}

.time-input-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.time-input-wrapper input {
    width: 70px;
    padding: 12px;
    border: 2px solid #4a4a6a;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.3rem;
    text-align: center;
}

.time-input-wrapper input:focus {
    outline: none;
    border-color: #00d4ff;
}

.time-input-wrapper span {
    color: #888;
    font-size: 1.1rem;
}

.pace-ratios {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 25px;
}

.ratio-description {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 20px;
    text-align: center;
}

.ratio-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.ratio-group {
    text-align: center;
}

.ratio-group label {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 500;
}

.ratio-group input {
    width: 100px;
    padding: 12px;
    border: 2px solid #4a4a6a;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.2rem;
    text-align: center;
}

.ratio-group input:focus {
    outline: none;
    border-color: #00d4ff;
}

.ratio-hint {
    display: block;
    margin-top: 8px;
    font-size: 0.8rem;
    color: #666;
}

.calculated-paces {
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
}

.calculated-paces h4 {
    color: #00d4ff;
    text-align: center;
    margin-bottom: 15px;
}

.calc-pace-grid {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.calc-pace-item {
    text-align: center;
}

.calc-pace-label {
    display: block;
    color: #888;
    margin-bottom: 5px;
}

.calc-pace-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: #fff;
}

/* Start Time Input */
.start-time-input {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 25px;
    text-align: center;
}

.start-time-input label {
    display: block;
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 12px;
    color: #00d4ff;
}

.start-time-wrapper {
    display: flex;
    justify-content: center;
}

.start-time-wrapper input[type="time"] {
    padding: 12px 20px;
    border: 2px solid #4a4a6a;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.2rem;
    text-align: center;
}

.start-time-wrapper input[type="time"]:focus {
    outline: none;
    border-color: #00d4ff;
}

.start-time-wrapper input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

/* AID Stations Section */
.aid-stations-section {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 25px;
}

.aid-stations-section > label {
    display: block;
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 15px;
    color: #00d4ff;
}

.aid-stations-list {
    margin-bottom: 15px;
}

.aid-station-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 165, 0, 0.15);
    border: 1px solid rgba(255, 165, 0, 0.3);
    border-radius: 8px;
    padding: 10px 15px;
    margin-bottom: 8px;
}

.aid-station-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.aid-station-km {
    font-weight: bold;
    color: #ffa500;
}

.aid-station-name {
    color: #ccc;
}

.remove-aid-btn {
    background: rgba(244, 67, 54, 0.3);
    border: none;
    color: #f44336;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.remove-aid-btn:hover {
    background: rgba(244, 67, 54, 0.5);
}

.add-aid-station {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.add-aid-station input {
    padding: 10px 12px;
    border: 2px solid #4a4a6a !important;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1) !important;
    background-color: rgba(30, 30, 50, 0.9) !important;
    color: #fff !important;
    font-size: 0.95rem;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.add-aid-station input[type="number"] {
    width: 80px;
    text-align: center;
}

.add-aid-station input[type="text"] {
    flex: 1;
    min-width: 150px;
}

.add-aid-station input:focus {
    outline: none;
    border-color: #00d4ff !important;
}

.add-aid-station input::placeholder {
    color: #888 !important;
}

.add-aid-btn {
    padding: 10px 18px;
    background: linear-gradient(135deg, #ffa500 0%, #ff8c00 100%);
    border: none;
    border-radius: 8px;
    color: #1a1a2e;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-aid-btn:hover {
    transform: scale(1.05);
}

/* AID Station highlight in splits table */
.aid-station-row {
    background: rgba(255, 165, 0, 0.1) !important;
}

.aid-station-cell {
    color: #ffa500;
    font-weight: 500;
}

.calculate-btn {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    padding: 15px 30px;
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    border: none;
    border-radius: 10px;
    color: #1a1a2e;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 212, 255, 0.3);
}

/* Pace Results */
.pace-results {
    margin-top: 30px;
    padding: 25px;
    background: rgba(0, 212, 255, 0.08);
    border-radius: 10px;
    border: 1px solid rgba(0, 212, 255, 0.2);
}

.pace-results h3 {
    color: #00d4ff;
    margin-bottom: 20px;
    text-align: center;
}

.terrain-breakdown, .time-breakdown {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.terrain-stat, .time-stat {
    text-align: center;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.terrain-label, .time-label {
    display: block;
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 5px;
}

.terrain-value, .time-value {
    display: block;
    font-size: 1.2rem;
    font-weight: bold;
}

.total-time {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.2) 0%, rgba(0, 153, 204, 0.2) 100%);
    border-radius: 10px;
    margin-top: 15px;
}

.total-label {
    font-size: 1rem;
    color: #aaa;
    margin-right: 15px;
}

.total-value {
    font-size: 2rem;
    font-weight: bold;
    color: #00d4ff;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    margin-bottom: 0;
}

.export-btn {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.export-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(76, 175, 80, 0.4);
}

/* Splits Table */
.splits-table-container {
    overflow-x: auto;
}

#splitsTable {
    width: 100%;
    border-collapse: collapse;
}

#splitsTable th, #splitsTable td {
    padding: 12px 15px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#splitsTable th {
    background: rgba(0, 212, 255, 0.2);
    color: #00d4ff;
    font-weight: 600;
}

#splitsTable tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.terrain-flat {
    color: #4CAF50;
}

.terrain-uphill {
    color: #f44336;
}

.terrain-downhill {
    color: #2196F3;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    .terrain-breakdown, .time-breakdown {
        grid-template-columns: 1fr;
    }
    
    .pace-inputs {
        grid-template-columns: 1fr;
    }
    
    .map-legend {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
}
