
:root {
	--primary: #2457a7;
	--primary-hover: #194580;
	--text: #202b3c;
	--muted: #69778b;
	--border: #dce3ed;
	--surface: #ffffff;
	--background: #f3f6fb;
	--soft-blue: #edf4ff;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	font-family: system-ui, -apple-system, BlinkMacSystemFont,
	"Segoe UI", sans-serif;
	color: var(--text);
	background: var(--background);
	font-size: 15px;
}

/* Encabezado */

header {
	background: #172b4d;
	color: white;
	padding: 26px 20px;
	border-bottom: 4px solid var(--primary);
}

.header-inner,
main {
	width: min(1100px, calc(100% - 32px));
	margin: auto;
}

.brand {
	margin: 0;
	font-size: 25px;
	font-weight: 700;
	letter-spacing: -.5px;
}

.subtitle {
	margin: 7px 0 0;
	color: #d0d9e8;
	font-size: 14px;
}

/* Contenido */

main {
	padding: 28px 0 40px;
}

.panel {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 13px;
	padding: 24px;
	margin-bottom: 22px;
	box-shadow: 0 3px 12px rgb(24 42 72 / 4%);
}

.section-title {
	font-size: 18px;
	margin: 0 0 20px;
	font-weight: 700;
}

/* Formulario */

.filters {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 18px 22px;
}

.field {
	min-width: 0;
}

.field label,
.field-label {
	display: block;
	margin-bottom: 7px;
	font-weight: 650;
	font-size: 13px;
	color: #34445c;
}

input[type="text"],
select {
	width: 100%;
	min-height: 42px;
	padding: 9px 11px;
	border: 1px solid #cbd5e1;
	border-radius: 7px;
	background: white;
	color: var(--text);
	font: inherit;
}

input:focus,
select:focus {
	outline: 2px solid #b8d1ff;
	border-color: var(--primary);
}

.hint {
	color: var(--muted);
	font-size: 12px;
	margin-top: 5px;
}

/* Selección de cantidad de letras */

.length-options {
	grid-column: 1 / -1;
	padding: 16px;
	border: 1px solid var(--border);
	border-radius: 9px;
	background: #fafbfd;
}

.checkbox-list {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.check-option {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	border: 1px solid var(--border);
	background: white;
	padding: 8px 11px;
	border-radius: 7px;
	cursor: pointer;
	font-size: 13px;
	font-weight: 500;
}

.check-option:has(input:checked) {
	background: var(--soft-blue);
	border-color: #9ab9ef;
	color: #174b99;
}

.check-option input {
	accent-color: var(--primary);
	margin: 0;
}

/* Botones */

.actions {
	grid-column: 1 / -1;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	margin-top: 2px;
}

.btn {
	display: inline-flex;
	justify-content: center;
	align-items: center;
	min-height: 43px;
	padding: 10px 19px;
	border: 0;
	border-radius: 7px;
	background: var(--primary);
	color: white;
	font-weight: 650;
	font-size: 14px;
	text-decoration: none;
	cursor: pointer;
}

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

.btn-secondary {
	color: #40516a;
	background: #eef2f7;
}

.btn-secondary:hover {
	background: #e0e7f0;
}

/* Encabezado de resultados */

.results-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex-wrap: wrap;
	margin-bottom: 18px;
}

.results-header h2 {
	font-size: 19px;
	margin: 0;
}

.counter {
	color: var(--muted);
	font-size: 13px;
}

.counter strong {
	color: var(--text);
	font-size: 17px;
}

/* Paginación */

.pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 8px;
	padding: 13px 0;
}

.page-arrow {
	display: inline-flex;
	width: 37px;
	height: 37px;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--border);
	border-radius: 7px;
	background: white;
	color: var(--primary);
	text-decoration: none;
	font-size: 23px;
	line-height: 1;
}

.page-arrow:hover {
	background: var(--soft-blue);
	border-color: #a9c5f1;
}

.page-label,
.page-total {
	color: var(--muted);
	font-size: 13px;
}

.page-select {
	width: auto;
	min-width: 76px;
	min-height: 37px;
	padding: 6px 8px;
}

/* Listado de palabras */


/*
.word-grid {
	display: grid;

	grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));

	gap: 0;
	border: 1px solid var(--border);
	border-radius: 9px;
	overflow: hidden;
}

.word-item {
	display: block;
	min-width: 0;
	padding: 11px 12px;
	color: #2457a7;
	background: white;
	border-right: 1px solid #edf0f5;
	border-bottom: 1px solid #edf0f5;
	text-decoration: none;
	overflow-wrap: anywhere;
	transition: background .12s;
}

.word-item:hover {
	background: var(--soft-blue);
	text-decoration: underline;
}
*/


.word-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
	gap: 9px;
	margin: 20px 0;
}

.word-item {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 0;
	min-height: 43px;
	padding: 9px 6px;
	color: #1d4ed8;
	background: #f8fafc;
	border: 1px solid #dce3ed;
	border-radius: 8px;
	font-size: clamp(0.72rem, 1.1vw, 0.95rem);
	font-weight: 600;
	text-align: center;
	text-decoration: none;

	/* Mantener cada palabra en un único renglón */
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;

	transition: background 0.15s, border-color 0.15s,
	transform 0.15s;
}

