/**
 * Calculadora de Envíos — estilos del frontend
 *
 * Diseño: tarjeta limpia con secciones, selector de modalidad en tarjetas,
 * campos etiquetados y desglose destacado.
 *
 * Los estilos se prefijan siempre con `.cde-calc` para no chocar con el tema
 * y se refuerzan con `!important` en los elementos que los temas suelen
 * redefinir (botones, inputs y campos), porque si no la calculadora aparece
 * con los estilos del tema en lugar de los suyos.
 */

.cde-calc {
	/* Colores de marca: azul oscuro (logo) y rojo (boton). */
	--cde-primary: #1b3a7d;
	--cde-primary-dark: #142c60;
	--cde-primary-soft: rgba(27, 58, 125, 0.07);
	--cde-red: #d62828;
	--cde-red-dark: #b81f1f;
	--cde-accent: #1b3a7d;
	--cde-text: #1d2733;
	--cde-muted: #5b6b7f;
	--cde-line: #dfe4ec;
	--cde-line-soft: #f2f5f9;
	--cde-bg: #f8fafc;
	--cde-radius: 14px;
	--cde-shadow: 0 1px 2px rgba(27, 58, 125, 0.04), 0 8px 24px rgba(27, 58, 125, 0.07);

	box-sizing: border-box;
	width: 100%;
	margin: 28px 0;
	padding: 28px;
	border: 1px solid var(--cde-line);
	border-radius: 18px;
	background: #fff;
	color: var(--cde-text);
	box-shadow: var(--cde-shadow);
	font-family: inherit;
	font-size: 15px;
	line-height: 1.55;
	text-align: left;
}

.cde-calc *,
.cde-calc *::before,
.cde-calc *::after {
	box-sizing: border-box;
}

.cde-calc .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* ---------------- Título ---------------- */

.cde-calc__title {
	margin: 0 0 22px !important;
	padding: 0 !important;
	font-size: 24px !important;
	font-weight: 700 !important;
	line-height: 1.25 !important;
	text-align: center !important;
	color: var(--cde-accent) !important;
}

/* ---------------- Modalidades ---------------- */

.cde-calc .cde-modes {
	display: grid !important;
	grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
	gap: 12px;
	margin: 0 0 24px !important;
	padding: 0 !important;
	border: 0 !important;
}

.cde-calc .cde-mode {
	position: relative;
	display: flex !important;
	align-items: flex-start;
	gap: 12px;
	margin: 0 !important;
	padding: 16px !important;
	border: 2px solid var(--cde-line) !important;
	border-radius: var(--cde-radius) !important;
	background: #fff !important;
	box-shadow: none !important;
	cursor: pointer;
	transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.cde-calc .cde-mode:hover {
	border-color: #cbd5e1 !important;
}

.cde-calc .cde-mode.is-active,
.cde-calc .cde-mode:has(input:checked) {
	border-color: var(--cde-primary) !important;
	background: var(--cde-primary-soft) !important;
	box-shadow: 0 0 0 3px rgba(27, 58, 125, 0.12) !important;
}

/* Radio nativo oculto, se dibuja uno propio. */
.cde-calc .cde-mode input[type="radio"] {
	position: absolute !important;
	opacity: 0;
	width: 1px;
	height: 1px;
	margin: 0 !important;
	padding: 0 !important;
	pointer-events: none;
}

.cde-calc .cde-mode__radio {
	flex: 0 0 auto;
	width: 20px;
	height: 20px;
	margin-top: 1px;
	border: 2px solid #cbd5e1;
	border-radius: 50%;
	background: #fff;
	transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.cde-calc .cde-mode.is-active .cde-mode__radio,
.cde-calc .cde-mode:has(input:checked) .cde-mode__radio {
	border-color: var(--cde-primary);
	box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 9px var(--cde-primary);
}

.cde-calc .cde-mode__body {
	display: block;
	min-width: 0;
	flex: 1 1 auto;
}

.cde-calc .cde-mode__title {
	display: block !important;
	margin: 0 0 3px;
	font-size: 15px !important;
	font-weight: 700 !important;
	line-height: 1.35 !important;
	color: var(--cde-accent) !important;
}

.cde-calc .cde-mode__desc {
	display: block !important;
	margin: 0 !important;
	color: var(--cde-muted) !important;
	font-size: 12.5px !important;
	line-height: 1.45 !important;
}

.cde-calc .cde-mode__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 10px;
}

.cde-calc .cde-mode__price {
	display: inline-block !important;
	padding: 3px 9px;
	border-radius: 999px;
	background: var(--cde-accent);
	color: #fff !important;
	font-size: 12px !important;
	font-weight: 700 !important;
	line-height: 1.4 !important;
}

.cde-calc .cde-mode__unit {
	font-weight: 500;
	opacity: 0.85;
}

.cde-calc .cde-mode__min {
	display: inline-block !important;
	padding: 3px 9px;
	border-radius: 999px;
	background: var(--cde-line-soft);
	color: var(--cde-muted) !important;
	font-size: 12px !important;
	font-weight: 600 !important;
	line-height: 1.4 !important;
}

/* Modalidad unica: sin radio. */
.cde-calc .cde-modes--single .cde-mode--active {
	border-color: var(--cde-line) !important;
	background: var(--cde-bg) !important;
	box-shadow: none !important;
}

/* ---------------- Secciones ---------------- */

.cde-calc .cde-fields {
	display: grid !important;
	gap: 22px;
	margin: 0 !important;
	padding: 0 !important;
}

.cde-calc .cde-section {
	display: grid;
	gap: 14px;
	margin: 0 !important;
	padding: 20px !important;
	border: 1px solid var(--cde-line-soft);
	border-radius: var(--cde-radius);
	background: var(--cde-bg);
}

.cde-calc .cde-section__title {
	margin: 0 !important;
	padding: 0 !important;
	font-size: 13px !important;
	font-weight: 700 !important;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--cde-muted) !important;
}

