/* FormalabCNC Color Palette */
:root {
	--bg-primary: #18181b;
	--bg-secondary: #1E293B;
	--bg-tertiary: #334155;
	--accent-green: #10B981;
	--accent-blue: #38BDF8;
	--accent-red: #EF4444;
	--text-primary: #F1F5F9;
	--text-secondary: #94A3B8;
	--border-color: #475569;
	--accent-magenta: #A855F7;
	--accent-cyan: #22D3EE;
}

/* ===== PANELES FLOTANTES (Draggable & Resizable) ===== */
.floating-panel {
	position: fixed;
	background: var(--bg-secondary);
	border: 1px solid var(--border-color);
	border-radius: 8px;
	z-index: 100;
	font-family: 'Inter', sans-serif;
	min-width: 150px;
	min-height: 80px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
	overflow: hidden;
}

.floating-panel .panel-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 8px 12px;
	background: var(--bg-tertiary);
	cursor: move;
	user-select: none;
}

.floating-panel .panel-header h3 {
	margin: 0;
	font-size: 12px;
	color: var(--text-primary);
	font-weight: 600;
}

.floating-panel .panel-header .panel-controls {
	display: flex;
	gap: 4px;
}

.floating-panel .panel-header .panel-btn {
	width: 20px;
	height: 20px;
	border-radius: 4px;
	border: none;
	background: rgba(255, 255, 255, 0.1);
	color: var(--text-secondary);
	font-size: 10px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s;
}

.bp-option .panel-header .panel-btn:hover {
	background: rgba(255, 255, 255, 0.2);
	color: var(--text-primary);
}

.floating-panel .panel-content {
	padding: 10px;
	overflow: auto;
	max-height: calc(100% - 40px);
}

/* Playback controls - botones horizontales */
#playback-controls,
#new-playback-controls {
	display: flex;
	justify-content: center;
	gap: 5px;
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px solid var(--border-color);
}

/* Material Panel Styles */
.material-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 0;
	border-bottom: 1px solid var(--border-color);
}

/* Backplotter Option Styles */
.bp-option {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 8px;
}

.bp-option input[type="range"] {
	width: 100px;
	accent-color: var(--accent-green);
}

.bp-option .range-value {
	font-family: monospace;
	font-size: 12px;
	color: var(--accent-green);
	min-width: 40px;
	text-align: right;
}

.material-option:last-child {
	border-bottom: none;
}

.material-option label {
	color: var(--text-secondary);
	font-size: 13px;
	min-width: 80px;
}

.material-option input[type="range"] {
	flex: 1;
	margin: 0 10px;
	accent-color: var(--accent-cyan);
}

.material-option .range-value {
	color: var(--accent-cyan);
	font-size: 12px;
	min-width: 30px;
	text-align: right;
	font-family: 'Consolas', monospace;
}

.material-option input[type="color"] {
	width: 60px;
	height: 24px;
	border: 1px solid var(--border-color);
	border-radius: 4px;
	padding: 0;
	cursor: pointer;
	background: transparent;
}

.material-checkbox {
	width: 18px;
	height: 18px;
	accent-color: var(--accent-green);
	cursor: pointer;
}

/* Cuando está colapsado, ocultar TODO el contenido */
.floating-panel.collapsed .panel-content {
	display: none !important;
}

/* El panel colapsado solo muestra su header */
.floating-panel.collapsed {
	min-height: auto !important;
	height: auto !important;
	max-height: 40px !important;
	overflow: hidden !important;
}

/* ===== POSICIONES INICIALES DE PANELES (debajo del menú de 50px) ===== */
#material-panel {
	top: 60px;
	left: 10px;
	width: 180px;
	z-index: 101;
}

#lectura-panel {
	top: 60px;
	left: 200px;
	width: 280px;
	z-index: 102;
}

#offsets-panel {
	top: 60px;
	right: 200px;
	left: auto;
	width: 180px;
	z-index: 103;
}

#bp-panel {
	top: 60px;
	right: 10px;
	left: auto;
	width: 220px;
	z-index: 104;
}

/* ===== HAMBURGER MENU (Mobile) ===== */
.ntm-hamburger {
	display: none;
	/* Oculto por defecto, visible en móvil */
	flex-direction: column;
	justify-content: space-between;
	width: 28px;
	height: 20px;
	background: transparent;
	border: none;
	cursor: pointer;
	padding: 0;
	z-index: 1100;
}

.ntm-hamburger span {
	display: block;
	width: 100%;
	height: 3px;
	background: var(--text-primary);
	border-radius: 2px;
	transition: all 0.3s ease;
}

.ntm-hamburger:hover span {
	background: var(--accent-green);
}

/* Animación cuando está activo */
.ntm-hamburger.active span:nth-child(1) {
	transform: rotate(45deg) translate(5px, 5px);
}

.ntm-hamburger.active span:nth-child(2) {
	opacity: 0;
}

.ntm-hamburger.active span:nth-child(3) {
	transform: rotate(-45deg) translate(7px, -6px);
}

