/* 
   Bike Tracking App Stylesheet
   This file contains all styles for the bike tracking application
   Organized section by section for easier maintenance
*/

/* Base styles */
body {
    font-family: Arial, sans-serif;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
}
h1 {
    color: #333;
}
h2 {
    color: #444;
    font-size: 1.3em;
    margin-top: 30px;
}
.button-container {
    margin: 20px auto 10px;
    padding: 5px;
    border-radius: 5px;
    background-color: rgba(240, 240, 240, 0.8);
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    z-index: 100;
}
button {
    background-color: #4CAF50;
    border: none;
    color: white;
    padding: 6px 12px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 12px;
    cursor: pointer;
    border-radius: 3px;
}
button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.7;
}
#releaseButton {
    background-color: #f44336;
}
#releaseButton:disabled {
    background-color: #ffcccb; /* Light red/pink to indicate disabled */
    color: #888;
    border: 1px solid #ddd;
}
#lockButton:disabled {
    background-color: #a5d6a7; /* Light green to indicate disabled */
    color: #888;
    border: 1px solid #ddd;
}
#status {
    margin-top: 20px;
    padding: 10px;
    border-radius: 4px;
    background-color: #f1f1f1;
    font-size: 14px;
}

/* Geolocation styles */
#location-container {
    margin: 20px auto;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #ddd;
    max-width: 90%;
    position: relative;
}
#location-status {
    font-weight: bold;
    margin: 10px 0;
}
#coordinates {
    text-align: left;
    margin: 15px auto;
    max-width: 300px;
    background: white;
    padding: 10px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
#coordinates p {
    margin: 5px 0;
}
#locationButton {
    margin-top: 10px;
    background-color: #2196F3;
}

/* Map styles */
#map {
    height: 300px;
    width: 100%;
    margin: 15px 0;
    border-radius: 4px;
    border: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#followButton, #dynamicZoomButton {
    background-color: #555;
    color: white;
    opacity: 0.75;
}

#followButton.active, #dynamicZoomButton.active {
    background-color: #2196F3;
    opacity: 1;
}

/* Speed info styles */
#speed-info {
    background-color: #e3f2fd;
    padding: 10px;
    border-radius: 4px;
    margin: 10px auto;
    text-align: left;
    max-width: 300px;
}
#speed-info p {
    margin: 5px 0;
    font-size: 14px;
}
.speed-value {
    font-weight: bold;
    color: #0d47a1;
}
.hidden {
    display: none !important;
}

.tracking-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 10px 0;
}

#pauseButton {
    background-color: #ff9800;
}

#pauseButton.paused {
    background-color: #2196F3;
}

/* Header and user styling - improved alignment */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
}

header h1 {
    margin: 0;
}

.user-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
}

.user-info {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #333;
    gap: 10px; /* Increased gap for better spacing */
}

.auth-button {
    display: inline-block;
    padding: 5px 12px;
    text-decoration: none;
    border-radius: 3px;
    font-size: 12px;
    color: white;
    background-color: #2196F3;
    white-space: nowrap; /* Prevent button text from wrapping */
}

.auth-button.logout {
    background-color: #f44336;
}

.auth-button:hover {
    opacity: 0.9;
}

/* Trip history styling */
.history-button {
    background-color: #4a6572;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

.history-button:hover {
    background-color: #344955;
}

.modal {
    position: fixed;
    z-index: 1500; /* Increase z-index to be higher than Leaflet controls (usually around 1000) */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 0;
    border-radius: 5px;
    width: 80%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: modalFadeIn 0.3s;
    z-index: 1600; /* Higher than the modal backdrop */
}

/* Fix for Leaflet attribution z-index */
.leaflet-control-attribution {
    z-index: 900 !important; /* Force lower z-index than our modal */
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #333;
}

.close-modal {
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.close-modal:hover {
    color: #333;
}

.modal-body {
    padding: 15px 20px;
    overflow-y: auto;
    max-height: 60vh;
}

.trip-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.trip-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
}

.trip-item:hover {
    background-color: #f5f5f5;
}

.trip-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.trip-name {
    font-weight: bold;
    color: #333;
}

.trip-date {
    font-size: 0.8rem;
    color: #666;
}

.trip-item-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #666;
}

.trip-distance::after {
    content: " • ";
}

.trip-duration::after {
    content: " • ";
}

#saveButton {
    background-color: #FF9800;
}

#newTripButton {
    background-color: #2196F3;
}

@keyframes modalFadeIn {
    from {opacity: 0; transform: translateY(-20px);}
    to {opacity: 1; transform: translateY(0);}
}

.empty-trips {
    text-align: center;
    color: #666;
    padding: 20px;
    font-style: italic;
}

.error-message {
    color: #c62828;
    padding: 10px;
    border-radius: 4px;
    background-color: #ffebee;
    text-align: center;
    margin-bottom: 15px;
}

