/* ══════════════════════════════════════════════════════════════════
   CECO FLEET v32 — CORE.CSS
   Reset, pantallas de arranque, estructura de la app (barra lateral,
   cabecera, vistas) y comportamiento responsive.
   ────────────────────────────────────────────────────────────────
   ✏️ LOS COLORES NO SE EDITAN AQUI: estan en /style.css (variables).
   ══════════════════════════════════════════════════════════════════ */

/* ── 1. RESET ────────────────────────────────────────────────── */

.ceco-app *,
.ceco-app *::before,
.ceco-app *::after { box-sizing: border-box; }

body.ceco-app {
	margin: 0;
	padding: 0;
	background: var(--bg-0);
	color: var(--text);
	font-family: var(--font);
	font-size: 14px;
	line-height: 1.5;
	overflow-x: hidden;
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
}

body.ceco-app.modal-open { overflow: hidden; }

.ceco-app img { max-width: 100%; height: auto; display: block; }
.ceco-app a { color: var(--accent); text-decoration: none; }
.ceco-app h1, .ceco-app h2, .ceco-app h3, .ceco-app h4, .ceco-app h5 {
	margin: 0 0 6px;
	line-height: 1.25;
	color: #fff;
	font-weight: 800;
}
.ceco-app p { margin: 0 0 6px; }

/* La barra de WordPress estorba en una app a pantalla completa. */
body.ceco-app #wpadminbar { display: none !important; }
body.ceco-app.ceco-mode-scan #ceco-page,
body.ceco-app.ceco-mode-beacon #ceco-page { padding: 0; }

/* Scrollbar discreta */
.ceco-app ::-webkit-scrollbar { width: 8px; height: 8px; }
.ceco-app ::-webkit-scrollbar-track { background: var(--bg-1); }
.ceco-app ::-webkit-scrollbar-thumb { background: var(--stroke-2); border-radius: 4px; }
.ceco-app ::-webkit-scrollbar-thumb:hover { background: var(--blue); }

/* Utilidades de color de texto */
.ceco-app .green { color: var(--emerald); }
.ceco-app .red { color: var(--red); }
.ceco-app .amber { color: var(--amber); }
.ceco-app .muted { color: var(--muted); }
.ceco-app .small { font-size: 11px; }
.ceco-app .empty {
	color: var(--muted);
	text-align: center;
	padding: 28px 14px;
	font-size: 13px;
}

/* ── 2. FONDO ANIMADO ────────────────────────────────────────── */

#particlesCanvas {
	position: fixed;
	inset: 0;
	z-index: 0;
	pointer-events: none;
	opacity: .55;
}

/* ── 3. PANTALLA DE CARGA ────────────────────────────────────── */

#cecoLoader {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: var(--bg-0);
	display: grid;
	place-items: center;
	transition: opacity .5s ease, visibility .5s ease;
}
#cecoLoader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-box { text-align: center; }
.loader-logo {
	width: 76px;
	height: 76px;
	margin: 0 auto 18px;
	border-radius: 2px;
	background: linear-gradient(135deg, var(--emerald), var(--blue));
	display: grid;
	place-items: center;
	font-size: 36px;
	animation: cecoPulse 1.6s ease-in-out infinite;
}
.loader-box h1 {
	font-size: 20px;
	letter-spacing: 3px;
	margin-bottom: 4px;
}
.loader-box p { color: var(--muted); font-size: 12px; letter-spacing: 1px; }
.loader-bar {
	width: 190px;
	height: 3px;
	margin: 20px auto 0;
	background: var(--bg-2);
	border-radius: 3px;
	overflow: hidden;
}
.loader-bar i {
	display: block;
	height: 100%;
	width: 40%;
	background: linear-gradient(90deg, var(--emerald), var(--blue));
	animation: cecoSlide 1.2s ease-in-out infinite;
}

@keyframes cecoPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes cecoSlide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* ── 4. PANTALLA DE ACCESO ───────────────────────────────────── */

#authScreen {
	position: relative;
	z-index: 2;
	min-height: 100vh;
	min-height: 100dvh;
	display: grid;
	place-items: center;
	padding: 24px 16px;
	background: radial-gradient(circle at 50% 0%, rgba(255, 140, 26, .10), transparent 60%);
}
#authScreen.hidden { display: none; }

