/* ═══════════════════════════════════════════════════════════════════
   BASE — typography, surfaces, controls, buttons
   Loads after estilos.css and after the per-component vendor CSS, so
   plain class selectors here win on source order without !important.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Page ───────────────────────────────────────────────────────────── */

html, body {
	font-family: var(--font-sans);
	background: var(--bg);
	color: var(--ink);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
}

body { font-size: var(--fs-base); }

::selection {
	background: var(--brand-200);
	color: var(--nav-900);
}

/* Slim scrollbars on light surfaces */
body ::-webkit-scrollbar { width: 10px; height: 10px; }
body ::-webkit-scrollbar-track { background: transparent; }
body ::-webkit-scrollbar-thumb {
	background: var(--line-strong);
	border-radius: var(--r-pill);
	border: 2px solid transparent;
	background-clip: content-box;
}
body ::-webkit-scrollbar-thumb:hover { background-clip: border-box; }


/* ── Focus ──────────────────────────────────────────────────────────── */
/* estilos.css sets `*:focus { outline: none }`, which leaves keyboard
   users with no indicator at all. Restore it on :focus-visible only, so
   mouse clicks stay quiet while Tab navigation is clearly visible. */

/* No border-radius here: setting it on focus would reshape whatever got
   focused (the circular row actions turned into rounded squares). The
   outline already follows the element's own radius in current browsers. */
:focus-visible {
	outline: 2px solid var(--brand-500);
	outline-offset: 2px;
}

:where(.box-body, .sub_abm_modal) input:focus-visible,
:where(.box-body, .sub_abm_modal) select:focus-visible,
:where(.box-body, .sub_abm_modal) textarea:focus-visible,
.input_text:focus-visible {
	outline: none;
	border-color: var(--brand-500);
	box-shadow: var(--focus-ring);
}


/* ── Headings ───────────────────────────────────────────────────────── */

h2 {
	font-size: var(--fs-2xl);
	font-weight: 700;
	letter-spacing: -.02em;
	text-transform: none;         /* was uppercase — heavy at 27px */
	color: var(--ink);
	line-height: 1.2;
}

/* Breadcrumb only. Views render it as the `h3` that sits directly in the
   content frame ("Productos > Editar"). A bare `h3` selector also hit real
   section titles deeper in the page (agenda config, home widgets) and
   washed them out to small grey text. */
.contenedor-principal > h3 {
	font-size: var(--fs-md);
	font-weight: 600;
	letter-spacing: 0;
	color: var(--ink-mute);
	line-height: 1.5;
}

.contenedor-principal > h3 a {
	font-weight: 600;
	color: var(--ink-soft);
	transition: color var(--dur-1) var(--ease-out);
}

.contenedor-principal > h3 a:hover { color: var(--brand-600); }   /* text: 7:1 */


/* ── Card (.box) ────────────────────────────────────────────────────── */

/* No `overflow: hidden` here on purpose. It would clip absolutely
   positioned children (the save dropdown, inline pickers) and would turn
   the card into a scroll container, which breaks `position: sticky` on
   the submit bar. The corners are rounded on the children instead. */
.box {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--r-lg);
	box-shadow: var(--sh-1);
}

/* Was solid navy with white text. A light header with dark ink reads as
   one continuous card instead of a stack of dark bars down the page. */
.box-head {
	padding: 14px 18px;
	background: var(--surface);
	border-bottom: 1px solid var(--line);
	border-radius: 0;
	color: var(--ink);
	font-family: var(--font-sans);
	font-size: var(--fs-md);
	font-weight: 600;
	letter-spacing: .01em;
}

/* Several views render `<div class="box-head"></div>` purely as a spacer.
   Empty means no border and no padding, so it collapses cleanly. */
.box-head:empty {
	display: none;
}

.box-body {
	font-size: var(--fs-base);
	color: var(--ink);
	padding: 22px 18px;
	line-height: 1.5;
	box-shadow: none;              /* drop the old 94px ambient blur */
	background: var(--surface);
	border-radius: 0;
}

/* Corners follow position, not class. A card can open with a head, with
   a body directly, or with a head collapsed by `:empty`; whichever child
   is actually first or last takes the rounded corners so its square
   background never paints over the card's curved border. The inner
   radius is the outer one minus the 1px border. */
.box > :first-child,
.box > .box-head:empty + * {
	border-top-left-radius: calc(var(--r-lg) - 1px);
	border-top-right-radius: calc(var(--r-lg) - 1px);
}

.box > :last-child {
	border-bottom-left-radius: calc(var(--r-lg) - 1px);
	border-bottom-right-radius: calc(var(--r-lg) - 1px);
}


/* ── Buttons ────────────────────────────────────────────────────────── */