.cde-calc .cde-section__intro {
	margin: -6px 0 0 !important;
	color: var(--cde-muted) !important;
	font-size: 13px !important;
}

/* ---------------- Campos ---------------- */

.cde-calc .cde-field {
	display: grid;
	gap: 7px;
	margin: 0 !important;
	padding: 0 !important;
	min-width: 0;
}

.cde-calc .cde-field[hidden],
.cde-calc .cde-section[hidden] {
	display: none !important;
}

.cde-calc .cde-field > label {
	display: block !important;
	margin: 0 !important;
	padding: 0 !important;
	font-size: 13.5px !important;
	font-weight: 600 !important;
	line-height: 1.4 !important;
	color: var(--cde-accent) !important;
}

.cde-calc .cde-grid-2 {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 14px;
}

/* Inputs y selects */
.cde-calc input[type="text"],
.cde-calc input[type="number"],
.cde-calc input[type="url"],
.cde-calc input[type="tel"],
.cde-calc select,
.cde-calc textarea {
	display: block;
	width: 100% !important;
	max-width: 100%;
	/* Sin esto, el control no puede encogerse por debajo del texto mas largo
	   (min-width:auto en grid/flex) y desborda la tarjeta en movil. */
	min-width: 0 !important;
	min-height: 46px;
	margin: 0 !important;
	padding: 11px 14px !important;
	border: 1px solid #cbd5e1 !important;
	border-radius: 10px !important;
	background-color: #fff !important;
	background-image: none !important;
	box-shadow: none !important;
	color: var(--cde-text) !important;
	font-family: inherit !important;
	font-size: 15px !important;
	line-height: 1.45 !important;
	transition: border-color 0.16s ease, box-shadow 0.16s ease;
	appearance: none;
	-webkit-appearance: none;
}

.cde-calc textarea {
	min-height: 84px;
	resize: vertical;
}

.cde-calc select {
	padding-right: 40px !important;
	cursor: pointer;
}

.cde-calc input::placeholder,
.cde-calc textarea::placeholder {
	color: #94a3b8 !important;
	opacity: 1;
}

.cde-calc input:focus,
.cde-calc select:focus,
.cde-calc textarea:focus {
	outline: none !important;
	border-color: var(--cde-primary) !important;
	box-shadow: 0 0 0 3px rgba(27, 58, 125, 0.15) !important;
}

/* Flecha del select. */
.cde-calc .cde-select-wrap {
	position: relative;
	display: block;
}

/* Desplegable multiple: la altura la marca el atributo `size`. */
.cde-calc .cde-select-wrap--multi {
	max-width: 100%;
	min-width: 0;
	overflow: hidden;
}

