/* global.css
 * Reset, tipografia base, botones, formularios, badges y utilidades.
 * Los colores siempre provienen de variables.css.
 */

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

html {
	scroll-behavior: smooth;
	-webkit-text-size-adjust: 100%;
}

body {
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-body);
	font-size: var(--fs-base);
	line-height: 1.65;
	overflow-x: hidden;
	transition: background var(--t-slow), color var(--t-base);
	-webkit-font-smoothing: antialiased;
}

a {
	color: inherit;
	text-decoration: none;
}

button {
	cursor: pointer;
	border: none;
	background: none;
	font-family: inherit;
	font-size: inherit;
	color: inherit;
}

ul,
ol {
	list-style: none;
}

img,
svg {
	max-width: 100%;
	display: block;
}

/*
 * El atributo `hidden` debe ganar siempre.
 * El reset de arriba pone `display: block` a `img` y `svg`, y una regla de
 * autor vence a la del navegador: sin esto, ocultar una imagen no la oculta.
 */
[hidden] {
	display: none !important; /* NOSONAR: anula el reset de display de arriba */
}

/* ---------- Tipografia ---------- */

h1,
h2,
h3,
h4,
h5 {
	font-family: var(--font-display);
	font-weight: var(--wt-disp);
	letter-spacing: var(--letter-disp);
	line-height: 1.1;
	color: var(--text);
	transition: color var(--t-base);
}

h1 {
	font-size: var(--fs-4xl);
}

h2 {
	font-size: var(--fs-3xl);
}

h3 {
	font-size: var(--fs-2xl);
}

h4 {
	font-size: var(--fs-xl);
}

p {
	line-height: 1.72;
}

code,
kbd,
pre {
	font-family: var(--font-display);
	font-size: 0.92em;
}

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 3px;
	border-radius: 4px;
}

/* ---------- Contenedor ---------- */

.container {
	width: 100%;
	max-width: var(--container);
	margin: 0 auto;
	padding: 0 28px;
}

/* ---------- Antetitulo ---------- */

.eyebrow {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	font-family: var(--font-body);
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: var(--accent);
	margin-bottom: var(--space-4);
}

.eyebrow__bar {
	display: inline-block;
	width: 20px;
	height: 2px;
	background: var(--accent);
	border-radius: var(--radius-pill);
}

.accent {
	color: var(--accent);
}

.muted {
	color: var(--text-2);
}

.dim {
	color: var(--text-3);
}

.mono {
	font-family: var(--font-display);
}

/* Celda de tabla que no debe partirse: fechas cortas, alcance, conteos. */
.nowrap {
	white-space: nowrap;
}

/* ---------- Botones ---------- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-2);
	padding: 12px 24px;
	font-family: var(--font-body);
	font-size: var(--fs-sm);
	font-weight: 700;
	border-radius: var(--radius);
	cursor: pointer;
	transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast),
		background var(--t-fast), color var(--t-fast);
	white-space: nowrap;
	border: 1px solid transparent;
}

.btn--primary {
	background: var(--accent-deep);
	color: #fff;
	border-color: var(--accent-deep);
	box-shadow: var(--shadow-btn);
}

.btn--primary:hover {
	transform: translateY(-1px);
	background: var(--accent);
	border-color: var(--accent);
}

.btn--outline {
	border-color: var(--border-strong);
	color: var(--text);
	background: transparent;
}

.btn--outline:hover {
	border-color: var(--accent);
	color: var(--accent);
}

.btn--ghost {
	color: var(--text-2);
	border-color: transparent;
}

.btn--ghost:hover {
	color: var(--text);
	background: var(--surface-2);
}

.btn--block {
	width: 100%;
}

.btn--sm {
	padding: 8px 16px;
	font-size: var(--fs-xs);
}

.btn[disabled],
.btn[aria-disabled='true'] {
	opacity: 0.55;
	cursor: not-allowed;
	transform: none;
}

/* ---------- Formularios ---------- */

.field {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	margin-bottom: var(--space-4);
}

.field__label {
	font-size: var(--fs-xs);
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--text-2);
}

.field__hint {
	font-size: var(--fs-xs);
	color: var(--text-3);
}

.input {
	width: 100%;
	padding: 13px 16px;
	font-family: var(--font-body);
	font-size: var(--fs-base);
	color: var(--text);
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}

.input::placeholder {
	color: var(--text-3);
}

.input:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-glow);
}

.input:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Campo con boton para mostrar la contrasena. */
.field__control {
	position: relative;
	display: flex;
	align-items: center;
}

.input--with-toggle {
	padding-right: 78px;
}

.field__toggle {
	position: absolute;
	right: 6px;
	padding: 6px 10px;
	font-size: var(--fs-xs);
	font-weight: 700;
	color: var(--accent);
	border-radius: var(--radius);
	background: transparent;
	transition: color var(--t-fast), background var(--t-fast);
}

.field__toggle:hover {
	color: var(--text);
	background: var(--surface-2);
}

/* ---------- Etiquetas de estado ---------- */