.auth-card {
	width: 100%;
	max-width: 400px;
	background: var(--bg-1);
	border: 1px solid var(--stroke);
	border-radius: 2px;
	padding: 30px 24px;
	box-shadow: var(--shadow);
}
.auth-logo {
	width: 64px;
	height: 64px;
	margin: 0 auto 16px;
	border-radius: 2px;
	background: linear-gradient(135deg, var(--emerald), var(--blue));
	display: grid;
	place-items: center;
	font-size: 30px;
}
.auth-card h1 { font-size: 21px; text-align: center; letter-spacing: 1px; }
.auth-card > p { text-align: center; color: var(--muted); font-size: 12px; margin-bottom: 22px; }

.auth-error {
	display: none;
	background: var(--red-soft);
	border: 1px solid rgba(230, 95, 58, .35);
	color: #fca5a5;
	border-radius: var(--radius-sm);
	padding: 10px 12px;
	font-size: 12px;
	margin-bottom: 12px;
}
.auth-error.show { display: block; }

.auth-divider {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 18px 0 14px;
	color: var(--muted);
	font-size: 11px;
}
.auth-divider::before,
.auth-divider::after {
	content: '';
	flex: 1;
	height: 1px;
	background: var(--stroke);
}
.auth-foot {
	margin-top: 18px;
	text-align: center;
	color: var(--muted);
	font-size: 11px;
	line-height: 1.7;
}

/* ── 5. ESTRUCTURA DE LA APP ─────────────────────────────────── */

#app { display: none; position: relative; z-index: 2; }
#app.active { display: block; }

.app-header {
	position: sticky;
	top: 0;
	z-index: 60;
	height: var(--header-h);
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 0 14px;
	background: rgba(28, 23, 18, .92);
	backdrop-filter: blur(18px);
	border-bottom: 1px solid var(--stroke);
}

.hamburger {
	width: 40px;
	height: 40px;
	border: 1px solid var(--stroke);
	background: var(--bg-2);
	color: var(--text);
	border-radius: 2px;
	font-size: 17px;
	cursor: pointer;
	display: grid;
	place-items: center;
	flex-shrink: 0;
}
.hamburger:active { transform: scale(.94); }

.header-title { flex: 1; min-width: 0; }
.header-title h2 {
	font-size: 15px;
	margin: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.header-title span { font-size: 10.5px; color: var(--muted); }

.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
	width: 38px;
	height: 38px;
	border-radius: 2px;
	border: 1px solid var(--stroke);
	background: var(--bg-2);
	color: var(--text);
	font-size: 16px;
	cursor: pointer;
	display: grid;
	place-items: center;
}
.icon-btn:hover { border-color: var(--stroke-2); background: var(--bg-3); }
.icon-btn.primary {
	background: linear-gradient(135deg, var(--emerald), var(--blue));
	border-color: transparent;
	color: #1a1209;
}

#savingDot {
	display: none;
	align-items: center;
	gap: 5px;
	font-size: 10px;
	color: var(--amber);
	background: var(--amber-soft);
	border-radius: 999px;
	padding: 4px 9px;
}
#savingDot::before {
	content: '';
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--amber);
	animation: cecoPulse 1s infinite;
}

/* ── 6. BARRA LATERAL ────────────────────────────────────────── */

.sidebar {
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	width: var(--sidebar-w);
	z-index: 90;
	background: var(--bg-1);
	border-right: 1px solid var(--stroke);
	transform: translateX(-100%);
	transition: transform var(--t);
	display: flex;
	flex-direction: column;
	overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }

.sidebar-head {
	padding: 18px 16px;
	border-bottom: 1px solid var(--stroke);
	display: flex;
	align-items: center;
	gap: 11px;
}
.sidebar-logo {
	width: 40px;
	height: 40px;
	border-radius: 2px;
	background: linear-gradient(135deg, var(--emerald), var(--blue));
	display: grid;
	place-items: center;
	font-size: 19px;
	flex-shrink: 0;
}
.sidebar-head h3 { font-size: 14px; margin: 0; letter-spacing: 1px; }
.sidebar-head span { font-size: 10px; color: var(--muted); }