/* ===== MENÚ HAMBURGUESA ESTILO iOS (HORIZONTAL) ===== */
.ntm-nav.mobile-open {
	display: flex !important;
	position: fixed;
	top: 50px;
	left: 10px;
	right: 10px;
	height: 50px !important;
	max-height: 50px !important;
	background: rgba(30, 41, 59, 0.95);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	flex-direction: row;
	justify-content: space-around;
	align-items: center;
	padding: 0 8px;
	border-radius: 12px;
	border: 1px solid var(--border-color);
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
	z-index: 1050;
	animation: fadeIn 0.15s ease;
	overflow: visible;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: scale(0.95);
	}

	to {
		opacity: 1;
		transform: scale(1);
	}
}

.ntm-nav.mobile-open .ntm-item {
	width: auto;
	height: auto !important;
	position: relative;
	display: flex;
	align-items: center;
}

.ntm-nav.mobile-open .ntm-btn {
	width: auto;
	text-align: center;
	padding: 8px 14px;
	font-size: 13px;
	font-weight: 500;
	color: var(--text-primary);
	background: var(--bg-tertiary);
	border: none;
	border-radius: 8px;
	transition: background 0.15s;
}

.ntm-nav.mobile-open .ntm-btn:hover,
.ntm-nav.mobile-open .ntm-btn:active {
	background: var(--accent-green);
	color: var(--bg-primary);
}

.ntm-nav.mobile-open .ntm-item+.ntm-item {
	border: none;
}

.ntm-nav.mobile-open .ntm-dropdown {
	position: absolute;
	top: 100%;
	left: auto;
	right: 0;
	transform: none;
	display: none;
	background: rgba(30, 41, 59, 0.98);
	border-radius: 8px;
	margin-top: 6px;
	min-width: 130px;
	max-width: 90vw;
	padding: 4px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
	z-index: 1100;
}

/* Dropdown del primer item alineado a la izquierda */
.ntm-nav.mobile-open .ntm-item:first-child .ntm-dropdown {
	left: 0;
	right: auto;
}

.ntm-nav.mobile-open .ntm-item.expanded .ntm-dropdown {
	display: block;
}

.ntm-nav.mobile-open .ntm-dropdown .ntm-option {
	padding: 8px 12px;
	font-size: 13px;
	border-radius: 6px;
}

/* ===== TOOLBAR INFERIOR (Siempre Visible) ===== */
/* Barra de pestañas para controlar paneles - ahora siempre visible */
#mobile-drawer-tabs {
	display: flex;
	position: fixed;
	bottom: 35px;
	/* Encima del bottomMenu */
	left: 0;
	right: 0;
	height: 60px;
	background: var(--bg-secondary);
	border-top: 1px solid var(--border-color);
	z-index: 500;
	justify-content: center;
	align-items: center;
	gap: 8px;
	padding: 0 10px;
}

.drawer-tab {
	width: 48px;
	height: 48px;
	border: none;
	border-radius: 12px;
	font-size: 22px;
	cursor: pointer;
	transition: all 0.2s;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.drawer-tab:hover {
	transform: scale(1.1);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.drawer-tab:active {
	transform: scale(0.95);
}

.drawer-tab.active {
	box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
	transform: scale(1.1);
}

.tab-icon {
	font-size: 22px;
}

/* Botón Toggle Desplegar/Anclar */
.mode-toggle-btn {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 48px;
	border: 2px solid var(--accent-green);
	border-radius: 12px;
	background: var(--bg-tertiary);
	color: var(--accent-green);
	cursor: pointer;
	transition: all 0.2s;
	margin-left: 8px;
}

.mode-toggle-btn:hover {
	background: var(--accent-green);
	color: var(--bg-primary);
}

.mode-toggle-btn .toggle-icon {
	font-size: 18px;
}

.mode-toggle-btn .toggle-text {
	font-size: 9px;
	font-weight: 600;
	margin-top: 2px;
}

/* ===== MODO DRAWER (basado en clase body) ===== */
/* Se activa cuando body tiene .panel-mode-drawer (default) */
/* Los paneles se despliegan desde abajo al tocar los iconos */

body.panel-mode-drawer .floating-panel {
	position: fixed !important;
	bottom: -100vh !important;
	left: 0 !important;
	right: 0 !important;
	top: auto !important;
	width: 100% !important;
	max-width: 100% !important;
	max-height: 55vh;
	min-height: 200px;
	border-radius: 16px 16px 0 0 !important;
	transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
	box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.5);
	z-index: 200 !important;
}

body.panel-mode-drawer .floating-panel.drawer-open {
	bottom: 95px !important;
	/* Encima de tabs + bottomMenu */
}

body.panel-mode-drawer .floating-panel .panel-header {
	cursor: grab;
	padding: 16px;
	position: relative;
}

body.panel-mode-drawer .floating-panel .panel-header::before {
	content: '';
	position: absolute;
	top: 8px;
	left: 50%;
	transform: translateX(-50%);
	width: 40px;
	height: 4px;
	background: var(--text-secondary);
	border-radius: 2px;
	opacity: 0.5;
}

body.panel-mode-drawer .floating-panel .panel-content {
	max-height: calc(55vh - 60px);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 12px 16px;
}

/* ===== MODO FLOAT (paneles flotantes arrastrables) ===== */
/* Se activa cuando body tiene .panel-mode-float */

body.panel-mode-float .floating-panel {
	/* Restaurar comportamiento flotante normal */
	transition: none !important;
}

body.panel-mode-float .floating-panel.collapsed {
	min-height: auto !important;
	height: auto !important;
	max-height: 40px !important;
}

/* Ajustar canvas para dar espacio a la barra de iconos */
#canvasContainer {
	bottom: 95px !important;
	/* toolbar + bottomMenu */
}