.cde-calc .cde-select-wrap--multi select {
	padding: 6px 10px !important;
	background-image: none !important;
	/* El texto largo de las opciones se recorta con puntos suspensivos. */
	text-overflow: ellipsis;
}

.cde-calc .cde-select-wrap--multi option {
	padding: 5px 4px;
	border-radius: 4px;
	text-overflow: ellipsis;
}

.cde-calc .cde-select-wrap--multi option:checked {
	background: var(--cde-primary);
	color: #fff;
	font-weight: 600;
}

.cde-calc .cde-select-arrow {
	position: absolute;
	top: 50%;
	right: 16px;
	width: 0;
	height: 0;
	margin-top: -3px;
	border-left: 5px solid transparent;
	border-right: 5px solid transparent;
	border-top: 6px solid var(--cde-muted);
	pointer-events: none;
}

/* Campo libras con unidad. */
.cde-calc .cde-input-wrap {
	position: relative;
	display: flex;
	align-items: center;
}

.cde-calc .cde-input-wrap input {
	padding-right: 52px !important;
}

.cde-calc .cde-input-unit {
	position: absolute;
	right: 15px;
	color: var(--cde-muted);
	font-size: 13px;
	font-weight: 600;
	pointer-events: none;
}

/* Campo de libras autocalculado: no se puede escribir. */
.cde-calc input[readonly] {
	background: var(--cde-bg) !important;
	color: var(--cde-accent) !important;
	font-weight: 700;
	cursor: default;
}

.cde-calc .cde-hint {
	margin: 0 !important;
	padding: 0 !important;
	color: var(--cde-muted) !important;
	font-size: 12.5px !important;
	line-height: 1.45 !important;
}

/* Ficha de los productos elegidos: uno debajo de otro. */
.cde-calc .cde-product-info {
	display: flex !important;
	flex-direction: column;
	align-items: stretch;
	gap: 8px;
	margin: 2px 0 0 !important;
	padding: 10px !important;
	border: 1px solid var(--cde-line-soft);
	border-radius: 10px;
	background: #fff;
	font-size: 13.5px;
	max-height: 320px;
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
}

.cde-calc .cde-product-info[hidden] {
	display: none !important;
}

/* Cada producto es una fila que no se encoge ni se parte. */
.cde-calc .cde-product-info__row {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 0 0 auto;
	min-width: 0;
	max-width: 100%;
	padding-bottom: 8px;
	border-bottom: 1px solid var(--cde-line-soft);
}

.cde-calc .cde-product-info__row:last-child {
	padding-bottom: 0;
	border-bottom: 0;
}

.cde-calc .cde-product-info img {
	flex: 0 0 auto;
	width: 46px;
	height: 46px;
	object-fit: cover;
	border-radius: 8px;
	background: var(--cde-line-soft);
}

.cde-calc .cde-product-info__name {
	font-weight: 600;
	color: var(--cde-accent);
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.cde-calc .cde-product-info a {
	color: var(--cde-primary-dark) !important;
	font-weight: 600;
	text-decoration: none;
}

.cde-calc .cde-product-info a:hover {
	text-decoration: underline;
}

/* ---------------- Dirección de la oficina ---------------- */

.cde-calc .cde-office {
	display: flex !important;
	align-items: flex-start;
	gap: 12px;
	margin: 18px 0 0 !important;
	padding: 14px 16px !important;
	border: 1px solid var(--cde-line);
	border-left: 4px solid var(--cde-primary);
	border-radius: 10px;
	background: var(--cde-primary-soft);
	color: var(--cde-text);
}

.cde-calc .cde-office[hidden] {
	display: none !important;
}

.cde-calc .cde-office__icon {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--cde-primary);
	color: #fff;
}

.cde-calc .cde-office__body {
	display: block;
	min-width: 0;
}

.cde-calc .cde-office__title {
	display: block !important;
	margin: 0 0 3px;
	font-size: 13.5px;
	font-weight: 700;
	color: var(--cde-accent);
}

.cde-calc .cde-office__address {
	display: block !important;
	font-size: 14px;
	line-height: 1.5;
	color: var(--cde-text);
}

/* ---------------- Desglose ---------------- */

.cde-calc .cde-summary {
	display: block !important;
	margin: 22px 0 0 !important;
	padding: 18px !important;
	border: 1px solid var(--cde-line) !important;
	border-radius: var(--cde-radius) !important;
	background: #fff !important;
	box-shadow: none !important;
}

