/* Reset y variables CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Prevenir zoom táctil */
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Prevenir zoom específicamente */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    touch-action: manipulation;
}

body {
    /* Prevenir zoom con gestos */
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    overscroll-behavior: none;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    font-size: 16px;
}

/* Prevenir zoom en inputs específicamente */
input, button, select, textarea {
    touch-action: manipulation;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Para WebKit (Safari, Chrome) */
body {
    -webkit-text-size-adjust: none;
    -webkit-touch-callout: none;
}

:root {
    --primary-color: #16213e;
    --secondary-color: #0f4c75;
    --accent-color: #3282b8;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --text-primary: #ffffff;
    --text-secondary: #b8c5d6;
    --background-dark: #0d1117;
    --card-background: #161b22;
    --border-color: #30363d;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    --radius: 8px;
}

.app-container {
    height: 100vh;
    max-width: 500px;
    margin: 0 auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 4px 0;
    flex-shrink: 0;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(45deg, var(--accent-color), #ffffff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: var(--card-background);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.status-indicator.connected {
    border-color: var(--success-color);
    background: rgba(40, 167, 69, 0.1);
}

.status-indicator i {
    color: var(--accent-color);
}

/* Main content sin scroll */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: 8px;
}

/* Cards */
.measurement-card,
.settings-card {
    background: var(--card-background);
    border-radius: var(--radius);
    padding: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.measurement-card {
    display: flex;
    flex-direction: column;
}

.settings-card {
    flex-shrink: 0;
}

/* Current Speed Display */
.current-speed {
    text-align: center;
    margin-bottom: 12px;
}

.speed-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.speed-value {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--accent-color);
    text-shadow: 0 0 15px rgba(50, 130, 184, 0.5);
}

.speed-unit {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.acceleration-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
    font-size: 0.95rem;
}

.acceleration-indicator.detecting {
    color: var(--warning-color);
    animation: pulse 1s infinite;
}

.acceleration-indicator.active {
    color: var(--success-color);
}

/* Distance Progress horizontal */
.distance-progress {
    margin-bottom: 12px;
    display: flex;
    gap: 16px;
}

.progress-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.progress-item label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
}

.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), var(--success-color));
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

.distance-value {
    font-weight: 600;
    color: var(--accent-color);
    text-align: center;
    font-size: 0.85rem;
}

/* Time Results */
.time-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.time-card {
    background: rgba(50, 130, 184, 0.1);
    border: 1px solid var(--accent-color);
    border-radius: var(--radius);
    padding: 10px;
    text-align: center;
}

.time-card h3 {
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.time-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
}

.time-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-color);
}

.time-unit {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.time-card.completed .time-value {
    color: var(--success-color);
    text-shadow: 0 0 10px rgba(40, 167, 69, 0.5);
}

/* Speed display en time cards */
.speed-display-result {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 3px;
    margin-top: 4px;
}

.speed-value-result {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--warning-color);
}

.speed-unit-result {
    font-size: 0.6rem;
    color: var(--text-secondary);
}

.time-card.completed .speed-value-result {
    color: var(--warning-color);
    text-shadow: 0 0 8px rgba(255, 193, 7, 0.4);
}

/* Controls más grandes */
.controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 8px;
}

.btn-primary,
.btn-secondary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: var(--text-primary);
}

.btn-primary {
    background: linear-gradient(45deg, var(--accent-color), var(--secondary-color));
    box-shadow: 0 2px 8px rgba(50, 130, 184, 0.4);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(50, 130, 184, 0.6);
}

.btn-secondary {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    border-color: var(--accent-color);
    color: var(--text-primary);
    background: rgba(50, 130, 184, 0.1);
}

.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Botón de historial */
.history-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    margin-top: 10px;
    padding-top: 8px;
}

/* Settings compactas */
.settings-card h3 {
    margin-bottom: 8px;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    flex: 1;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.setting-item input[type="range"] {
    flex: 2;
    margin: 0 8px;
}

.setting-item span {
    color: var(--accent-color);
    font-weight: 600;
    min-width: 40px;
    font-size: 0.85rem;
}

/* Range Slider */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* Modal de Historial */
.history-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.history-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.history-modal-content {
    background: var(--card-background);
    border-radius: var(--radius);
    padding: 20px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.history-modal h3 {
    margin-bottom: 16px;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 1.2rem;
}

.close-history {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.4rem;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-history:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 16px;
    max-height: none;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(50, 130, 184, 0.1);
    border-radius: 8px;
    border-left: 3px solid var(--accent-color);
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-info {
    flex: 1;
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.history-distance {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.history-times {
    display: flex;
    gap: 16px;
}

.history-time {
    text-align: center;
}

.history-time strong {
    display: block;
    color: var(--accent-color);
    font-size: 1rem;
}

.history-time small {
    font-size: 0.7rem;
    color: var(--text-secondary);
    display: block;
}

.history-speed {
    font-size: 0.65rem;
    color: var(--warning-color);
    font-weight: 500;
}

.no-history {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 40px 20px;
    font-size: 1rem;
}

/* Modal de Error */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--card-background);
    border-radius: var(--radius);
    padding: 20px;
    max-width: 400px;
    width: 90%;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 16px;
    color: var(--danger-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1.1rem;
}

.modal-content p {
    margin-bottom: 20px;
    color: var(--text-secondary);
    line-height: 1.5;
    font-size: 1rem;
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Media Queries solo para ajustes menores */
@media (max-width: 400px) {
    .app-container {
        padding: 6px;
    }
    
    .measurement-card,
    .settings-card {
        padding: 10px;
    }
    
    .speed-value {
        font-size: 2.4rem;
    }
    
    .time-value {
        font-size: 1.5rem;
    }
    
    .controls {
        flex-direction: column;
        gap: 8px;
    }
    
    .distance-progress {
        flex-direction: column;
        gap: 12px;
    }
    
    .progress-item {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }
    
    .progress-item label {
        min-width: 50px;
        text-align: left;
    }
    
    .distance-value {
        text-align: right;
        min-width: 60px;
    }
}

@media (max-height: 650px) {
    .app-container {
        padding: 6px;
    }
    
    .measurement-card,
    .settings-card {
        padding: 10px;
    }
    
    .speed-value {
        font-size: 2.4rem;
    }
    
    .time-value {
        font-size: 1.5rem;
    }
    
    .current-speed {
        margin-bottom: 10px;
    }
    
    .distance-progress {
        margin-bottom: 10px;
    }
    
    .time-results {
        margin-bottom: 10px;
        gap: 8px;
    }
}

/* Cronómetro en tiempo real */
.chronometer-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    font-size: 1.1rem;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chronometer-display.active {
    opacity: 1;
}

.chronometer-display i {
    color: var(--accent-color);
    animation: tick 1s infinite;
}

.chrono-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(50, 130, 184, 0.3);
    min-width: 60px;
}

.chrono-unit {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

@keyframes tick {
    0%, 50% { transform: scale(1); }
    25% { transform: scale(1.1); }
} 