.btn {
	position: relative;
	overflow: hidden;              /* clips the ripple */
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	padding: 9px 16px;
	margin: 5px 5px;
	font-family: var(--font-sans);
	font-size: var(--fs-md);
	font-weight: 600;
	line-height: 1.25;
	letter-spacing: .01em;
	text-transform: none;          /* was uppercase */
	text-shadow: none;
	color: #fff;
	border: 1px solid transparent;
	border-radius: var(--r-sm);
	box-shadow: var(--sh-1);
	cursor: pointer;
	transition: transform var(--dur-1) var(--ease-out),
	            box-shadow var(--dur-1) var(--ease-out),
	            filter var(--dur-1) var(--ease-out),
	            background-color var(--dur-1) var(--ease-out);
}

.btn:hover {
	transform: translateY(-1px);
	box-shadow: var(--sh-2);
	filter: brightness(1.04);
}

.btn:active {
	transform: translateY(0) scale(.98);
	box-shadow: var(--sh-1);
	filter: brightness(.96);
}

.btn:focus-visible {
	outline: none;
	box-shadow: var(--sh-1), var(--focus-ring);
}

.btn[disabled],
.btn.disabled,
.btn.btn-icon-disabled {
	opacity: .5;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
	filter: none;
}

.btn-primary {
	background-image: var(--brand-fill);
	background-color: var(--brand-500);
	border-color: transparent;
}

.btn-primary:hover { background-image: var(--brand-fill-hover); }

.btn-success { background-color: var(--ok);     border-color: transparent; }
.btn-info    { background-color: var(--info);   border-color: transparent; }
.btn-warning { background-color: var(--warn);   border-color: transparent; }
.btn-danger  { background-color: var(--danger); border-color: transparent; border-radius: var(--r-sm); }

.btn-light {
	background: var(--surface);
	border: 1px solid var(--line-strong);
	border-radius: var(--r-sm);
	color: var(--ink);
	font-weight: 600;
	box-shadow: var(--sh-1);
	text-shadow: none;
}

.btn-light:hover {
	background: var(--bg-sunken);
	border-color: var(--brand-300);
	color: var(--brand-600);
}

.btn-dark-action {
	background: var(--nav-800);
	color: #fff;
	font-weight: 600;
	border-radius: var(--r-sm);
}

.btn-dark-action:hover { background: var(--nav-700); }

/* Secondary: bordered, brand-coloured text. Previously defined inline by
   componentes/sub_abm4.php as a navy gradient, and only on pages that
   rendered that component. It is the only view using the class (the
   tools use their own `.wc-btn-secondary` / `.mp-btn-secondary`). */
.btn-secondary {
	background: var(--surface);
	border: 1px solid var(--line-strong);
	color: var(--brand-600);
	text-shadow: none;
	box-shadow: var(--sh-1);
}

.btn-secondary:hover {
	background: var(--brand-50);
	border-color: var(--brand-300);
	color: var(--brand-700);
	filter: none;
}

/* New variant — low-emphasis action that doesn't compete with primary */
.btn-ghost {
	background: transparent;
	border: 1px solid var(--line-strong);
	color: var(--ink-soft);
	box-shadow: none;
	text-shadow: none;
}

.btn-ghost:hover {
	background: var(--brand-50);
	border-color: var(--brand-300);
	color: var(--brand-600);
	filter: none;
}

/* Inline loading state — the label is replaced by a spinner while a
   submit is in flight. Purely presentational: JS only toggles a class. */
.btn.is-loading {
	color: transparent;
	pointer-events: none;
}

.btn.is-loading::after {
	content: '';
	position: absolute;
	top: 50%; left: 50%;
	width: 15px; height: 15px;
	margin: -8px 0 0 -8px;
	border: 2px solid rgba(255,255,255,.35);
	border-top-color: #fff;
	border-radius: 50%;
	animation: ui-spin .7s linear infinite;
}


/* ── Form controls ──────────────────────────────────────────────────── */

.control-group {
	margin: 5px 5px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--line);
}

.control-group label {
	display: block;
	padding: 0 0 6px;
	font-size: var(--fs-sm);
	font-weight: 600;
	letter-spacing: .01em;
	color: var(--ink-soft);
}

.control-group .aclaracion {
	font-size: var(--fs-sm);
	padding: 5px 0 12px;
	color: var(--ink-mute);
	line-height: 1.45;
}

/* Scope: the engine's own surfaces only. The tool SPAs (.wc-root, .mp-root,
   .wa-root) style their inputs with single-class selectors such as
   `.mp-search-input` (0,1,0). A bare `input[type="search"]` (0,1,1) loaded
   after them would win and restyle every tool field. `:where()` adds no
   specificity, so these rules stay at (0,1,1): enough to beat the legacy
   `input[type="text"]` in estilos.css by source order, and they never
   reach outside `.box-body` / the sub-ABM modal. */