/* Resize Handle */
.floating-panel .resize-handle {
	position: absolute;
	bottom: 0;
	right: 0;
	width: 16px;
	height: 16px;
	cursor: se-resize;
	background: linear-gradient(135deg, transparent 50%, var(--accent-cyan) 50%);
	border-radius: 0 0 8px 0;
	opacity: 0.5;
	transition: opacity 0.2s;
}

.floating-panel:hover .resize-handle {
	opacity: 1;
}

.floating-panel.collapsed .resize-handle {
	display: none;
}

/* Panel activo (al arrastrar) */
.floating-panel.dragging {
	opacity: 0.9;
	box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

body {
	overflow: hidden;
	padding: 0px;
	margin: 0px;
	list-style: none;
	background: var(--bg-primary);
	color: var(--text-primary);
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== NUEVO MENÚ SUPERIOR (Flexbox + Dark Theme) ===== */
#new-top-menu {
	display: flex;
	justify-content: space-between;
	align-items: center;
	background: var(--bg-secondary);
	height: 50px;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	z-index: 1000;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
	padding: 0 15px;
	box-sizing: border-box;
	font-family: 'Inter', sans-serif;
}

.ntm-brand {
	display: flex;
	align-items: center;
	gap: 10px;
	color: var(--accent-green);
	font-weight: 600;
	font-size: 16px;
}

.ntm-brand .icon {
	font-size: 20px;
}

.ntm-nav {
	display: flex;
	gap: 5px;
	height: 100%;
}

.ntm-item {
	position: relative;
	height: 100%;
	display: flex;
	align-items: center;
}

.ntm-btn {
	background: transparent;
	border: none;
	color: var(--text-secondary);
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	padding: 0 15px;
	height: 100%;
	transition: all 0.2s;
	border-radius: 4px;
}

.ntm-btn:hover,
.ntm-item:hover .ntm-btn {
	color: var(--text-primary);
	background: rgba(255, 255, 255, 0.05);
}

/* Dropdowns */
.ntm-dropdown {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	background: var(--bg-tertiary);
	border: 1px solid var(--border-color);
	border-radius: 0 0 8px 8px;
	min-width: 180px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
	padding: 5px 0;
	z-index: 1001;
}

.ntm-item:hover .ntm-dropdown {
	display: block;
	animation: fadeIn 0.15s ease-out;
}

.ntm-option {
	padding: 8px 15px;
	color: var(--text-primary);
	font-size: 13px;
	cursor: pointer;
	transition: background 0.1s;
	display: block;
}

.ntm-option:hover {
	background: var(--accent-green);
	color: #fff;
}

.ntm-separator {
	height: 1px;
	background: var(--border-color);
	margin: 5px 0;
}

/* Status Indicator */
.ntm-status {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 12px;
	color: var(--text-secondary);
}

.status-indicator {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #666;
}

.status-indicator.online {
	background: var(--accent-green);
	box-shadow: 0 0 8px var(--accent-green);
}

/* Ajustar canvas para el nuevo menú */
#canvasContainer {
	top: 50px !important;
	/* Ajuste para el nuevo menú */
}

/* Ocultar menú antiguo (temporalmente visible si se desea, pero por defecto oculto para probar) */
#topMenu {
	display: none !important;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(-5px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

nav {
	top: -36px;
	position: absolute;
	margin: 20px auto;
	width: 100%;
	margin-bottom: 0px;
}

nav ul {
	list-style: none;
	padding: 0px;
}

nav>ul {
	margin-bottom: 0px;
	width: 100%;
	background: var(--bg-secondary);
	position: relative;
}

nav>ul li {
	display: table-cell;
}

nav>ul>li:hover>ul {
	display: block;
	height: 100%;
}

nav>ul>li>ul {
	display: block;
	position: absolute;
	background: var(--bg-tertiary);
	left: 0;
	right: 0;
	overflow: hidden;
	height: 0%;
	-webkit-transition: all .3s ease;
	-moz-transition: all .3s ease;
	-ms-transition: all .3s ease;
	-o-transition: all .3s ease;
	transition: all .3s ease;
	opacity: 0.98;
}

nav>ul li div {
	color: var(--text-primary);
	display: block;
	line-height: 15px;
	padding: 15px;
	position: relative;
	text-align: center;
	cursor: pointer;
	-webkit-transition: all .3s ease;
	-moz-transition: all .3s ease;
	-ms-transition: all .3s ease;
	-o-transition: all .3s ease;
	transition: all .3s ease;
}

nav>ul>li>ul>li div:hover {
	background: var(--accent-green);
	color: var(--bg-primary);
}

nav>ul>li>div span {
	background: var(--accent-green);
	display: block;
	height: 100%;
	width: 100%;
	left: 0;
	position: absolute;
	top: -42px;
	-webkit-transition: all .3s ease;
	-moz-transition: all .3s ease;
	-ms-transition: all .3s ease;
	-o-transition: all .3s ease;
	transition: all .3s ease;
}

nav>ul>li>div>.icon {
	display: block;
	line-height: 45px;
}

a {
	text-decoration: none;
}

a:link {
	color: var(--accent-blue);
}

/* visited link */
a:visited {
	color: var(--accent-blue);
}

nav>ul>li>div:hover>span {
	top: 0;
}

#editor {
	z-index: 40;
	display: block;
	position: fixed;
	top: 0px;
	bottom: 0px;
	right: 0px;
	width: 25%;
	min-width: 300px;
	/* Oculto porque ahora está en panel flotante */
	/* El panel flotante lo mueve, así que este espacio no se necesita */
}

