/* Tesla Dashcam Telemetry Viewer - Lite Web Version */
/* Design matching TesCamStudio.com */
/* No-scroll layout - everything fits in viewport */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0a0a0b;
    --bg-secondary: rgba(255, 255, 255, 0.03);
    --bg-tertiary: rgba(255, 255, 255, 0.05);
    --bg-card: rgba(255, 255, 255, 0.03);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-muted: rgba(255, 255, 255, 0.4);
    --accent-red: #e63946;
    --accent-red-hover: #ff4d5a;
    --accent-green: #4ade80;
    --accent-yellow: rgb(255, 214, 10);
    --overlay-bg: rgba(0, 0, 0, 1);
    --border-radius: 12px;
    --border-radius-sm: 8px;
}

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

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    line-height: 1.4;
}

/* Background effects matching TesCamStudio */
.app-container {
    width: 100vw;
    height: 100vh;
    padding: 1vh 2vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background:
        /* Grid pattern */
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        /* Red glow orbs */
        radial-gradient(ellipse at 20% 20%, rgba(230, 57, 70, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(230, 57, 70, 0.05) 0%, transparent 50%),
        var(--bg-primary);
    background-size: 50px 50px, 50px 50px, 100% 100%, 100% 100%, 100% 100%;
}

/* Header */
.app-header {
    text-align: center;
    padding: 0.5vh 0 1vh 0;
    flex-shrink: 0;
}

.header-logo {
    width: clamp(48px, 8vh, 80px);
    height: clamp(48px, 8vh, 80px);
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 0.5vh;
    box-shadow: 0 4px 20px rgba(230, 57, 70, 0.3);
}

.app-header h1 {
    font-size: clamp(1rem, 2.5vw, 1.8rem);
    font-weight: 700;
    color: var(--text-primary);
}

.app-header .subtitle {
    color: var(--text-secondary);
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    margin-top: 0.3vh;
    font-weight: 400;
}

.app-header .subtitle a,
.app-header .subtitle a:visited {
    color: var(--accent-red);
    text-decoration: none;
    transition: all 0.3s ease;
}

.app-header .subtitle a:hover {
    color: var(--accent-red-hover);
    text-decoration: underline;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
}

/* Drop Zone */
.drop-zone {
    position: relative;
    width: 90%;
    max-width: 600px;
    height: 40vh;
    max-height: 300px;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* iOS tap highlight */
    -webkit-tap-highlight-color: rgba(230, 57, 70, 0.2);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent-red);
    background: rgba(230, 57, 70, 0.05);
}

.drop-zone.drag-over {
    transform: scale(1.02);
}

.drop-zone-content {
    text-align: center;
    padding: 2vh 2vw;
}

.upload-icon {
    width: clamp(40px, 6vh, 64px);
    height: clamp(40px, 6vh, 64px);
    color: var(--accent-red);
    margin-bottom: 1.5vh;
}

.drop-zone-content h2 {
    font-size: clamp(1rem, 2vw, 1.4rem);
    font-weight: 600;
    margin-bottom: 0.5vh;
}

.drop-zone-content p {
    color: var(--text-secondary);
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    margin-bottom: 0.3vh;
}

.drop-zone-content .file-types {
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    color: var(--text-muted);
}

/* App Store Badge */
.app-store-badge {
    display: inline-block;
    margin-top: 2vh;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-store-badge:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.app-store-badge img {
    height: clamp(36px, 5vh, 48px);
    width: auto;
}

/* Loading State */
.loading-state {
    width: 90%;
    max-width: 500px;
    padding: 4vh 3vw;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    text-align: center;
    border: 1px solid var(--border-color);
}

.spinner {
    width: clamp(32px, 5vh, 48px);
    height: clamp(32px, 5vh, 48px);
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5vh;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 1.5vh;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-red), var(--accent-red-hover));
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

/* Player Section */
.player-section {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.video-container {
    position: relative;
    flex: 1;
    min-height: 0;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
}

.output-canvas {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    touch-action: none; /* Prevent default touch behaviors for drag */
}

.source-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
}

/* Controls */
.controls {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.2vh 1.5vw;
    margin-top: 1vh;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1vw;
    flex-shrink: 0;
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 1vw;
}

