/* Modern Industrial Theme - "NEXUS" */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Inter:wght@400;600&display=swap');

:root {
    --bg-dark: #0f1115;
    --panel-bg: #1a1d24;
    --panel-border: #333a45;
    --accent-color: #f59e0b;
    /* Safety Orange */
    --accent-glow: rgba(245, 158, 11, 0.3);
    --text-main: #e2e8f0;
    --text-dim: #94a3b8;
    --lcd-bg: #101820;
    --lcd-text: #00ffcc;
    /* Cyan phosphor */
    --btn-face: #2d333b;
    --btn-hover: #374151;
    --btn-active: #1f2937;
}

body {
    margin: 0;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
}

#app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* 3D Viewport */
#viewport {
    flex-grow: 1;
    background: radial-gradient(circle at center, #1f2329 0%, #0f1115 100%);
    position: relative;
    outline: none;
}

/* Camera Toolbar */
#camera-toolbar {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    display: flex;
    gap: 10px;
    background: rgba(20, 20, 25, 0.8);
    backdrop-filter: blur(10px);
    padding: 8px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.cam-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-dim);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.cam-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.5);
}

/* UI CARDS SYSTEM */
.ui-card {
    position: absolute;
    width: 280px;
    /* More compact */
    background: rgba(20, 24, 30, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.1s, box-shadow 0.2s;
}

.ui-card:active {
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
    z-index: 101;
    /* Bring to front */
}

.card-header {
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--accent-color);
    font-family: 'JetBrains Mono';
    font-size: 12px;
    font-weight: bold;
    cursor: grab;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.card-header:active {
    cursor: grabbing;
    background: rgba(255, 255, 255, 0.1);
}

.card-content {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    /* Allow scrolling if content is too big */
    /* Prevent spill */
    gap: 10px;
    /* Space between internal blocks */
}

/* Compact LCD - Grows to fill space */
/* Compact LCD - Grows to fill space */
.lcd-screen {
    background-color: var(--lcd-bg);
    color: var(--lcd-text);
    font-family: 'JetBrains Mono', monospace;
    padding: 15px;
    /* More padding */
    border-radius: 6px;
    height: auto;
    flex: 1;
    /* FILL VERTICAL SPACE */
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    /* Spread rows evenly */
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
    /* Inner shadow for depth */
    border: 1px solid #333;
}

/* Resize Handle */
.resize-handle {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    cursor: se-resize;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.resize-handle::after {
    content: "↘";
    color: var(--accent-color);
    font-size: 16px;
    font-weight: bold;
    pointer-events: none;
    text-shadow: 0 0 2px black;
}

.resize-handle:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Scanline effect */
.lcd-screen::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
    background-size: 100% 4px;
    z-index: 2;
    pointer-events: none;
}

.screen-header {
    border-bottom: 1px solid rgba(0, 255, 204, 0.3);
    padding-bottom: 5px;
    margin-bottom: 10px;
    font-size: 0.9em;
    opacity: 0.8;
}

.coord-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
    font-size: 11px;
}

.separator {
    color: rgba(0, 255, 204, 0.2);
    margin: 5px 0;
}

/* Controls Shared */
.control-group {
    margin-bottom: 10px;
    background: transparent;
    padding: 0;
    border-radius: 8px;
    border: none;
}

.control-group label {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Toggle Switch (Tabs) */
.toggle-switch-container {
    display: flex;
    flex-wrap: wrap;
    /* Allow wrapping for new buttons */
    background: #111;
    border-radius: 6px;
    padding: 4px;
    gap: 4px;
}

.toggle-switch-container input {
    display: none;
}

.toggle-btn {
    flex: 1;
    text-align: center;
    padding: 8px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
    font-weight: bold;
}

input:checked+.toggle-btn {
    background: var(--btn-face);
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

#mode-world:checked+label {
    color: var(--accent-color);
}

/* Jog Keys */
.jog-row {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    flex: 1;
    /* Grow vertically to fill card */
    min-height: 24px;
    /* Minimum height so they don't squash too much */
}

.axis-label {
    width: 30px;
    font-family: 'JetBrains Mono';
    font-size: 12px;
    color: var(--text-dim);
    font-weight: bold;
    display: flex;
    align-items: center;
    /* Vertically center label */
}

.jog-btn {
    flex: 1;
    background: linear-gradient(to bottom, #3a414b, #2d333b);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 14px;
    margin: 0 4px;
    /* Horizontal gap */
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.1s;
    height: 100%;
    /* Fill the row height */
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.jog-btn:hover {
    background: linear-gradient(to bottom, #4b5563, #374151);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
}

.jog-btn:active {
    transform: translateY(1px);
    background: var(--btn-active);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Step Grid */
.step-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
}

.step-grid input {
    display: none;
}

.step-btn {
    background: #111;
    border: 1px solid #333;
    color: #666;
    text-align: center;
    padding: 6px;
    font-size: 11px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.step-grid input:checked+.step-btn {
    background: var(--accent-color);
    color: #000;
    font-weight: bold;
    border-color: var(--accent-color);
    box-shadow: 0 0 8px var(--accent-glow);
}

/* 3D World Labels */
#world-labels {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    /* High z-index to be above canvas */
    overflow: hidden;
}

.ghost-label {
    position: absolute;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid #00ffff;
    color: #00ffff;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: bold;
    transform: translate(-50%, -100%);
    white-space: nowrap;
    text-shadow: 0 0 5px #00ffff;
}

/* Waypoint List Items */
.waypoint-item {
    padding: 6px;
    border-bottom: 1px solid #333;
    font-size: 11px;
    color: #aaa;
    cursor: pointer;
    transition: background 0.2s;
}

.waypoint-item:hover {
    background: #222;
    color: #fff;
}

.waypoint-item.active-run {
    background: rgba(0, 255, 0, 0.3) !important;
    color: #fff !important;
    border-left: 3px solid #00ff00;
    font-weight: bold;
    box-shadow: inset 0 0 10px rgba(0, 255, 0, 0.1);
}

/* New Buttons */
.config-btn {
    background: var(--btn-face);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.config-btn:hover {
    background: var(--btn-hover);
    color: white;
}

/* Emergency Stop */
.esto-container {
    margin-top: auto;
    padding-top: 20px;
}

#e-stop {
    width: 100%;
    background: linear-gradient(to bottom, #ef4444, #b91c1c);
    color: white;
    font-weight: 900;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 4px 0 #7f1d1d, 0 10px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.1s;
}

#e-stop:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #7f1d1d, inset 0 2px 5px rgba(0, 0, 0, 0.5);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #111;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}