.sidebar-user {
	display: flex;
	align-items: center;
	gap: 11px;
	padding: 14px 16px;
	border-bottom: 1px solid var(--stroke);
	cursor: pointer;
}
.sidebar-user:hover { background: var(--bg-2); }
.user-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	/* Avatares: tierra, para no competir con el naranja de accion. */
	background: linear-gradient(135deg, #7a6349, #3d3125);
	display: grid;
	place-items: center;
	font-weight: 800;
	font-size: 13px;
	color: #fff;
	overflow: hidden;
	flex-shrink: 0;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user b { display: block; font-size: 13px; color: #fff; }
.sidebar-user small { font-size: 9.5px; color: var(--emerald); letter-spacing: 1px; }

.sidebar-nav { padding: 10px 8px; flex: 1; }
.nav-section {
	font-size: 9.5px;
	letter-spacing: 1.5px;
	color: var(--muted);
	padding: 12px 10px 6px;
}

.nav-btn {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 11px;
	padding: 11px 12px;
	margin-bottom: 3px;
	background: transparent;
	border: none;
	border-radius: var(--radius-sm);
	color: var(--text-2);
	font-size: 13px;
	font-family: inherit;
	font-weight: 600;
	text-align: left;
	cursor: pointer;
	transition: background var(--t-fast), color var(--t-fast);
}
.nav-btn:hover { background: var(--bg-2); color: #fff; }
.nav-btn.active {
	background: var(--emerald-soft);
	color: var(--emerald);
	box-shadow: inset 3px 0 0 var(--emerald);
}
.nav-btn .nav-icon { font-size: 16px; width: 22px; text-align: center; }
.nav-btn .nav-badge {
	margin-left: auto;
	background: var(--red);
	color: #fff;
	font-size: 9.5px;
	font-weight: 800;
	border-radius: 999px;
	padding: 2px 7px;
}

.sidebar-foot {
	padding: 12px 16px;
	border-top: 1px solid var(--stroke);
	font-size: 10px;
	color: var(--muted);
}

.overlay {
	position: fixed;
	inset: 0;
	z-index: 80;
	background: rgba(2, 6, 15, .7);
	backdrop-filter: blur(3px);
	opacity: 0;
	visibility: hidden;
	transition: opacity var(--t), visibility var(--t);
}
.overlay.active { opacity: 1; visibility: visible; }

/* ── 7. CONTENIDO Y VISTAS ───────────────────────────────────── */

.app-main {
	padding: 16px 14px 96px;
	max-width: 1500px;
	margin: 0 auto;
}

.view { display: none; animation: cecoFade .3s ease; }
.view.active { display: block; }

@keyframes cecoFade {
	from { opacity: 0; transform: translateY(8px); }
	to { opacity: 1; transform: translateY(0); }
}

.view-head {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
	margin-bottom: 14px;
}
.view-head h3 { font-size: 17px; margin: 0; }
.view-head .count {
	font-size: 11px;
	color: var(--muted);
	background: var(--bg-2);
	border-radius: 999px;
	padding: 3px 10px;
}
.view-head .spacer { flex: 1; }

.section-title {
	font-size: 12.5px;
	color: #fff;
	margin: 18px 0 8px;
	display: flex;
	align-items: center;
	gap: 8px;
}
.mini-title {
	display: block;
	font-size: 11px;
	color: #fff;
	margin: 12px 0 6px;
	letter-spacing: .5px;
}

/* ── 8. BARRA INFERIOR (movil) ───────────────────────────────── */

.bottom-nav {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 70;
	display: flex;
	align-items: center;
	justify-content: space-around;
	height: 62px;
	padding-bottom: env(safe-area-inset-bottom);
	background: rgba(28, 23, 18, .96);
	backdrop-filter: blur(18px);
	border-top: 1px solid var(--stroke);
}
.bottom-nav .nav-btn {
	flex-direction: column;
	gap: 2px;
	padding: 6px 4px;
	margin: 0;
	font-size: 9.5px;
	border-radius: 2px;
	width: auto;
	min-width: 58px;
	text-align: center;
	align-items: center;
}
.bottom-nav .nav-btn.active { box-shadow: none; background: transparent; }
.bottom-nav .nav-btn .nav-icon { font-size: 19px; width: auto; }

.scan-fab {
	width: 58px;
	height: 58px;
	margin-top: -22px;
	border: none;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--emerald), var(--blue));
	color: #1a1209;
	font-size: 24px;
	cursor: pointer;
	box-shadow: 0 10px 30px rgba(255, 140, 26, .45);
	flex-shrink: 0;
}
.scan-fab:active { transform: scale(.92); }

/* ── 9. MODO BEACON (telefono en la maquina) ─────────────────── */

#beaconScreen {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 9000;
	background: var(--bg-0);
	padding: 30px 20px;
	text-align: center;
	overflow-y: auto;
}
#beaconScreen.active { display: block; }