.control-btn {
    width: clamp(36px, 4vh, 48px);
    height: clamp(36px, 4vh, 48px);
    border: none;
    background: var(--accent-red);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.control-btn:hover {
    transform: scale(1.08);
    background: var(--accent-red-hover);
    box-shadow: 0 4px 20px rgba(230, 57, 70, 0.4);
}

.control-btn svg {
    width: clamp(16px, 2.5vh, 24px);
    height: clamp(16px, 2.5vh, 24px);
    color: white;
}

.time-display {
    font-family: 'Inter', monospace;
    font-size: clamp(0.75rem, 1.2vw, 1rem);
    color: var(--text-secondary);
    white-space: nowrap;
    font-weight: 500;
}

.time-separator {
    margin: 0 0.3vw;
    color: var(--text-muted);
}

/* Seek Bar */
.seek-bar-container {
    flex: 1;
    min-width: 100px;
}

.seek-bar {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 4px;
    cursor: pointer;
}

.seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-red);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.seek-bar::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(230, 57, 70, 0.5);
}

.seek-bar::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--accent-red);
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

/* Action Controls */
.action-controls {
    display: flex;
    align-items: center;
    gap: 0.8vw;
    flex-wrap: wrap;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 0.5vw;
}

.speed-control label {
    color: var(--text-secondary);
    font-size: clamp(0.7rem, 1vw, 0.9rem);
    white-space: nowrap;
    font-weight: 500;
}

.speed-control select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.6vh 0.8vw;
    color: var(--text-primary);
    font-size: clamp(0.7rem, 1vw, 0.9rem);
    cursor: pointer;
    transition: border-color 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.speed-control select:focus {
    outline: none;
    border-color: var(--accent-red);
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.5vw;
    padding: 0.8vh 1.2vw;
    border: none;
    border-radius: var(--border-radius-sm);
    background: var(--accent-red);
    color: white;
    font-size: clamp(0.75rem, 1vw, 0.95rem);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
}

.action-btn:hover {
    transform: translateY(-2px) scale(1.02);
    background: var(--accent-red-hover);
    box-shadow: 0 4px 20px rgba(230, 57, 70, 0.4);
}

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

.action-btn.secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-red);
    box-shadow: none;
}

.action-btn svg {
    width: clamp(14px, 1.8vh, 20px);
    height: clamp(14px, 1.8vh, 20px);
}

/* Telemetry Panel */
.telemetry-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-top: 1vh;
    overflow: hidden;
    flex-shrink: 0;
}

.telemetry-panel summary {
    padding: 1vh 1.2vw;
    cursor: pointer;
    font-weight: 600;
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    user-select: none;
    transition: color 0.3s ease;
}

.telemetry-panel summary:hover {
    color: var(--text-primary);
}

.telemetry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1vh 1vw;
    padding: 1.2vh 1.5vw;
    max-height: 15vh;
    overflow-y: auto;
}

.telemetry-item {
    display: flex;
    flex-direction: column;
    gap: 0.2vh;
}

.telemetry-label {
    font-size: clamp(0.6rem, 0.8vw, 0.75rem);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.telemetry-value {
    font-family: 'Inter', monospace;
    font-size: clamp(0.8rem, 1vw, 1rem);
    color: var(--text-primary);
    font-weight: 600;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 3vh 3vw;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    font-size: clamp(1rem, 1.8vw, 1.4rem);
    margin-bottom: 1.5vh;
    font-weight: 600;
}

.modal-content .progress-bar {
    margin: 1.5vh 0;
}

#exportPercent {
    font-family: 'Inter', monospace;
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    color: var(--accent-red);
    margin-bottom: 1.5vh;
    font-weight: 600;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 0.8vh 0;
    color: var(--text-muted);
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    flex-shrink: 0;
}

.app-footer .disclaimer {
    margin-top: 0.3vh;
    font-size: clamp(0.55rem, 0.7vw, 0.7rem);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Fade-up animation for elements */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-up {
    animation: fadeUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Responsive - Very small screens */
@media (max-width: 600px) {
    .app-container {
        padding: 1vh 2vw;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 1vh;
    }

    .playback-controls {
        justify-content: center;
    }

    .seek-bar-container {
        width: 100%;
        order: -1;
    }

    .action-controls {
        justify-content: center;
    }

    .speed-control {
        width: 100%;
        justify-content: center;
    }

    .telemetry-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Landscape mobile */
@media (max-height: 500px) {
    .app-header {
        padding: 0.3vh 0;
    }

    .app-header .subtitle {
        display: none;
    }

    .controls {
        padding: 0.8vh 1vw;
    }

    .telemetry-panel {
        display: none;
    }

    .app-footer {
        display: none;
    }
}