/* Ahora el canvas ocupa todo el ancho porque el editor es flotante */
#canvasContainer {
	z-index: 10;
	position: fixed;
	top: 45px;
	bottom: 30px;
	width: 100%;
}

#bottomMenu {
	z-index: 20;
	font-size: 15;
	position: fixed;
	left: 0px;
	bottom: 0px;
	width: 100%;
	height: 15px;
	padding: 10px 0 10px 0;
	background: var(--bg-secondary);
	color: var(--text-primary);
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-khtml-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

#bottomMenu span {
	padding-left: 10px;
	cursor: pointer;
}

#bottomMenu>span:hover {
	color: #d14826;
	cursor: pointer;
}

/* Responsive Design - Mobile (Drawer System Integration) */
@media screen and (max-width: 768px) {
	body {
		overflow: hidden;
	}

	/* Ocultar menú nav en móvil - usar hamburguesa */
	.ntm-nav {
		display: none;
	}

	/* Mostrar hamburguesa */
	.ntm-hamburger {
		display: flex !important;
	}

	/* Canvas ocupa todo excepto top menu y bottom bars */
	#canvasContainer {
		position: fixed !important;
		top: 50px !important;
		left: 0 !important;
		right: 0 !important;
		bottom: 85px !important;
		/* tabs + bottomMenu */
		width: 100% !important;
	}

	/* Bottom menu queda en la base */
	#bottomMenu {
		position: fixed !important;
		bottom: 0 !important;
		z-index: 400;
	}

	/* Editor wrapper no se necesita en móvil */
	#editor-panel {
		z-index: 300 !important;
	}

	/* Menú superior más compacto */
	#new-top-menu {
		padding: 0 10px;
	}

	.ntm-brand .brand-text {
		font-size: 14px;
	}

	.ntm-status .status-text {
		display: none;
		/* Ocultar texto en móvil */
	}
}

/* Desktop - toggle editor siempre funciona */
#editor.visible {
	display: block !important;
}

#toggleEditorBtn:hover {
	cursor: pointer;
}

#dialogBox {
	width: 400px;
	border: 0px;
}

#dialogBox ul {
	padding: 0px;
	list-style: none;
}

#dialogBox label {
	padding: 0px;
	display: block;
	margin: 10px 0px 10px 0px;
}

#dialog input {
	display: inline;
}

.tableList {
	display: table;
}

.tableList li {
	width: 110px;
	margin: 5px;
	display: inline-block;
	vertical-align: top;
	text-align: center;
	cursor: pointer;
}

.tableList span {
	font-size: 50px;
	display: block;
	padding-bottom: 10px;
}

#menuTemplates {
	display: none;
}

.ui-widget-header {
	background: var(--bg-tertiary);
}

.ui-corner-all {
	border-radius: 0px;
}

.ui-dialog {
	color: var(--text-primary);
	background: var(--bg-secondary);
	border: 1px solid var(--border-color);
	-webkit-box-shadow: -5px 7px 29px 3px rgba(0, 0, 0, 0.68);
	-moz-box-shadow: -5px 7px 29px 3px rgba(0, 0, 0, 0.68);
	box-shadow: -5px 7px 29px 3px rgba(0, 0, 0, 0.68);
}

.ui-front {
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
	font-size: 16;
}

.ui-button {
	margin-top: 10px;
	height: 30px;
	bottom: 0px;
	width: 100px;
	background: var(--accent-green);
	color: var(--bg-primary);
	border: 0px;
	border-radius: 4px;
	font-weight: 500;
	cursor: pointer;
}

.ui-button:hover {
	background: #0EA571;
}

.ui-dialog-titlebar-close {
	background: inherit;
}

.ui-dialog-titlebar-close:before {
	font-size: 15;
	content: "x";
}

#machineIcon {
	color: var(--accent-blue);
	position: absolute;
	right: 0;
	top: 0;
	text-align: right;
	margin: 5px;
	font-size: 35px;
}

#gui {
	position: absolute;
	top: 0px;
	right: 0px;
	float: right;
	z-index: 999;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-khtml-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

.notImplemented {
	color: #707070;
}

#messages {
	z-index: 50;
	color: var(--text-primary);
	padding: 10;
	bottom: 0;
	position: absolute;
	background: var(--bg-secondary);
	border-radius: 4px;
}

/* ===== PANEL DRO (LECTURA DIGITAL) ===== */
/* Ahora usa .floating-panel como base - solo estilos de contenido interno */
#dro-panel {
	/* Tamaño inicial sugerido - puede ser redimensionado */
	width: 280px;
}

/* Estilos del contenido del DRO (no del panel en sí) */
#dro-panel .panel-content {
	padding: 10px;
}

.dro-row {
	display: flex;
	gap: 10px;
	margin-bottom: 10px;
}

.dro-axis {
	flex: 1;
	text-align: center;
}

.dro-axis .axis-label {
	font-size: 12px;
	font-weight: 600;
	padding: 4px 0;
	background: var(--bg-tertiary);
	color: var(--text-secondary);
}

.dro-axis.x-axis .axis-label {
	background: #EF4444;
	color: #fff;
}

