﻿/* ═══════════════════════════════════════════════════════════
   Mahindra Tractor Simulator — Enterprise UI
   Dark industrial theme with Mahindra red accent
   ═══════════════════════════════════════════════════════════ */

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

html, body {
    width: 100%; height: 100%;
    background: #000;
    font-family: 'Segoe UI', system-ui, sans-serif;
    color: #e0e0e0;
    overflow: hidden;
    user-select: none;
}

/* ── CANVAS ─────────────────────────────────────────────── */
#sim-canvas {
    position: fixed; inset: 0;
    display: block;
    width: 100%; height: 100%;
    cursor: crosshair;
}

/* ── LOADING SCREEN ──────────────────────────────────────── */
#loading-screen {
    position: fixed; inset: 0;
    background: radial-gradient(ellipse at center, #1a0a00 0%, #000 100%);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}

.loader-content {
    text-align: center;
    max-width: 440px;
    padding: 0 24px;
}

.loader-content img {
    height: 60px;
    margin-bottom: 24px;
}

.loader-content h1 {
    font-size: 2.6rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    color: #ffffff;
    line-height: 1.1;
}

.loader-content h1 span {
    font-size: 1.1rem;
    font-weight: 400;
    letter-spacing: 0.22em;
    color: #e8000d;
    display: block;
    margin-top: 6px;
}

.loader-bar {
    width: 100%; height: 5px;
    background: #1a1a1a;
    border-radius: 3px;
    margin: 28px 0 14px;
    overflow: hidden;
}

.loader-fill {
    height: 100%;
    background: linear-gradient(90deg, #e8000d, #ff5722);
    border-radius: 3px;
    transition: width 0.28s ease;
    box-shadow: 0 0 12px #e8000d88;
}

#loader-status {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    color: #888;
    text-transform: uppercase;
}

/* ── MAIN MENU ───────────────────────────────────────────── */
#main-menu {
    position: fixed; inset: 0;
    background: radial-gradient(ellipse at 30% 60%, #1a0500 0%, #000 65%);
    display: none;
    align-items: center; justify-content: center;
    z-index: 90;
}

.menu-box {
    background: rgba(10,10,10,0.92);
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 40px 48px;
    min-width: 520px;
    backdrop-filter: blur(8px);
    box-shadow: 0 0 60px #e8000d22;
}

.menu-logo { text-align: center; margin-bottom: 36px; }

.menu-logo h1 {
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    color: #e8000d;
}

.menu-logo h2 {
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.22em;
    color: #888;
    margin-top: 4px;
    text-transform: uppercase;
}

.menu-sub {
    font-size: 0.72rem;
    color: #555;
    margin-top: 8px;
    letter-spacing: 0.10em;
}

/* Selection groups */
.menu-options > div { margin-bottom: 22px; }

.menu-options label {
    display: block;
    font-size: 0.70rem;
    letter-spacing: 0.14em;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.farm-btns, .tractor-btns, .task-btns {
    display: flex; gap: 8px; flex-wrap: wrap;
}

.farm-btn, .tractor-btn, .task-btn {
    background: #111;
    border: 1px solid #333;
    color: #aaa;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.18s;
    letter-spacing: 0.04em;
}

.farm-btn:hover, .tractor-btn:hover, .task-btn:hover {
    border-color: #e8000d;
    color: #fff;
    background: #1a0505;
}

.farm-btn.active, .tractor-btn.active, .task-btn.active {
    background: #e8000d;
    border-color: #e8000d;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 0 12px #e8000d55;
}

.start-btn {
    width: 100%;
    padding: 14px;
    margin-top: 10px;
    background: linear-gradient(135deg, #e8000d 0%, #cc0008 100%);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.18s;
    text-transform: uppercase;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px #e8000d66;
}

.session-info {
    text-align: center;
    font-size: 0.62rem;
    color: #333;
    margin-top: 18px;
    letter-spacing: 0.08em;
}

/* ── HUD ─────────────────────────────────────────────────── */
#hud {
    position: fixed; inset: 0;
    pointer-events: none;
    z-index: 50;
}

/* TOP BAR */
.hud-topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 44px;
    background: linear-gradient(180deg, rgba(0,0,0,0.75) 0%, transparent 100%);
    display: flex;
    align-items: center;
    padding: 0 18px;
    gap: 12px;
}

.hud-left-top, .hud-center-top, .hud-right-top {
    display: flex; align-items: center; gap: 12px;
}

.hud-center-top { flex: 1; justify-content: center; }
.hud-right-top  { margin-left: auto; }

.hud-brand {
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.18em;
    color: #e8000d;
}

.hud-model-tag {
    font-size: 0.72rem;
    color: #aaa;
    letter-spacing: 0.08em;
    background: rgba(255,255,255,0.06);
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid #333;
}

.hud-task-badge {
    font-size: 0.70rem;
    letter-spacing: 0.06em;
    color: #ffab40;
}

.hud-timer {
    font-size: 0.80rem;
    font-weight: 700;
    font-family: monospace;
    color: #fff;
    background: rgba(0,0,0,0.5);
    padding: 2px 10px;
    border-radius: 4px;
}

.hud-coords, .hud-terrain-label {
    font-size: 0.65rem;
    color: #888;
    letter-spacing: 0.06em;
}

/* BOTTOM INSTRUMENT CLUSTER */
.hud-cluster {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 200px;
    background: linear-gradient(0deg, rgba(0,0,0,0.88) 0%, transparent 100%);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0;
    padding: 0 16px 12px;
}

/* Speedometer / RPM pods */
.instrument-pod {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.instrument-pod canvas {
    display: block;
    filter: drop-shadow(0 0 8px rgba(0,0,0,0.8));
}

.pod-label {
    font-size: 0.72rem;
    color: #aaa;
    text-align: center;
    letter-spacing: 0.08em;
}

.pod-label span {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    font-family: monospace;
}

/* Center status panel */
.hud-status-panel {
    flex: 1;
    max-width: 380px;
    padding: 0 20px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.status-cell {
    flex: 1;
    background: rgba(0,0,0,0.55);
    border: 1px solid #222;
    border-radius: 6px;
    padding: 6px 0;
    text-align: center;
    min-width: 72px;
}

.status-key {
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.status-big {
    font-size: 1.6rem;
    font-weight: 900;
    font-family: monospace;
    color: #fff;
    line-height: 1;
}

.status-indicator {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 2px 0;
}

.status-indicator.on  { color: #00e676; }
.status-indicator.off { color: #e8000d; }

/* Bar panel */
.bar-panel { display: flex; flex-direction: column; gap: 4px; }

.bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bar-label {
    font-size: 0.60rem;
    letter-spacing: 0.08em;
    color: #666;
    width: 66px;
    text-align: right;
    flex-shrink: 0;
    text-transform: uppercase;
}

.bar-pct {
    font-size: 0.58rem;
    color: #888;
    width: 36px;
    text-align: right;
    flex-shrink: 0;
}

.bar-track {
    flex: 1;
    height: 5px;
    background: #1a1a1a;
    border-radius: 3px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.12s linear;
}

.bar-fill.green  { background: linear-gradient(90deg, #00897b, #00e676); }
.bar-fill.amber  { background: linear-gradient(90deg, #e65100, #ffab40); }
.bar-fill.blue   { background: linear-gradient(90deg, #0288d1, #26c6da); }
.bar-fill.teal   { background: linear-gradient(90deg, #00695c, #26a69a); }

/* ── MINIMAP ─────────────────────────────────────────────── */
.hud-minimap {
    position: absolute;
    top: 54px;
    right: 14px;
    text-align: center;
}

.hud-minimap canvas {
    display: block;
    border-radius: 8px;
    border: 1px solid #333;
    box-shadow: 0 2px 12px rgba(0,0,0,0.7);
}

.minimap-label {
    font-size: 0.58rem;
    letter-spacing: 0.10em;
    color: #555;
    margin-top: 4px;
    text-transform: uppercase;
}

/* ── CONTROLS REFERENCE (left-side panel) ───────────────── */
.hud-controls-ref {
    position: absolute;
    top: 54px;
    left: 14px;
    background: rgba(0,0,0,0.62);
    border: 1px solid #222;
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 180px;
}

.ctrl-col { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }

.ctrl-title {
    font-size: 0.56rem;
    letter-spacing: 0.14em;
    color: #444;
    text-transform: uppercase;
    border-bottom: 1px solid #1e1e1e;
    padding-bottom: 5px;
    margin-bottom: 3px;
}

.ctrl-hint {
    font-size: 0.66rem;
    color: #888;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

kbd {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 3px;
    padding: 0px 4px;
    font-size: 0.60rem;
    font-family: monospace;
    color: #aaa;
}

/* ── ALERT (small toast, top-right) ────────────────────────── */
.hud-alert {
    position: absolute;
    top: 54px;
    right: 14px;
    padding: 9px 16px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    max-width: 280px;
    line-height: 1.35;
    animation: alertFade 0.22s ease;
    pointer-events: none;
}

.hud-alert-info   { background: rgba(10,30,10,0.88); border: 1px solid #00e676; color: #00e676; }
.hud-alert-warn   { background: rgba(30,20,0,0.88);  border: 1px solid #ffab40; color: #ffab40; }
.hud-alert-danger { background: rgba(30,0,0,0.88);   border: 1px solid #e8000d; color: #e8000d;
    box-shadow: 0 0 20px #e8000d44; }

@keyframes alertFade {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── PAUSE MENU ──────────────────────────────────────────── */
#pause-menu {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.78);
    display: none;
    align-items: center; justify-content: center;
    z-index: 80;
    backdrop-filter: blur(3px);
}

.pause-box {
    background: rgba(8,8,8,0.96);
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 36px 44px;
    min-width: 360px;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 0 40px rgba(0,0,0,0.8);
}

.pause-box h2 {
    font-size: 1.6rem;
    letter-spacing: 0.18em;
    color: #e8000d;
    margin-bottom: 24px;
}

.pause-box button {
    display: block;
    width: 100%;
    padding: 11px;
    margin-bottom: 10px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    color: #ccc;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.15s;
    pointer-events: all;
}

.pause-box button:hover {
    background: #e8000d;
    border-color: #e8000d;
    color: #fff;
}

/* Telemetry summary table */
.tel-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 18px;
    font-size: 0.78rem;
    text-align: left;
}

.tel-table td {
    padding: 5px 8px;
    border-bottom: 1px solid #1a1a1a;
    color: #888;
}

.tel-table td:last-child {
    color: #fff;
    font-weight: 600;
    text-align: right;
    font-family: monospace;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
