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

/* Typography System */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #2c3e50;
    font-weight: 400;
    min-height: 100vh;
    background: #f8fafc;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-weight: 600;
    line-height: 1.3;
    color: #1a202c;
}

h1 { font-size: 2rem; margin-bottom: 1rem; }
h2 { font-size: 1.5rem; margin-bottom: 0.875rem; }
h3 { font-size: 1.25rem; margin-bottom: 0.75rem; }
h4 { font-size: 1.125rem; margin-bottom: 0.625rem; }
h5 { font-size: 1rem; margin-bottom: 0.5rem; }
h6 { font-size: 0.875rem; margin-bottom: 0.5rem; }

/* Text weights */
.text-light { font-weight: 300; }
.text-normal { font-weight: 400; }
.text-medium { font-weight: 500; }
.text-semibold { font-weight: 600; }
.text-bold { font-weight: 700; }

/* Text colors */
.text-primary { color: #2d3748; }
.text-secondary { color: #718096; }
.text-muted { color: #a0aec0; }
.text-accent { color: #3182ce; }
.text-success { color: #38a169; }
.text-warning { color: #d69e2e; }
.text-error { color: #e53e3e; }

/* Text sizes */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    background: linear-gradient(135deg, #2d3748, #4a5568);
    color: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.header-controls {
    display: flex;
    gap: 0.5rem;
}

.location-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.location-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    overflow-y: auto;
    background: #f8fafc;
}

/* Section Cards */
.route-controls,
.route-info,
.map-container,
.elevation-profile,
.turn-directions {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    transition: box-shadow 0.2s ease;
}

.route-controls:hover,
.route-info:hover,
.map-container:hover,
.elevation-profile:hover,
.turn-directions:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.route-controls {
    padding: 1.25rem;
}

.route-controls h2 {
    color: #1a202c;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.5rem;
}

.route-info {
    padding: 1rem;
}

.map-container {
    overflow: hidden;
}

.map-container #map {
    height: 400px;
    width: 100%;
}

.elevation-profile {
    padding: 1rem;
}

.turn-directions {
    padding: 1rem;
}

.map-container .elevation-chart-container {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    height: 450px;
    margin-bottom: 15px;
    max-height: 600px;
    overflow-y: auto;
}

.map-container #elevationChart {
    width: 100%;
    height: 100%;
}

.map-container .elevation-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.map-container .elevation-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.route-controls h2 {
    color: #4CAF50;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

/* Form Elements */
.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 600;
    color: #374151;
    font-size: 0.8rem;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.input-with-buttons {
    display: flex;
    gap: 0.375rem;
}

.input-with-buttons input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.375rem;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    background: white;
    color: #374151;
}

.input-with-buttons input:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

.input-with-buttons input::placeholder {
    color: #9ca3af;
}

/* Buttons */
.generate-btn,
.clear-btn,
.export-btn,
.add-waypoint-btn,
.location-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.generate-btn {
    background: linear-gradient(135deg, #3182ce, #2c5282);
    color: white;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.generate-btn:hover {
    background: linear-gradient(135deg, #2c5282, #2a4e7c);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.clear-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.clear-btn:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.export-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.export-btn:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.add-waypoint-btn {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.add-waypoint-btn:hover {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.location-btn {
    background: linear-gradient(135deg, #6b7280, #4b5563);
    color: white;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.location-btn:hover {
    background: linear-gradient(135deg, #4b5563, #374151);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.input-with-buttons input {
    flex: 1;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px 0 0 6px;
    font-size: 0.9rem;
    background: #f9f9f9;
}

.input-group input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #f9f9f9;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #4CAF50;
}

.location-btn {
    padding: 10px 16px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.3s ease;
    white-space: nowrap;
}

.location-btn:hover {
    background: #1976D2;
    background: white;
}

/* Address Suggestions */
.address-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.suggestion-item {
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.suggestion-item:hover {
    background-color: #f5f5f5;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.waypoints-section {
    margin-bottom: 20px;
}

.waypoints-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.waypoints-header label {
    font-weight: 600;
    color: #333;
}

.waypoint-counter {
    background: #FF9800;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.waypoints-list {
    margin-bottom: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.waypoint-item {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 8px;
}

.waypoint-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.waypoint-number {
    font-weight: 600;
    color: #FF9800;
    font-size: 0.9rem;
}

.remove-waypoint-btn {
    background: #f44336;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.remove-waypoint-btn:hover {
    background: #d32f2f;
}

.waypoint-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 0.8rem;
    background: white;
    transition: border-color 0.3s ease;
}

.waypoint-input:focus {
    outline: none;
    border-color: #FF9800;
}

.map-mode-indicator {
    margin: 8px 0;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 4px;
    border-left: 4px solid #FF9800;
}

.mode-text {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

/* Waypoint Suggestions */
.waypoint-suggestions {
    position: fixed;
    top: auto;
    left: auto;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.add-waypoint-btn {
    width: 100%;
    padding: 10px;
    background: #FF9800;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.3s ease;
}

.add-waypoint-btn:hover {
    background: #F57C00;
}

.route-options {
    margin: 20px 0;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.route-type-selector {
    margin-top: 10px;
}

.route-type-selector label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

.route-type-select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.route-type-select:focus {
    outline: none;
    border-color: #4CAF50;
}

.route-type-info {
    margin-top: 5px;
    color: #666;
    font-size: 0.8rem;
    font-style: italic;
}

.api-selector {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

.api-selector label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

.api-select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.api-select:focus {
    outline: none;
    border-color: #4CAF50;
}

.api-info {
    margin-top: 5px;
    color: #666;
    font-size: 0.8rem;
    font-style: italic;
}

.unit-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: #333;
    user-select: none;
    margin-top: 10px;
}

.unit-toggle input[type="checkbox"] {
    display: none;
}

.unit-toggle input[type="checkbox"]:checked + .checkmark {
    background: #2196F3;
}

.checkbox-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: #333;
    user-select: none;
}

.checkbox-container input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    background: white;
    border: 2px solid #4CAF50;
    border-radius: 4px;
    margin-right: 10px;
    position: relative;
    transition: all 0.3s ease;
}

.checkbox-container input[type="checkbox"]:checked + .checkmark {
    background: #4CAF50;
}

.checkbox-container input[type="checkbox"]:checked + .checkmark:after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.generate-btn {
    flex: 1;
    padding: 12px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.3s ease;
}

.generate-btn:hover {
    background: #45a049;
}

.clear-btn {
    padding: 12px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.3s ease;
}

.clear-btn:hover {
    background: #d32f2f;
}

.export-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.export-btn {
    flex: 1;
    padding: 10px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.3s ease;
}

.export-btn:hover {
    background: #1976D2;
}

.export-btn:active {
    transform: scale(0.98);
}

.map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* Custom marker styles */
.custom-div-icon {
    background: transparent !important;
    border: none !important;
}

/* Route Info */
.route-info {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.route-info h3 {
    color: #4CAF50;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.route-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.route-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
}

.route-stat:last-child {
    border-bottom: none;
}

.stat-label {
    font-weight: 500;
    color: #666;
}

.stat-value {
    font-weight: 600;
    color: #333;
}

/* Elevation Profile */
.elevation-profile {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.elevation-profile h3 {
    color: #FF6B35;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.elevation-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

.elevation-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.stat-label {
    font-weight: 500;
    color: #666;
    font-size: 0.9rem;
}

.stat-value {
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

.elevation-chart-container {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px;
    height: 450px;
}

#elevationChart {
    width: 100%;
    height: 450px;
}

/* Gradient Legend */
.gradient-legend {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-top: 15px;
    padding: 10px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.85rem;
}

.legend-title {
    font-weight: 600;
    color: #333;
    margin-right: 10px;
}

.legend-item {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: white;
    font-weight: 500;
}

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

.legend-item.moderate {
    background: #FF9800;
}

.legend-item.hard {
    background: #FF5722;
}

.legend-item.severe {
    background: #9C27B0;
}

.legend-item.extreme {
    background: #795548;
}

/* Add downhill to legend */
.legend-item.downhill {
    background: #2196F3;
}

/* Turn Directions */
.turn-directions {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    max-height: 600px;  /* Increased from 400px to show all 21 steps */
    overflow-y: auto;
}

.turn-directions h3 {
    color: #4CAF50;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.turn-step {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.turn-step.difficulty-easy {
    border-left: 4px solid #4CAF50;
    background: linear-gradient(to right, rgba(76, 175, 80, 0.05), white);
}

.turn-step.difficulty-moderate {
    border-left: 4px solid #FF9800;
    background: linear-gradient(to right, rgba(255, 152, 0, 0.05), white);
}

.turn-step.difficulty-hard {
    border-left: 4px solid #FF5722;
    background: linear-gradient(to right, rgba(255, 87, 34, 0.05), white);
}

.turn-step.difficulty-very-hard {
    border-left: 4px solid #F44336;
    background: linear-gradient(to right, rgba(244, 67, 54, 0.05), white);
}

.turn-step.difficulty-extreme {
    border-left: 4px solid #9C27B0;
    background: linear-gradient(to right, rgba(156, 39, 176, 0.05), white);
}

.turn-step.difficulty-flat {
    border-left: 4px solid #2196F3;
    background: linear-gradient(to right, rgba(33, 150, 243, 0.05), white);
}

.turn-step.difficulty-uphill {
    border-left: 4px solid #795548;
    background: linear-gradient(to right, rgba(121, 85, 72, 0.05), white);
}

.turn-step:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.turn-step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.turn-step-number {
    background: #4CAF50;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.turn-step-distance {
    background: #2196F3;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.turn-instruction {
    color: #333;
    font-weight: 500;
    margin-bottom: 8px;
    line-height: 1.4;
}

.turn-step-details {
    display: flex;
    gap: 15px;
    font-size: 0.8rem;
    color: #666;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: 300px;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .map-container {
        height: calc(100vh - 300px - 80px);
    }
}