.dro-axis.y-axis .axis-label {
	background: var(--accent-green);
	color: #fff;
}

.dro-axis.z-axis .axis-label {
	background: var(--accent-blue);
	color: #0F172A;
}

.dro-axis.a-axis .axis-label {
	background: #8B5CF6;
	color: #fff;
}

.dro-axis.b-axis .axis-label {
	background: #F59E0B;
	color: #0F172A;
}

.dro-axis.c-axis .axis-label {
	background: #EC4899;
	color: #fff;
}

.dro-axis .axis-value {
	font-size: 16px;
	font-weight: 500;
	padding: 8px 0;
	font-family: 'Consolas', 'Monaco', monospace;
	color: var(--text-primary);
	background: var(--bg-primary);
	border: 1px solid var(--border-color);
	min-width: 85px;
	text-align: center;
}

/* ===== DRO SECCIONES (Absoluto + Incremental) ===== */
.dro-section {
	margin-bottom: 10px;
}

.dro-section:last-child {
	margin-bottom: 0;
}

.dro-section-title {
	font-size: 11px;
	font-weight: 600;
	color: var(--text-secondary);
	margin-bottom: 6px;
	padding-bottom: 4px;
	border-bottom: 1px solid var(--border-color);
}

/* Sección Incremental con color diferente */
.dro-incremental .axis-value {
	color: var(--accent-cyan);
}

/* Valores positivos en verde, negativos en rojo */
.dro-incremental .axis-value.positive {
	color: var(--accent-green);
}

.dro-incremental .axis-value.negative {
	color: #ef4444;
}

/* ===== PANEL WORK OFFSETS (G54-G59) ===== */
#offsets-panel {
	position: fixed;
	top: 180px;
	left: 10px;
	width: 180px;
	background: var(--bg-secondary);
	border: 1px solid var(--border-color);
	border-radius: 8px;
	z-index: 30;
	font-family: 'Inter', sans-serif;
}

#offsets-panel .panel-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 8px 12px;
	background: #7c3aed;
	border-radius: 8px 8px 0 0;
	cursor: pointer;
}

#offsets-panel .panel-header h3 {
	margin: 0;
	font-size: 12px;
	color: #fff;
	font-weight: 600;
}

#offsets-panel .panel-content {
	padding: 10px;
}

.offset-selector {
	margin-bottom: 10px;
}

.offset-selector label {
	display: block;
	font-size: 11px;
	color: var(--text-secondary);
	margin-bottom: 4px;
}

.offset-selector select {
	width: 100%;
	padding: 6px 8px;
	background: var(--bg-primary);
	border: 1px solid var(--border-color);
	border-radius: 4px;
	color: var(--text-primary);
	font-size: 12px;
	cursor: pointer;
}

.offset-inputs {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: 10px;
}

.offset-input {
	display: flex;
	align-items: center;
	gap: 6px;
}

.offset-input label {
	min-width: 20px;
	font-size: 11px;
	font-weight: 600;
	color: var(--accent-magenta);
}

.offset-input input {
	flex: 1;
	padding: 4px 6px;
	background: var(--bg-primary);
	border: 1px solid var(--border-color);
	border-radius: 4px;
	color: var(--text-primary);
	font-size: 11px;
	font-family: 'Consolas', monospace;
}

.offset-btn {
	width: 100%;
	padding: 6px;
	background: #7c3aed;
	border: none;
	border-radius: 4px;
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s;
}

.offset-btn:hover {
	background: #6d28d9;
}

#offsets-panel.collapsed .panel-content {
	display: none;
}

#offsets-panel.collapsed .toggle-icon {
	transform: rotate(180deg);
}

/* ===== PANEL BACKPLOTTER SETTINGS ===== */
#backplotter-panel {
	position: fixed;
	top: 50px;
	right: 26%;
	width: 220px;
	background: var(--bg-secondary);
	border: 1px solid var(--border-color);
	border-radius: 8px;
	z-index: 25;
	font-family: 'Inter', sans-serif;
}

#backplotter-panel .panel-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 15px;
	background: var(--accent-green);
	border-radius: 8px 8px 0 0;
	cursor: pointer;
}

#backplotter-panel .panel-header h3 {
	margin: 0;
	font-size: 13px;
	color: var(--bg-primary);
	font-weight: 600;
}

#backplotter-panel.collapsed .panel-content {
	display: none;
}

#backplotter-panel .panel-content {
	padding: 12px 15px;
}

.bp-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 0;
	border-bottom: 1px solid var(--bg-tertiary);
	font-size: 13px;
	color: var(--text-primary);
}

.bp-option:last-child {
	border-bottom: none;
}

.bp-option label {
	cursor: pointer;
	flex: 1;
}

/* Toggle Switch */
.toggle-switch {
	position: relative;
	width: 40px;
	height: 20px;
}

.toggle-switch input {
	opacity: 0;
	width: 0;
	height: 0;
}

.toggle-switch .slider {
	position: absolute;
	cursor: pointer;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: var(--bg-tertiary);
	transition: .3s;
	border-radius: 20px;
}

.toggle-switch .slider:before {
	position: absolute;
	content: "";
	height: 14px;
	width: 14px;
	left: 3px;
	bottom: 3px;
	background-color: var(--text-secondary);
	transition: .3s;
	border-radius: 50%;
}

