/* Base styles and variables */
:root {
    --primary-color: #3498db;
    --text-color: #333;
    --background-color: #fff;
    --border-color: #ddd;
    --button-hover: #2980b9;
    --section-bg: #f9f9f9;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #3498db;
        --text-color: #f5f5f5;
        --background-color: #222;
        --border-color: #444;
        --button-hover: #2980b9;
        --section-bg: #333;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    margin: 0;
    padding: 0;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 10px;
    font-size: 16px;
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary-color);
}

h2 {
    margin-top: 0;
    color: var(--primary-color);
}

/* Form elements styling */
.section {
    margin-bottom: 15px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: var(--section-bg);
}

.input-group {
    display: flex;
    align-items: center;
    margin: 10px 0;
}

input[type="number"] {
    width: 50px;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0 3px;
    font-size: 16px; /* Prevent iOS zoom on focus */
}

input[type="number"]:first-child {
    margin-left: 0;
}

/* Toggle switches */
.units-toggle, .calc-toggle {
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    width: 280px;
    margin-left: auto;
    margin-right: auto;
}

.toggle-label {
    font-size: 14px;
    color: var(--text-color);
    width: 90px;
    text-align: center;
}

/* The switch - the box around the slider */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

/* Hide default HTML checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The slider */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Distance row layout */
.distance-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

/* Preset buttons */
.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.preset {
    padding: 6px 10px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
}

.preset:hover {
    background-color: var(--button-hover);
}

.preset.active {
    background-color: var(--button-hover);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--primary-color);
}

button {
    padding: 8px 10px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
}

button:hover {
    background-color: var(--button-hover);
}

/* Results and comparison styling */
.results, .comparison, .favorites {
    background-color: rgba(52, 152, 219, 0.1);
}

.equivalent-pace {
    margin-top: 10px;
    font-style: italic;
    color: var(--primary-color);
}

/* Comparison table */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

th, td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

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

/* Favorites list */
.favorites-list {
    list-style: none;
    padding: 0;
}

.favorites-list li {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.favorites-list button {
    padding: 5px 10px;
    font-size: 0.9em;
}

/* Responsive design */
@media (max-width: 600px) {
    body {
        font-size: 15px;
    }
    
    h1 {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }
    
    h2 {
        font-size: 1.2rem;
    }
    
    .container {
        padding: 8px;
    }
    
    .section {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .distance-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .preset-buttons {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        width: 100%;
    }
    
    .input-group {
        flex-wrap: wrap;
        margin: 5px 0;
    }
    
    .favorites-list li {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .favorites-list li div:first-child {
        font-weight: bold;
    }
    
    .favorites-list li button {
        margin-top: 5px;
    }
    
    /* Make buttons more tappable on mobile */
    button, .preset {
        padding: 10px;
        min-height: 44px; /* Minimum touch target size */
    }
}