/* Direction marker styling - improved for iOS compatibility */
.direction-marker {
    position: relative;
    z-index: 1000; /* Ensure it's above other map elements */
}

.arrow {
    position: relative;
    width: 20px;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transform-origin: center center;
    -webkit-transform-origin: center center; /* iOS compatibility */
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.7));
    -webkit-filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.7)); /* iOS compatibility */
    overflow: visible;
    /* Add hardware acceleration and improve iOS performance */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000;
    perspective: 1000;
    will-change: transform;
}

.arrow::before {
    content: "";
    position: absolute;
    top: -15px;
    left: 5px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 15px solid #ff0000; /* Red triangle pointing forward */
}

.arrow::after {
    content: "";
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: white;
    border-radius: 50%;
    top: 8px;
    left: 8px;
}

/* Debug panel styling - hidden but kept for potential future use */
.debug-panel {
    display: none;
}

/* iOS permission container styling */
.ios-permission-container {
    background-color: #f0f8ff;
    border: 2px solid #2196F3;
    border-radius: 8px;
    padding: 15px;
    margin: 15px auto;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.permission-content h3 {
    color: #1565C0;
    margin-top: 0;
}

.permission-button {
    background-color: #FF5722;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px 15px;
    font-size: 16px;
    cursor: pointer;
    margin-top: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.permission-button:hover {
    background-color: #E64A19;
}

/* Profile Button Styling */
.profile-button {
    background-color: #4a90e2;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.profile-button:hover {
    background-color: #3a7bc8;
}

/* Profile Modal Form Styling */
#profileForm {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 400px;
    margin: 0 auto;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.form-group input,
.form-group select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #4a90e2;
    outline: none;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.form-actions {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

.btn-save {
    background-color: #2ecc71;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-save:hover {
    background-color: #27ae60;
}

/* Profile Message Styling */
.message {
    padding: 12px;
    border-radius: 4px;
    margin-top: 15px;
    text-align: center;
    font-weight: 500;
}

.message.hidden {
    display: none;
}

.message.info {
    background-color: #e3f2fd;
    color: #0d47a1;
    border: 1px solid #bbdefb;
}

.message.success {
    background-color: #e8f5e9;
    color: #1b5e20;
    border: 1px solid #c8e6c9;
}

.message.error {
    background-color: #ffebee;
    color: #b71c1c;
    border: 1px solid #ffcdd2;
}

/* Make the modal more responsive */
@media (max-width: 600px) {
    .modal-content {
        width: 95%;
        margin: 20px auto;
    }
    
    #profileForm {
        width: 100%;
        padding: 0 10px;
    }
    
    .form-group input,
    .form-group select {
        font-size: 14px;
    }
}

/* Responsive adjustments for very small screens */
@media (max-width: 480px) {
    header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .user-container {
        margin-top: 10px;
        justify-content: center;
        width: 100%;
    }
    
    .user-info {
        justify-content: center;
        margin-bottom: 8px;
    }
}

/* Activity type styles */
.activity-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    margin-right: 8px;
    font-weight: bold;
    color: white;
}

.activity-badge.cycling {
    background-color: #3498db;
}

.activity-badge.walking {
    background-color: #27ae60;
}

/* Activity selector styles */
.activity-selector {
    margin: 15px 0;
    padding: 10px;
    background-color: #f5f5f5;
    border-radius: 5px;
    display: flex;
    align-items: center;
}

.activity-selector.tracking {
    background-color: transparent;
}

.activity-selector.viewing-saved select {
    display: none;
}

.activity-selector label {
    margin-right: 10px;
    font-weight: bold;
}

.activity-selector select {
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

/* Elevation Info Styles */
.elevation-data {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #bbdefb;
}

.elevation-value {
    font-weight: bold;
}

.ascent {
    color: #e53935; /* Red for uphill */
}

.descent {
    color: #1e88e5; /* Blue for downhill */
}

.current-elevation {
    color: #f57c00; /* Orange for current elevation */
}

/* Elevation Legend */
.elevation-legend {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
    padding: 5px;
    background-color: #f5f5f5;
    border-radius: 4px;
    font-size: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
}

.legend-color {
    width: 12px;
    height: 12px;
    margin-right: 4px;
    border-radius: 50%;
}

.uphill-color {
    background-color: #FF0000; /* Red */
}

.flat-color {
    background-color: #FF9800; /* Orange */
}

.downhill-color {
    background-color: #0000FF; /* Blue */
}

/* Hidden marker for saved trips */
.hidden-marker {
    display: none;
    visibility: hidden;
    opacity: 0;
}

/* Elevation Source Toggle */
.elevation-source-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 10px auto;
    font-size: 14px;
}

/* The switch - the box around the slider */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

/* Hide default 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: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #2196F3;
}

input:focus + .slider {
    box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: #2196F3;
    color: white;
    font-size: 12px;
    font-weight: bold;
    text-decoration: none;
}

.info-icon:hover {
    background-color: #0b7dda;
}