.toggle-switch input:checked+.slider {
	background-color: var(--accent-green);
}

.toggle-switch input:checked+.slider:before {
	transform: translateX(20px);
	background-color: #fff;
}

/* ===== CONTROLES DE REPRODUCCIÓN ===== */
#playback-controls {
	display: flex;
	justify-content: center;
	gap: 5px;
	padding: 12px;
	background: var(--bg-tertiary);
	border-radius: 0 0 8px 8px;
}

.playback-btn {
	width: 32px;
	height: 32px;
	border: none;
	border-radius: 4px;
	background: var(--bg-secondary);
	color: var(--text-primary);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s;
}

.playback-btn:hover {
	background: var(--accent-green);
	color: var(--bg-primary);
}

.playback-btn.active {
	background: var(--accent-green);
	color: var(--bg-primary);
}

/* Responsive para paneles */
@media screen and (max-width: 768px) {

	#dro-panel,
	#backplotter-panel {
		position: relative;
		width: 100%;
		top: auto;
		left: auto;
		right: auto;
		margin-bottom: 10px;
		border-radius: 0;
	}
}

/* ===== INDICADOR DE LÍNEA ACTUAL (PLAYBACK) ===== */
.playback-line {
	position: absolute;
	background: var(--accent-green) !important;
	opacity: 0.3;
}

/* Gutter decoración para línea actual */
.ace_gutter-cell.ace_gutter-active-line {
	background: var(--accent-green) !important;
	color: var(--bg-primary) !important;
}

/* Línea actual más visible */
.ace_marker-layer .playback-line {
	background: rgba(16, 185, 129, 0.35) !important;
	border-left: 3px solid var(--accent-green);
}

/* ===== VIEWCUBE WIDGET EXPANDIDO (Estilo Rombicuboctaedro) ===== */
#viewcube-widget {
	position: fixed;
	top: 60px;
	right: 10px;
	z-index: 600;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	background: rgba(30, 41, 59, 0.9);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	padding: 8px;
	border-radius: 12px;
	border: 1px solid var(--border-color);
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
	transition: all 0.2s ease;
}

/* Botón toggle siempre visible */
.vc-toggle {
	width: 36px;
	height: 36px;
	border: none;
	border-radius: 8px;
	background: var(--accent-cyan);
	font-size: 20px;
	cursor: pointer;
	transition: all 0.2s;
	display: flex;
	align-items: center;
	justify-content: center;
}

.vc-toggle:hover {
	background: var(--accent-green);
	transform: scale(1.1);
}

/* Contenido colapsable */
.vc-content {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	transition: all 0.2s ease;
}

/* Estado MINIMIZADO - solo se ve el botón toggle */
#viewcube-widget.vc-minimized {
	padding: 4px;
	background: transparent;
	border: none;
	box-shadow: none;
}

#viewcube-widget.vc-minimized .vc-content {
	display: none;
}

#viewcube-widget.vc-minimized .vc-toggle {
	background: rgba(30, 41, 59, 0.9);
	border: 1px solid var(--border-color);
}

/* Matriz 3x3 principal para navegación frontal */
.viewcube-main {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.viewcube-row {
	display: flex;
	gap: 2px;
}

/* Estilos base para botones del ViewCube */
.vc-btn {
	width: 26px;
	height: 26px;
	border: none;
	border-radius: 4px;
	font-size: 10px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.15s;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Cara central (más grande y destacada) */
.vc-face {
	width: 32px;
	height: 32px;
	background: var(--accent-cyan);
	color: var(--bg-primary);
	font-size: 14px;
	border-radius: 6px;
}

.vc-face:hover {
	background: var(--accent-green);
	transform: scale(1.1);
}

/* Esquinas (isométricas) */
.vc-corner {
	background: var(--bg-tertiary);
	color: var(--text-secondary);
}

.vc-corner:hover {
	background: var(--accent-magenta);
	color: white;
}

/* Aristas */
.vc-edge {
	background: rgba(71, 85, 105, 0.6);
	color: var(--text-secondary);
	font-size: 8px;
}

.vc-edge:hover {
	background: var(--accent-blue);
	color: white;
}

/* Botones activos */
.vc-btn.active,
.vq-btn.active,
.vs-btn.active {
	box-shadow: 0 0 8px var(--accent-green);
	background: var(--accent-green) !important;
	color: var(--bg-primary) !important;
}

/* Barra de vistas rápidas */
.viewcube-quick {
	display: flex;
	gap: 4px;
	margin-top: 4px;
}

.vq-btn {
	width: 34px;
	height: 28px;
	border: none;
	border-radius: 6px;
	background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
	color: var(--text-primary);
	font-size: 11px;
	cursor: pointer;
	transition: all 0.15s;
}

.vq-btn:hover {
	background: var(--accent-green);
	color: var(--bg-primary);
	transform: scale(1.05);
}

/* Botones secundarios */
.viewcube-secondary {
	display: flex;
	gap: 3px;
	margin-top: 2px;
}

.vs-btn {
	width: 26px;
	height: 22px;
	border: none;
	border-radius: 4px;
	background: rgba(71, 85, 105, 0.5);
	color: var(--text-secondary);
	font-size: 10px;
	cursor: pointer;
	transition: all 0.15s;
}

.vs-btn:hover {
	background: var(--accent-cyan);
	color: var(--bg-primary);
}

/* Controles de Grilla */
.viewcube-grid-controls {
	display: flex;
	gap: 4px;
	margin-top: 4px;
	align-items: center;
	border-top: 1px solid rgba(255, 255, 255, 0.1);
	padding-top: 6px;
}

.vg-btn {
	width: 28px;
	height: 24px;
	border: none;
	border-radius: 4px;
	background: var(--bg-tertiary);
	color: var(--text-secondary);
	font-size: 14px;
	cursor: pointer;
	transition: all 0.15s;
}

.vg-btn:hover {
	background: var(--accent-blue);
	color: white;
}

.vg-btn.active {
	background: var(--accent-green);
	color: var(--bg-primary);
}

#grid-spacing-select {
	flex: 1;
	height: 24px;
	padding: 0 4px;
	border: 1px solid var(--border-color);
	border-radius: 4px;
	background: var(--bg-tertiary);
	color: var(--text-primary);
	font-size: 10px;
	cursor: pointer;
}

#grid-spacing-select:focus {
	outline: none;
	border-color: var(--accent-cyan);
}

