/* Running Analysis - Clean Professional Styling */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --warning: #ca8a04;
    --danger: #dc2626;
    --text: #1f2937;
    --text-muted: #6b7280;
    --bg: #f9fafb;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    --border-dashed: #9ca3af;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2.5rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border-dashed);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--card-bg);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.04);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
}

.drop-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text);
}

.drop-subtext {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.file-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

/* Selected File */
.selected-file {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.selected-file #file-name {
    font-weight: 500;
    color: var(--text);
}

.btn-clear {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}

.btn-clear:hover {
    color: var(--danger);
}

/* Checkbox Label */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: var(--text);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Input Group */
.input-group {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.input-field {
    flex: 1;
    min-width: 160px;
}

.input-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.input-field input[type="number"] {
    width: 100%;
    padding: 0.65rem 0.75rem;
    font-size: 0.95rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
    transition: border-color 0.2s;
}

.input-field input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.mode-selector {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.mode-selector input[type="radio"] {
    display: none;
}

.mode-selector label {
    display: inline-block;
    padding: 0.6rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 0;
    background: var(--card-bg);
}

.mode-selector input[type="radio"]:checked + label {
    background: var(--primary);
    color: white;
}

.mode-selector label:hover {
    background: rgba(37, 99, 235, 0.06);
}

.mode-selector input[type="radio"]:checked + label:hover {
    background: var(--primary-hover);
}

/* Speed tier badge */
.speed-tier-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    color: white;
    margin-top: 1.5rem;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: rgba(37, 99, 235, 0.08);
}

/* Spinner */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Error Message */
.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-top: 1.5rem;
    font-weight: 500;
}

/* Results Section */
#results-section {
    margin-top: 2.5rem;
}

#results-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text);
}

/* Metadata Card */
.metadata-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.metadata-item {
    text-align: center;
}

.metadata-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.metadata-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

/* Parameters Grid */
.parameters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.parameter-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    border-left: 4px solid var(--border);
}

.parameter-card.ideal {
    border-left-color: var(--success);
}

.parameter-card.warning {
    border-left-color: var(--warning);
}

.parameter-card.problem {
    border-left-color: var(--danger);
}

.parameter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.parameter-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.parameter-quality {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.parameter-quality.ideal {
    background: #dcfce7;
    color: var(--success);
}

.parameter-quality.warning {
    background: #fef9c3;
    color: var(--warning);
}

.parameter-quality.problem {
    background: #fee2e2;
    color: var(--danger);
}

/* Gauge Visualization */
.gauge-container {
    margin: 1rem 0;
    padding: 0.5rem 0;
}

.gauge-track {
    position: relative;
    height: 12px;
    background: var(--border);
    border-radius: 6px;
    overflow: visible;
}

.gauge-segment {
    position: absolute;
    height: 100%;
    border-radius: 6px;
}

.gauge-segment.ideal {
    background: linear-gradient(90deg, #86efac, #22c55e);
}

.gauge-segment.warning {
    background: linear-gradient(90deg, #fde047, #eab308);
}

.gauge-segment.problem {
    background: linear-gradient(90deg, #fca5a5, #ef4444);
}

.gauge-marker {
    position: absolute;
    top: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.gauge-marker-line {
    width: 3px;
    height: 24px;
    background: var(--text);
    border-radius: 2px;
    margin: 0 auto;
    transform: translateY(-50%);
    box-shadow: 0 0 0 2px white;
}

.gauge-marker-value {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text);
    background: white;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.gauge-marker.ideal .gauge-marker-value {
    background: #dcfce7;
    border-color: #86efac;
    color: var(--success);
}

.gauge-marker.warning .gauge-marker-value {
    background: #fef9c3;
    border-color: #fde047;
    color: var(--warning);
}

.gauge-marker.problem .gauge-marker-value {
    background: #fee2e2;
    border-color: #fca5a5;
    color: var(--danger);
}

.gauge-labels {
    position: relative;
    height: 20px;
    margin-top: 4px;
}

.gauge-label {
    position: absolute;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: var(--text-muted);
}

.parameter-stats {
    display: flex;
    gap: 1.5rem;
}

.stat {
    text-align: center;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

/* Download Section */
.download-section {
    text-align: center;
    margin: 2rem 0;
}

.download-icon {
    width: 20px;
    height: 20px;
}

/* Raw JSON */
.raw-json-section {
    margin-top: 1.5rem;
}

.raw-json-section summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.raw-json-section pre {
    background: #1f2937;
    color: #e5e7eb;
    padding: 1.25rem;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.8rem;
    line-height: 1.5;
    max-height: 400px;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ============================================================
   Rear-view analysis styles
   ============================================================ */

/* View Tabs */
.view-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* Rear-View Parameter Pair Cards (L | R side-by-side) */
.param-pair-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.rear-parameters h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
    margin-top: 1rem;
}

.rear-side-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    border-left: 4px solid var(--border);
    text-align: center;
}

.rear-side-card.ideal {
    border-left-color: var(--success);
}

.rear-side-card.warning {
    border-left-color: var(--warning);
}

.rear-side-card.problem {
    border-left-color: var(--danger);
}

.rear-side-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.rear-side-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.rear-side-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin: 0.5rem 0 0.25rem;
}

.rear-side-count {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Quality Badges */
.quality-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.quality-ideal {
    background: #dcfce7;
    color: #166534;
}

.quality-warning {
    background: #fef3c7;
    color: #92400e;
}

.quality-problem {
    background: #fee2e2;
    color: #991b1b;
}

/* Captures Grid (2x2 for 4 images) */
.captures-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1rem 0 1.5rem;
}

.capture-item {
    text-align: center;
}

.capture-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.capture-loading {
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.captures-grid img {
    width: 100%;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.btn-capture-download {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--primary);
    background: none;
    border: 1px solid var(--primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-capture-download:hover {
    background: rgba(37, 99, 235, 0.08);
}

/* Landing Detail Table */
.landing-detail {
    margin-top: 1.5rem;
}

.landing-detail summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.landings-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.landings-table th,
.landings-table td {
    padding: 0.6rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.landings-table th {
    background: var(--bg);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.landings-table td {
    font-size: 0.9rem;
    color: var(--text);
}

.landings-table tbody tr:last-child td {
    border-bottom: none;
}

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

/* Responsive */
@media (max-width: 768px) {
    .param-pair-card {
        grid-template-columns: 1fr;
    }

    .captures-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 1.5rem 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .drop-zone {
        padding: 2rem 1.5rem;
    }

    .parameters-grid {
        grid-template-columns: 1fr;
    }

    .view-tabs {
        margin-bottom: 1rem;
    }

    .tab-btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}
