/* Base styles */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #22c55e;
    --error: #ef4444;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
header {
    background: var(--primary);
    color: white;
    padding: 2rem;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

header p {
    opacity: 0.9;
}

/* Main content */
main {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.card.error {
    border-left: 4px solid var(--error);
}

.hidden {
    display: none !important;
}

/* Upload area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: #f0f9ff;
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

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

.file-info {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #f0fdf4;
    border-radius: var(--radius);
    color: var(--success);
}

/* Map */
#map {
    height: 400px;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.route-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    font-size: 0.9rem;
}

.route-info span {
    background: var(--bg);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
}

.route-info strong {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

/* Form */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-group input {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group small {
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn.primary {
    background: var(--primary);
    color: white;
}

.btn.primary:hover {
    background: var(--primary-dark);
}

.btn.primary:disabled {
    background: var(--secondary);
    cursor: not-allowed;
}

.btn.secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn.secondary:hover {
    background: var(--border);
}

/* Progress */
.progress-container {
    margin-bottom: 1rem;
}

.progress-stage {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    margin-top: 0.5rem;
    text-align: right;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.progress-log {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    font-family: monospace;
    font-size: 0.85rem;
    max-height: 200px;
    overflow-y: auto;
}

.progress-log p {
    margin: 0.25rem 0;
}

.progress-log .complete {
    color: var(--success);
}

.progress-log .error {
    color: var(--error);
}

/* Result */
.result-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.result-stats .stat {
    background: var(--bg);
    padding: 1rem;
    border-radius: var(--radius);
    text-align: center;
}

.result-stats .stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
}

.result-stats .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

#preview-container {
    background: #1a1a2e;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

#preview-canvas {
    width: 100%;
    height: 400px;
    display: block;
}

.result-actions {
    display: flex;
    gap: 1rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 600px) {
    header {
        padding: 1.5rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    main {
        padding: 1rem;
    }

    .card {
        padding: 1rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    #map {
        height: 300px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .result-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}