.viewcube-container {
	width: 80px;
	height: 80px;
	perspective: 200px;
	position: relative;
}

.viewcube-cube {
	width: 50px;
	height: 50px;
	position: absolute;
	top: 15px;
	left: 15px;
	transform-style: preserve-3d;
	transform: rotateX(-25deg) rotateY(45deg);
	transition: transform 0.4s ease;
	cursor: pointer;
}

.cube-face {
	position: absolute;
	width: 50px;
	height: 50px;
	background: rgba(30, 41, 59, 0.85);
	border: 1px solid var(--accent-cyan);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 11px;
	font-weight: 600;
	color: var(--text-secondary);
	cursor: pointer;
	transition: all 0.2s;
	backdrop-filter: blur(4px);
}

.cube-face:hover {
	background: var(--accent-green);
	color: var(--bg-primary);
}

.cube-face.front {
	transform: translateZ(25px);
}

.cube-face.back {
	transform: rotateY(180deg) translateZ(25px);
}

.cube-face.top {
	transform: rotateX(90deg) translateZ(25px);
}

.cube-face.bottom {
	transform: rotateX(-90deg) translateZ(25px);
}

.cube-face.left {
	transform: rotateY(-90deg) translateZ(25px);
}

.cube-face.right {
	transform: rotateY(90deg) translateZ(25px);
}

.viewcube-axes {
	position: absolute;
	bottom: 0;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	gap: 8px;
}

.axis {
	font-size: 10px;
	font-weight: 700;
	padding: 2px 4px;
	border-radius: 3px;
}

.axis-x {
	color: #ef4444;
}

.axis-y {
	color: #22c55e;
}

.axis-z {
	color: #3b82f6;
}

.viewcube-buttons {
	display: flex;
	gap: 4px;
	background: rgba(30, 41, 59, 0.9);
	padding: 4px;
	border-radius: 8px;
	border: 1px solid var(--border-color);
}

.view-btn {
	width: 32px;
	height: 32px;
	border: none;
	border-radius: 6px;
	background: var(--bg-tertiary);
	color: var(--text-primary);
	font-size: 14px;
	cursor: pointer;
	transition: all 0.2s;
	display: flex;
	align-items: center;
	justify-content: center;
}

.view-btn:hover {
	background: var(--accent-green);
	transform: scale(1.1);
}

.view-btn:active {
	transform: scale(0.95);
}

/* Responsive - ocultar cubo 3D en móvil, solo botones */
@media screen and (max-width: 500px) {
	.viewcube-container {
		display: none;
	}

	#viewcube-widget {
		top: 55px;
		right: 5px;
	}
}

/* ===== JOYSTICKS VIRTUALES ===== */
#joysticks-container {
	pointer-events: none;
}

/* Botón toggle circular estilo AssistiveTouch */
.joystick-toggle {
	position: fixed;
	bottom: 100px;
	left: 15px;
	width: 50px;
	height: 50px;
	border-radius: 50%;
	background: rgba(30, 41, 59, 0.85);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	border: 2px solid var(--border-color);
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
	cursor: pointer;
	z-index: 700;
	pointer-events: auto;
	transition: all 0.2s;
	display: flex;
	align-items: center;
	justify-content: center;
}

.joystick-toggle:hover {
	transform: scale(1.1);
	border-color: var(--accent-cyan);
}

.joystick-toggle.active {
	background: var(--accent-green);
	border-color: var(--accent-green);
}

.toggle-icon {
	font-size: 22px;
}

/* Wrapper de joystick */
.joystick-wrapper {
	position: fixed;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 5px;
	z-index: 650;
	pointer-events: auto;
	transition: opacity 0.2s, transform 0.2s;
}

.joystick-wrapper.hidden {
	opacity: 0;
	pointer-events: none;
	transform: scale(0.8);
}

/* Posiciones */
.joystick-left {
	bottom: 100px;
	left: 80px;
}

.joystick-right {
	bottom: 100px;
	right: 20px;
}

/* Base del joystick */
.joystick-base {
	width: 100px;
	height: 100px;
	border-radius: 50%;
	background: radial-gradient(circle at center,
			rgba(30, 41, 59, 0.6) 0%,
			rgba(30, 41, 59, 0.8) 50%,
			rgba(30, 41, 59, 0.95) 100%);
	backdrop-filter: blur(5px);
	-webkit-backdrop-filter: blur(5px);
	border: 2px solid rgba(71, 85, 105, 0.6);
	box-shadow:
		0 4px 20px rgba(0, 0, 0, 0.4),
		inset 0 2px 10px rgba(0, 0, 0, 0.3);
	display: flex;
	align-items: center;
	justify-content: center;
	touch-action: none;
}