.word-item:hover {
	background: #eff6ff;
	border-color: #93c5fd;
	transform: translateY(-1px);
}

/* Sin resultados */

.empty {
	padding: 35px 15px;
	text-align: center;
	color: var(--muted);
	background: #fafbfd;
	border: 1px dashed var(--border);
	border-radius: 9px;
}

/* Pie de página */

footer {
	text-align: center;
	color: var(--muted);
	font-size: 12px;
	padding: 0 16px 28px;
}

/* Tablet y celular */

@media (max-width: 900px) {
	.filters {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 700px) {
	.filters {
		grid-template-columns: 1fr;
	}

	.length-options,
	.actions {
		grid-column: auto;
	}

	.panel {
		padding: 17px;
	}

	.word-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.brand {
		font-size: 22px;
	}
}

/* Celulares pequeños */

@media (max-width: 380px) {
	.word-grid {
		grid-template-columns: 1fr;
	}

	.page-arrow {
		width: 32px;
		height: 34px;
	}

	.pagination {
		gap: 5px;
	}
}

.resumen-filtros {
	margin-top: -8px;
	margin-bottom: 20px;
	color: #64748b;
	font-size: 0.9rem;
	line-height: 1.7;
	overflow-wrap: anywhere;
}

/* =====================================================
   Ajustes responsive adicionales para celulares
   ===================================================== */

@media (max-width: 700px) {
    /* Más columnas para aprovechar el ancho disponible. */
    .word-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 5px;
    }

    .word-item {
        padding: 7px 3px;
        font-size: 0.78rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Mantener la paginación en una sola fila.
       Si no entra completa, se puede desplazar horizontalmente. */
    .pagination {
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 4px;
        max-width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .page-arrow {
        flex: 0 0 30px;
        width: 30px;
        height: 32px;
        font-size: 21px;
    }

    .page-label,
    .page-total {
        flex: 0 0 auto;
        font-size: 11px;
    }

    .page-select {
        flex: 0 0 auto;
        width: auto;
        min-width: 48px;
        max-width: 68px;
        min-height: 32px;
        padding: 4px 3px;
        font-size: 12px;
    }

    /* Reducir el espacio dedicado a las cantidades de letras. */
    .length-options {
        padding: 10px;
    }

    .length-options .field-label {
        margin-bottom: 6px;
        font-size: 12px;
    }

    .checkbox-list {
        gap: 5px;
    }

    .check-option {
        gap: 4px;
        min-height: 28px;
        padding: 4px 7px;
        font-size: 11px;
    }

    .check-option input {
        width: 13px;
        height: 13px;
    }
}

/* Cuatro columnas cuando el celular tiene suficiente ancho. */
@media (min-width: 390px) and (max-width: 700px) {
    .word-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 5px;
    }

    .word-item {
        padding: 7px 2px;
        font-size: 0.75rem;
    }
}

/* En pantallas muy estrechas, mantener tres columnas compactas. */
@media (max-width: 389px) {
    .word-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 4px;
    }

    .word-item {
        padding: 6px 2px;
        font-size: 0.72rem;
    }

    .pagination {
        gap: 3px;
    }

    .page-arrow {
        flex-basis: 28px;
        width: 28px;
    }

    .page-select {
        min-width: 44px;
        max-width: 58px;
        font-size: 11px;
    }

    .check-option {
        gap: 3px;
        padding: 3px 5px;
        font-size: 10px;
    }
}

#resultados {
	scroll-margin-top: 15px;
}


/* Etiquetas de filtros con ayuda emergente */
.field-label-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 20px;
    margin-bottom: 7px;
}

.field-label-row > label,
.field-label-row .field-label {
    display: inline-block;
    margin: 0;
}

.help-button {
    display: inline-flex;
    flex: 0 0 17px;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    padding: 0;
    border: 1px solid #8292a8;
    border-radius: 50%;
    background: #fff;
    color: #52647b;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.help-button:hover,
.help-button:focus-visible {
    border-color: var(--primary);
    background: var(--soft-blue);
    color: var(--primary);
    outline: 2px solid #b8d1ff;
    outline-offset: 1px;
}

.help-popup {
    position: absolute;
    z-index: 20;
    top: calc(100% + 5px);
    left: 0;
    width: min(290px, calc(100vw - 60px));
    padding: 11px 13px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #26364b;
    box-shadow: 0 5px 18px rgb(24 42 72 / 16%);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
}

.help-popup[hidden] {
    display: none;
}

.length-label-row {
    margin-bottom: 10px;
}


/* Botón para borrar el contenido de los campos de filtro */
.input-clear-wrap {
    position: relative;
    width: 100%;
}

.input-clear-wrap input[type="text"] {
    padding-right: 36px;
}

.clear-input {
    position: absolute;
    top: 50%;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 23px;
    height: 23px;
    padding: 0;
    transform: translateY(-50%);
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #718096;
    font-family: Arial, sans-serif;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.clear-input:hover,
.clear-input:focus-visible {
    background: #e8edf5;
    color: #1e3a5f;
    outline: 2px solid #b8d1ff;
    outline-offset: 1px;
}

.clear-input[hidden] {
    display: none;
}