.cde-calc .cde-line {
	display: flex !important;
	align-items: baseline;
	justify-content: space-between;
	gap: 14px;
	margin: 0 !important;
	padding: 7px 0 !important;
	font-size: 14.5px !important;
	line-height: 1.5 !important;
}

.cde-calc .cde-line[hidden] {
	display: none !important;
}

.cde-calc .cde-line__label {
	color: var(--cde-muted) !important;
	font-weight: 500 !important;
}

.cde-calc .cde-line__value {
	color: var(--cde-text) !important;
	font-weight: 600 !important;
	white-space: nowrap;
	text-align: right;
}

.cde-calc .cde-line--total {
	margin-top: 10px !important;
	padding-top: 14px !important;
	border-top: 1px solid var(--cde-line);
	font-size: 17px !important;
}

.cde-calc .cde-line--total .cde-line__label {
	color: var(--cde-accent) !important;
	font-weight: 700 !important;
}

.cde-calc .cde-line--total .cde-line__value {
	color: var(--cde-primary-dark) !important;
	font-size: 22px !important;
	font-weight: 800 !important;
	letter-spacing: -0.01em;
}

/* ---------------- Avisos ---------------- */

.cde-calc .cde-warn {
	display: block !important;
	margin: 14px 0 0 !important;
	padding: 11px 14px !important;
	border: 1px solid #fde68a;
	border-radius: 10px;
	background: #fffbeb;
	color: #92400e !important;
	font-size: 13.5px !important;
	line-height: 1.45 !important;
}

.cde-calc .cde-warn[hidden] {
	display: none !important;
}

.cde-calc .cde-status {
	min-height: 20px;
	margin: 12px 0 0 !important;
	padding: 0 !important;
	color: var(--cde-primary-dark) !important;
	font-size: 14px !important;
	text-align: center !important;
}

.cde-calc .cde-status--error {
	color: #dc2626 !important;
}

/* ---------------- Botón ---------------- */

.cde-calc .cde-btn {
	display: flex !important;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100% !important;
	max-width: 100%;
	min-height: 52px;
	margin: 18px 0 0 !important;
	padding: 14px 20px !important;
	border: 0 !important;
	border-radius: 12px !important;
	background: var(--cde-red) !important;
	background-image: none !important;
	box-shadow: 0 6px 16px rgba(214, 40, 40, 0.28) !important;
	color: #fff !important;
	font-family: inherit !important;
	font-size: 16px !important;
	font-weight: 700 !important;
	line-height: 1.3 !important;
	text-align: center !important;
	text-decoration: none !important;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
	transition: background-color 0.16s ease, transform 0.06s ease, box-shadow 0.16s ease;
}

.cde-calc .cde-btn:hover {
	background: var(--cde-red-dark) !important;
	color: #fff !important;
	box-shadow: 0 8px 20px rgba(214, 40, 40, 0.36) !important;
}

.cde-calc .cde-btn:active {
	transform: translateY(1px);
}

.cde-calc .cde-btn:focus-visible {
	outline: 3px solid rgba(214, 40, 40, 0.45) !important;
	outline-offset: 2px;
}

.cde-calc .cde-btn:disabled {
	opacity: 0.65 !important;
	cursor: progress !important;
	transform: none;
}

.cde-calc .cde-btn__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.cde-calc .cde-btn__icon svg {
	display: block;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 560px) {
	.cde-calc {
		margin: 16px 0;
		padding: 18px;
		border-radius: 14px;
	}

	.cde-calc__title {
		font-size: 20px !important;
	}

	.cde-calc .cde-section {
		padding: 16px !important;
	}

	.cde-calc .cde-grid-2 {
		grid-template-columns: 1fr;
	}

	/* En movil el desplegable de productos no debe pasar de 4 filas. */
	.cde-calc .cde-select-wrap--multi select {
		max-height: 160px;
		font-size: 14px !important;
	}

	.cde-calc .cde-product-info {
		gap: 8px;
		padding: 8px !important;
		max-height: 260px;
	}

	.cde-calc .cde-product-info img {
		width: 38px;
		height: 38px;
	}

	.cde-calc .cde-product-info__name {
		font-size: 13px;
	}
	}

	.cde-calc .cde-line--total .cde-line__value {
		font-size: 20px !important;
	}
}