.beacon-icon {
	width: 110px;
	height: 110px;
	margin: 30px auto 20px;
	border-radius: 50%;
	background: var(--purple-soft);
	border: 3px solid var(--purple);
	display: grid;
	place-items: center;
	font-size: 48px;
	animation: cecoRing 2s ease-out infinite;
}
@keyframes cecoRing {
	0% { box-shadow: 0 0 0 0 rgba(167,139,250,.5); }
	100% { box-shadow: 0 0 0 34px rgba(167,139,250,0); }
}

#beaconCode {
	font-size: 30px;
	font-weight: 900;
	letter-spacing: 2px;
	color: #fff;
	margin-bottom: 6px;
}
.beacon-status {
	display: inline-block;
	margin: 14px auto;
	padding: 10px 18px;
	border-radius: 999px;
	background: var(--bg-2);
	border: 1px solid var(--stroke);
	font-size: 12px;
	color: var(--text-2);
	max-width: 100%;
	word-break: break-word;
}
.beacon-status.live { background: var(--emerald-soft); border-color: var(--emerald); color: var(--emerald); }
.beacon-status.error { background: var(--red-soft); border-color: var(--red); color: #fca5a5; }
.beacon-status.wait { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }

.beacon-help {
	max-width: 420px;
	margin: 22px auto 0;
	text-align: left;
	background: var(--bg-1);
	border: 1px solid var(--stroke);
	border-radius: var(--radius);
	padding: 16px;
	font-size: 12px;
	color: var(--text-2);
	line-height: 1.8;
}

/* ── 10. RESPONSIVE ──────────────────────────────────────────── */

@media (min-width: 1024px) {
	.sidebar { transform: translateX(0); }
	.overlay { display: none; }
	.hamburger { display: none; }
	.app-header { padding-left: calc(var(--sidebar-w) + 18px); }
	.app-main { padding: 20px 24px 40px calc(var(--sidebar-w) + 24px); }
	.bottom-nav { display: none; }
}

@media (max-width: 1023px) {
	.app-main { padding-bottom: 96px; }
}

@media (max-width: 480px) {
	.app-main { padding-left: 11px; padding-right: 11px; }
	.view-head h3 { font-size: 15px; }
}

/* Menos movimiento para quien lo prefiera (accesibilidad). */
@media (prefers-reduced-motion: reduce) {
	.ceco-app *,
	.ceco-app *::before,
	.ceco-app *::after {
		animation-duration: .01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: .01ms !important;
	}
}

/* ── 11. IMPRESION ───────────────────────────────────────────── */

@media print {
	.app-header, .sidebar, .bottom-nav, .overlay,
	.chat-fab, .chat-panel, #particlesCanvas, .icon-btn { display: none !important; }
	.app-main { padding: 0 !important; }
	body.ceco-app { background: #fff; color: #000; }
}

/* ══════════════════════════════════════════════════════════════════
   SALIDA DE EMERGENCIA  (v52)
   ──────────────────────────────────────────────────────────────────
   Sale cuando la sesion caduco y recargar no basta (el caso de
   "llevo dos semanas sin entrar y no me deja").

   ⚠️ COLORES ESCRITOS A PELO, SIN VARIABLES, Y TIPO DEL SISTEMA.
   No es un descuido: este cartel tiene que verse AUNQUE el CSS de
   la app no haya cargado o las fuentes no lleguen. Si usara
   var(--bg-1) y esa variable no existiera, saldria transparente,
   que es justo cuando mas falta hace que se vea.
   ══════════════════════════════════════════════════════════════════ */

.ceco-salida {
	position: fixed;
	inset: 0;
	z-index: 2147483647;   /* Por encima de todo, incluidos los modales. */
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 28px 22px;
	text-align: center;
	background: #13100c;
	color: #f2ece0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
	font-size: 16px;
	line-height: 1.5;
}

.ceco-salida p { margin: 0; max-width: 30em; }
.ceco-salida p b { font-size: 20px; color: #ff8c1a; }

.ceco-salida button {
	margin-top: 10px;
	padding: 15px 30px;
	border: 0;
	border-radius: 2px;
	background: #ff8c1a;
	color: #13100c;
	font: inherit;
	font-size: 16px;
	font-weight: 700;
	letter-spacing: .04em;
	text-transform: uppercase;
	cursor: pointer;
	/* Dedo con guante en una obra: el boton tiene que ser grande. */
	min-height: 52px;
	min-width: 220px;
}

.ceco-salida button:active { background: #d96f00; }