/* Stick del joystick */
.joystick-stick {
	width: 50px;
	height: 50px;
	border-radius: 50%;
	background: radial-gradient(circle at 30% 30%,
			rgba(255, 255, 255, 0.3) 0%,
			rgba(100, 116, 139, 0.8) 30%,
			rgba(71, 85, 105, 0.9) 70%,
			rgba(51, 65, 85, 1) 100%);
	border: 2px solid rgba(148, 163, 184, 0.5);
	box-shadow:
		0 3px 10px rgba(0, 0, 0, 0.4),
		inset 0 -2px 5px rgba(0, 0, 0, 0.3),
		inset 0 2px 5px rgba(255, 255, 255, 0.1);
	transition: transform 0.05s ease-out;
	cursor: grab;
}

.joystick-stick:active {
	cursor: grabbing;
	box-shadow:
		0 2px 8px rgba(0, 0, 0, 0.5),
		inset 0 -1px 3px rgba(0, 0, 0, 0.4);
}

/* Etiqueta del joystick */
.joystick-label {
	font-size: 10px;
	color: var(--text-secondary);
	text-transform: uppercase;
	letter-spacing: 1px;
	background: rgba(30, 41, 59, 0.8);
	padding: 2px 8px;
	border-radius: 4px;
}

/* Responsive - joysticks más pequeños en pantallas pequeñas */
@media screen and (max-width: 500px) {
	.joystick-base {
		width: 80px;
		height: 80px;
	}

	.joystick-stick {
		width: 40px;
		height: 40px;
	}

	.joystick-left {
		bottom: 90px;
		left: 70px;
	}

	.joystick-right {
		bottom: 90px;
		right: 15px;
	}

	.joystick-toggle {
		width: 44px;
		height: 44px;
		bottom: 90px;
	}
}

/* ===== SLIDER DE ZOOM VERTICAL ===== */
.zoom-slider-wrapper {
	position: fixed;
	left: 5px;
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	z-index: 650;
	pointer-events: auto;
	transition: opacity 0.2s, transform 0.2s;
}

.zoom-slider-wrapper.hidden {
	opacity: 0;
	pointer-events: none;
	transform: translateY(-50%) scale(0.8);
}

.zoom-slider-track {
	width: 30px;
	height: 180px;
	background: radial-gradient(circle at center,
			rgba(30, 41, 59, 0.6) 0%,
			rgba(30, 41, 59, 0.9) 100%);
	backdrop-filter: blur(5px);
	-webkit-backdrop-filter: blur(5px);
	border: 2px solid rgba(71, 85, 105, 0.6);
	border-radius: 15px;
	box-shadow:
		0 4px 20px rgba(0, 0, 0, 0.4),
		inset 0 2px 10px rgba(0, 0, 0, 0.3);
	position: relative;
	touch-action: none;
}

.zoom-slider-thumb {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: radial-gradient(circle at 30% 30%,
			rgba(255, 255, 255, 0.3) 0%,
			rgba(100, 116, 139, 0.8) 30%,
			rgba(71, 85, 105, 0.9) 70%,
			rgba(51, 65, 85, 1) 100%);
	border: 2px solid rgba(148, 163, 184, 0.5);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
	cursor: grab;
	transition: top 0.05s ease-out;
}

.zoom-slider-thumb:active {
	cursor: grabbing;
}

.zoom-label {
	font-size: 10px;
	color: var(--text-secondary);
	text-transform: uppercase;
	letter-spacing: 1px;
	background: rgba(30, 41, 59, 0.8);
	padding: 2px 6px;
	border-radius: 4px;
	writing-mode: vertical-rl;
	text-orientation: mixed;
}

/* Responsive para zoom slider */
@media screen and (max-width: 500px) {
	.zoom-slider-track {
		height: 140px;
		width: 26px;
	}

	.zoom-slider-thumb {
		width: 22px;
		height: 22px;
	}
}

/* ===== STATS.JS FPS MONITOR - Integrado con diseño ===== */
#stats {
	position: fixed !important;
	bottom: 110px !important;
	right: 10px !important;
	left: auto !important;
	top: auto !important;
	z-index: 900 !important;
	border-radius: 8px !important;
	overflow: hidden !important;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
	border: 1px solid var(--border-color) !important;
	opacity: 0.9 !important;
	transform: scale(0.9);
	transform-origin: bottom right;
}

#stats>div {
	background: var(--bg-secondary) !important;
	padding: 2px 4px 4px 4px !important;
}

#stats>div>div:first-child {
	font-family: 'Inter', 'Roboto', sans-serif !important;
	font-size: 10px !important;
	font-weight: 500 !important;
	color: var(--text-primary) !important;
	line-height: 14px !important;
}

/* Colores de las gráficas */
#fpsGraph,
#stats canvas {
	background: rgba(30, 41, 59, 0.8) !important;
}

/* Responsive - más pequeño en móvil */
@media screen and (max-width: 500px) {
	#stats {
		transform: scale(0.75);
		bottom: 55px !important;
		right: 5px !important;
	}
}