:where(.box-body, .sub_abm_modal) input[type="text"],
:where(.box-body, .sub_abm_modal) input[type="number"],
:where(.box-body, .sub_abm_modal) input[type="email"],
:where(.box-body, .sub_abm_modal) input[type="password"],
:where(.box-body, .sub_abm_modal) input[type="search"],
:where(.box-body, .sub_abm_modal) input[type="tel"],
:where(.box-body, .sub_abm_modal) input[type="date"],
:where(.box-body, .sub_abm_modal) input[type="time"],
.control-group .input_text,
.control-group textarea,
.control-group select {
	font-family: var(--font-sans);
	font-size: var(--fs-base);
	line-height: 1.4;
	color: var(--ink);
	background: var(--field-bg);   /* grey well at rest, white on focus (below) */
	border: 1px solid var(--field-border);
	border-radius: var(--r-sm);
	transition: border-color var(--dur-1) var(--ease-out),
	            box-shadow var(--dur-1) var(--ease-out),
	            background-color var(--dur-1) var(--ease-out);
}

:where(.box-body, .sub_abm_modal) input[type="text"],
:where(.box-body, .sub_abm_modal) input[type="number"],
:where(.box-body, .sub_abm_modal) input[type="email"],
:where(.box-body, .sub_abm_modal) input[type="password"],
:where(.box-body, .sub_abm_modal) input[type="search"],
:where(.box-body, .sub_abm_modal) input[type="tel"] {
	padding: 9px 11px;
}

.control-group .input_text {
	width: 100%;
	padding: 9px 11px;
	margin-bottom: 4px;
}

.control-group textarea {
	width: 100%;
	padding: 10px 11px;
	min-height: 140px;
	line-height: 1.55;
}

.control-group select {
	padding: 9px 11px;
}

/* Same scope as above. A bare `input:hover` / `input:focus` also landed on
   checkboxes, radios, range sliders and every tool SPA field. */
:where(.box-body, .sub_abm_modal) input:not([type="checkbox"]):not([type="radio"]):hover:not(:focus),
.control-group .input_text:hover:not(:focus),
.control-group textarea:hover:not(:focus),
.control-group select:hover:not(:focus) {
	border-color: var(--brand-300);
}

:where(.box-body, .sub_abm_modal) input:not([type="checkbox"]):not([type="radio"]):focus,
.control-group .input_text:focus,
.control-group textarea:focus,
.control-group select:focus {
	background-color: var(--surface);
	border-color: var(--brand-500);
	box-shadow: var(--focus-ring);
}

:where(.box-body, .sub_abm_modal) input::placeholder,
:where(.box-body, .sub_abm_modal) textarea::placeholder { color: var(--ink-mute); }   /* text: needs 4.5:1 */

:where(.box-body, .sub_abm_modal) input[disabled],
:where(.box-body, .sub_abm_modal) input[readonly],
:where(.box-body, .sub_abm_modal) select[disabled],
:where(.box-body, .sub_abm_modal) textarea[disabled] {
	background: var(--bg-sunken);
	color: var(--ink-mute);
	cursor: not-allowed;
}

.control-group label.check,
.control-group label.radio-label,
.control-group .radio {
	font-weight: 500;
	color: var(--ink);
	font-size: var(--fs-base);
}

:where(.box-body, .sub_abm_modal) input[type="checkbox"],
:where(.box-body, .sub_abm_modal) input[type="radio"] {
	accent-color: var(--brand-500);
	width: 16px;
	height: 16px;
	vertical-align: -2px;
	cursor: pointer;
}


/* Touch screens: fields at 16px or more. Easier to read, and iOS zooms
   the whole page on focus when a field is smaller. estilos.css shrinks the
   filter fields to 13px with !important on mobile, hence !important there. */
@media (max-width: 768px) {
	:where(.box-body, .sub_abm_modal) input[type="text"],
	:where(.box-body, .sub_abm_modal) input[type="number"],
	:where(.box-body, .sub_abm_modal) input[type="email"],
	:where(.box-body, .sub_abm_modal) input[type="password"],
	:where(.box-body, .sub_abm_modal) input[type="search"],
	:where(.box-body, .sub_abm_modal) input[type="tel"],
	.control-group .input_text,
	.control-group textarea,
	.control-group select {
		font-size: max(16px, var(--fs-base));
	}

	.buscador input[type="text"],
	.buscador input[type="number"],
	.buscador input[type="date"],
	.buscador select,
	.buscador .input_text {
		font-size: max(16px, var(--fs-base)) !important;
	}
}


/* ── Numbers ────────────────────────────────────────────────────────── */
/* Tabular figures keep columns of money and counts aligned. */

table td,
table th,
.ui-num,
[class*="total"],
[class*="precio"] {
	font-variant-numeric: tabular-nums;
	font-feature-settings: 'tnum' 1;
}


/* ── Messages ───────────────────────────────────────────────────────── */

#infoMessage {
	margin: 14px 0;
	padding: 11px 14px;
	background: var(--info-soft);
	border: 1px solid var(--info-border);
	border-radius: var(--r-md);
	color: var(--info);
	font-size: var(--fs-md);
	font-weight: 500;
}

.errores-validacion {
	margin-bottom: 12px;
	color: var(--danger);
	font-size: var(--fs-md);
}
