/* Reset & Box Sizing */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Disable text selection and callouts globally */
* {
  -webkit-touch-callout: none; /* Disables iOS/Android callout menu on long-press */
  -webkit-user-select: none;   /* Disables text selection highlighting */
  user-select: none;          
}

/* Layout & Typography */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0 auto;
    padding: 15px;
    padding-top: max(20px, calc(15px + env(safe-area-inset-top)));
    padding-bottom: calc(85px + env(safe-area-inset-bottom));
    max-width: 500px;
    min-height: 100vh;
    background-color: #f9f9f9;
    color: #333;
}

/* Cards & Containers */
.card {
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 15px;
}

/* Buttons & Action Groups */
.btn-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

button {
    padding: 14px;
    font-size: 15px;
    font-weight: bold;
    flex: 1;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    transition: opacity 0.2s, background 0.15s ease, transform 0.1s ease;
}

button:active {
    opacity: 0.8;
    transform: scale(0.96);
}

#connectBtn { background-color: #007bff; color: white; }
#disconnectBtn { background-color: #dc3545; color: white; }
#exportBtn { background-color: #28a745; color: white; width: 100%; margin-bottom: 15px; }
#exportBtn:disabled { background-color: #ccc; cursor: not-allowed; }

#lockScreenBtn {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    background-color: #ff9800;
    color: white;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Primary Metrics (Speed & Battery) */
.primary-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 15px;
}

.metric-primary {
    background: #e3f2fd;
    border: 2px solid #2196f3;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.metric-value-large {
    font-size: 26px;
    font-weight: bold;
    color: #0d47a1;
    margin-top: 6px;
}

/* Secondary Metrics Grid */
.metric-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}

.metric {
    background: #f1f3f5;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
}

.metric-title {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    margin-top: 4px;
}

/* Status Bar & Badges */
.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.status-badge {
    font-weight: bold;
}

.status-disconnected, .status-searching {
    color: #dc3545;
}

.status-connected, .status-ok {
    color: #28a745;
}

/* Configuration Checklist Panel */
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 14px;
}

.config-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* Collapsible Details / Accordions */
summary {
    cursor: pointer;
    font-size: 15px;
    color: #333;
    outline: none;
    user-select: none;
}

summary::-webkit-details-marker {
    color: #007bff;
}

details[open] summary {
    margin-bottom: 5px;
}

/* Lock Screen Overlay */
.touch-lock-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000;
    z-index: 9999;
    display: none;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    color: white;
    touch-action: pan-y;
    padding-top: 60px;
}

.unlock-slider {
    -webkit-appearance: none;
    width: 80%;
    max-width: 300px;
    height: 40px;
    background: #333;
    border-radius: 20px;
    outline: none;
    margin: 10px 0;
}

.unlock-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
}

/* Bike Controls Section */
.bike-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    padding: 18px 0 12px;
}

.pas-control {
    display: flex;
    align-items: center;
    background: #252525;
    border: 1px solid #3d3d3d;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

.pas-btn {
    width: 52px;
    height: 52px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #fff;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
}

.pas-btn:hover {
    background: #353535;
}

.pas-display {
    min-width: 58px;
    height: 52px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-left: 1px solid #3d3d3d;
    border-right: 1px solid #3d3d3d;
    color: #fff;
}

.pas-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    color: #888;
}

#pasValue {
    font-size: 20px;
    font-weight: 700;
    line-height: 22px;
}

/* Headlight Toggle Button */
.light-btn {
    width: 58px;
    height: 52px;
    padding: 0;
    border: 1px solid #444;
    border-radius: 16px;
    background: #252525;
    color: #aaa;
    font-size: 27px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.light-btn:hover {
    background: #303030;
    color: #fff;
}

.light-btn.active {
    background: #fff3a3;
    color: #ffb300;
    border-color: #ffd54f;
    box-shadow: 0 0 14px rgba(255, 213, 79, 0.5), 0 3px 10px rgba(0, 0, 0, 0.25);
}

.light-icon {
    display: block;
    transform: translateY(-1px);
}

.go-btn {
    width: 58px;
    height: 52px;
    padding: 0;
    border: 1px solid #28a745;
    border-radius: 16px;
    background: #252525;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
    transition: background 0.2s ease, transform 0.1s ease;
}

.go-btn:hover {
    background: #303030;
}

/* Responsive Scaling for Small Screens */
@media (max-width: 400px) {
    .bike-controls {
        gap: 14px;
    }

    .pas-btn,
    .light-btn {
        width: 48px;
        height: 48px;
    }

    .pas-display {
        height: 48px;
        min-width: 52px;
    }
}