.tag {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 12px;
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	border-radius: var(--radius-pill);
	background: var(--surface-3);
	color: var(--text-2);
	border: 1px solid var(--border);
	/* Una etiqueta de dos palabras no se parte: "al dia" no es "al" y "dia". */
	white-space: nowrap;
}

.tag--ok {
	background: var(--success-bg);
	color: var(--success);
	border-color: transparent;
}

.tag--warn {
	background: var(--warning-bg);
	color: var(--warning);
	border-color: transparent;
}

.tag--danger {
	background: var(--danger-bg);
	color: var(--danger);
	border-color: transparent;
}

.tag--accent {
	background: var(--accent-glow);
	color: var(--accent);
	border-color: transparent;
}

/* ---------- Tarjetas ---------- */

.card {
	background: var(--gradient-panel);
	border: 1px solid var(--border);
	border-radius: var(--radius-xl);
	padding: var(--space-5);
	box-shadow: var(--shadow-card);
	transition: box-shadow var(--t-base), transform var(--t-base);
}

.card--hover:hover {
	box-shadow: var(--shadow-card-hover);
	transform: translateY(-2px);
}

/* ---------- Tablas ---------- */

.table-wrap {
	overflow-x: auto;
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	background: var(--surface);
}

.table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--fs-sm);
}

.table th {
	text-align: left;
	padding: var(--space-3) var(--space-4);
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--text-2);
	background: var(--surface-2);
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}

.table td {
	padding: var(--space-3) var(--space-4);
	border-bottom: 1px solid var(--border);
	color: var(--text);
	vertical-align: middle;
}

.table tbody tr:last-child td {
	border-bottom: none;
}

.table tbody tr:hover {
	background: var(--surface-2);
}

/*
 * Acciones dentro de una fila.
 * La tabla de flota tiene dos acciones por vehiculo (historial y revocar) y
 * apiladas ocupan el alto de dos filas de datos.
 */
.row-actions {
	display: flex;
	gap: var(--space-2);
	align-items: center;
	flex-wrap: wrap;
}

.row-actions form {
	margin: 0;
}

/* ---------- Interruptor ---------- */

/*
 * Interruptor de un ajuste booleano.
 *
 * Es un `<button>` con `role="switch"`, no un checkbox: dentro de una tabla
 * cada fila necesita su propio `<form>` y un boton de envio se comporta igual
 * sin JavaScript y sin depender de que el formulario este bien asociado.
 */
.switch {
	display: inline-flex;
	align-items: center;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
	flex-shrink: 0;
}

.switch__track {
	position: relative;
	display: block;
	width: 38px;
	height: 21px;
	border-radius: var(--radius-pill);
	background: var(--surface-3);
	border: 1px solid var(--border-strong);
	transition: background var(--t-fast), border-color var(--t-fast);
}

.switch__thumb {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 15px;
	height: 15px;
	border-radius: 50%;
	background: var(--text-3);
	transition: transform var(--t-fast), background var(--t-fast);
}

.switch:hover .switch__track {
	border-color: var(--accent);
}

.switch[aria-checked='true'] .switch__track {
	background: var(--accent-glow);
	border-color: var(--accent);
}

.switch[aria-checked='true'] .switch__thumb {
	transform: translateX(17px);
	background: var(--accent);
}

.switch:focus-visible {
	outline: none;
}

.switch:focus-visible .switch__track {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* Etiqueta que acompana al interruptor en la tabla de flota. */
.cfg-form {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	margin: 0;
}

.cfg-label {
	font-size: var(--fs-xs);
	font-weight: 700;
	letter-spacing: 0.03em;
	white-space: nowrap;
	color: var(--text-3);
}

.cfg-label--on {
	color: var(--accent);
}

/* ---------- Lista de definiciones ---------- */

.defs {
	display: grid;
	gap: var(--space-3);
}

.defs__row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: var(--space-4);
	padding-bottom: var(--space-3);
	border-bottom: 1px solid var(--border);
}

.defs__row:last-child {
	border-bottom: none;
	padding-bottom: 0;
}

.defs__key {
	font-size: var(--fs-xs);
	font-weight: 800;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--text-2);
}

.defs__value {
	font-family: var(--font-display);
	font-size: var(--fs-sm);
	color: var(--text);
	text-align: right;
	word-break: break-all;
}

/* ---------- Accesibilidad ---------- */

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 100;
	padding: var(--space-3) var(--space-5);
	background: var(--accent-deep);
	color: #fff;
	border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
	left: 0;
}

/*
 * Menos movimiento para quien lo pidio en su sistema.
 * Aqui `!important` es necesario: el objetivo es anular animaciones y
 * transiciones declaradas en cualquier otro lugar de la hoja.
 */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important; /* NOSONAR: anula animaciones ajenas */
		transition-duration: 0.01ms !important; /* NOSONAR: anula transiciones ajenas */
		scroll-behavior: auto !important; /* NOSONAR: anula el desplazamiento suave */
	}
}

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

::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

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

::-webkit-scrollbar-thumb {
	background: var(--border-strong);
	border-radius: var(--radius-pill);
}

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