/* ============================================================
   UDEC Haptic SIM - Dark theme stylesheet
   ============================================================ */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent-blue: #58a6ff;
    --accent-orange: #d29922;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-cyan: #39d2c0;
    --accent-purple: #bc8cff;
    --panel-width: 320px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* ---- Header ---- */

#header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    height: 48px;
    z-index: 10;
}

#header h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-cyan);
}

#header .subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

#helpBtn {
    margin-left: auto;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#helpBtn:hover {
    background: var(--accent-blue);
    color: #000;
}

/* ---- Main layout ---- */

#app {
    display: flex;
    height: calc(100vh - 48px);
}

/* ---- 3D Viewport ---- */

#viewport {
    flex: 1;
    position: relative;
    background: #000;
}

#renderCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

#overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    gap: 16px;
    font-size: 13px;
    font-family: "JetBrains Mono", "Fira Code", monospace;
    color: var(--text-secondary);
    pointer-events: none;
}

#overlay span {
    background: rgba(13, 17, 23, 0.8);
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

#fpsDisplay { color: var(--accent-green); }
#collisionDisplay { color: var(--accent-red); }
#forceDisplay { color: var(--accent-orange); }
#spatialDisplay { color: var(--accent-purple); }

#keyHints {
    position: absolute;
    bottom: 36px;
    left: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    pointer-events: none;
}

#keyHints kbd {
    display: inline-block;
    padding: 2px 5px;
    font-size: 11px;
    font-family: monospace;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 3px;
    margin: 0 1px;
}

#statusBar {
    position: absolute;
    bottom: 8px;
    left: 10px;
    font-size: 12px;
    color: var(--accent-green);
    font-family: monospace;
}

/* ---- Side Panel ---- */

#panel {
    width: var(--panel-width);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    padding: 12px;
}

.panel-section {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.panel-section:last-child {
    border-bottom: none;
}

.panel-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* Buttons */

.btn {
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn:hover {
    background: var(--accent-blue);
    color: #000;
}

.btn-accent {
    background: var(--accent-orange);
    color: #000;
    font-weight: 600;
}

.btn-accent:hover {
    background: #e6a817;
}

.btn-accent.active {
    background: var(--accent-red);
    color: #fff;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.btn-sm {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 11px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-sm:hover {
    background: var(--accent-cyan);
    color: #000;
}

.file-label {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s;
}

.file-label:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* Sliders */

.slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.slider-row label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 80px;
}

.slider-row input[type="range"] {
    flex: 1;
    accent-color: var(--accent-cyan);
    height: 4px;
}

.slider-row span {
    font-size: 11px;
    color: var(--accent-cyan);
    min-width: 36px;
    text-align: right;
    font-family: monospace;
}

.slider-row select {
    flex: 1;
    padding: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
}

/* Toggles */

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    cursor: pointer;
}

.toggle input[type="checkbox"] {
    accent-color: var(--accent-cyan);
}

/* Transform buttons */

.transform-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

/* Status indicator */

.status {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
}

.status.connected {
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.status.disconnected {
    background: rgba(248, 81, 73, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

/* Body info */

#bodyInfo {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.body-item {
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    margin-bottom: 4px;
}

.body-item .name {
    color: var(--accent-cyan);
    font-weight: 600;
}

.body-item .detail {
    color: var(--text-secondary);
    font-size: 11px;
}

/* ---- Help Modal ---- */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-content h2 {
    color: var(--accent-cyan);
    margin-bottom: 16px;
}

.modal-content h3 {
    color: var(--accent-orange);
    margin-top: 16px;
    margin-bottom: 8px;
}

.modal-content p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 8px;
}

.modal-content pre {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    color: var(--accent-green);
    font-size: 13px;
    margin: 8px 0;
    overflow-x: auto;
}

.modal-content ul {
    padding-left: 20px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
}

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

/* ---- Scrollbar ---- */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
