/* =========================================================
   generador.css - Estilos del formulario generador
   (no forma parte de los sitios generados)
   ========================================================= */

:root {
    --fondo:        #EEF3F8;
    --superficie:   #FFFFFF;
    --superficie-2: #F6F9FC;
    --tinta:        #1B2A3A;
    --tinta-suave:  #5B6B7C;
    --acento:       #2F6FEB;
    --acento-claro: #DCE7FD;
    --borde:        #D6DFE9;
    --error:        #B42318;
    --error-fondo:  #FEF3F2;
    --alerta:       #9A6700;
    --radio:        12px;
    --fuente: "Segoe UI", system-ui, -apple-system, sans-serif;
    --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

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

body {
    margin: 0;
    font-family: var(--fuente);
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--tinta);
    background: var(--fondo);
}

code { font-family: var(--mono); font-size: 0.9em; }

/* ---------- Cabecera ---------- */
.cabecera {
    padding: 2rem 1rem 1rem;
    max-width: 1100px;
    margin: 0 auto;
}
.cabecera h1 { margin: 0 0 0.25rem; font-size: 1.75rem; }
.cabecera p { margin: 0; color: var(--tinta-suave); max-width: 70ch; }

.contenido {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem 4rem;
}

/* ---------- Paneles ---------- */
.panel {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.panel h2 { margin: 0 0 0.75rem; font-size: 1.2rem; }

.panel-generar {
    position: sticky;
    bottom: 0.75rem;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
    box-shadow: 0 6px 24px rgb(27 42 58 / 0.12);
}
.panel-generar .aviso { align-self: stretch; max-height: 30vh; overflow: auto; }

.subgrupo {
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 0.75rem 1rem 1rem;
    margin: 1rem 0 0;
    min-width: 0;
}
.subgrupo legend { font-weight: 600; padding: 0 0.35rem; }

/* ---------- Campos ---------- */
.rejilla {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem 1rem;
    align-items: start;
}
.ancho-2 { grid-column: span 2; }
.ancho-3 { grid-column: span 3; }
.ancho-completo { grid-column: 1 / -1; }

label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-weight: 600;
    font-size: 0.85rem;
}
label small, .ayuda {
    font-weight: 400;
    color: var(--tinta-suave);
    font-size: 0.8rem;
}
.ayuda { margin: 0 0 0.75rem; }

label.casilla, label.en-linea {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
}
.rejilla > label.casilla { align-self: end; padding-bottom: 0.5rem; }

input, select, textarea {
    font: inherit;
    font-weight: 400;
    color: inherit;
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: 8px;
    padding: 0.45rem 0.6rem;
    width: 100%;
    min-width: 0;
}
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--acento); }
input[type="file"] { padding: 0.3rem; background: var(--superficie-2); }
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
    outline: 2px solid var(--acento);
    outline-offset: 1px;
}
input:user-invalid, textarea:user-invalid { border-color: var(--error); }

/* ---------- Botones ---------- */
button, .boton-archivo {
    font: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--acento);
    background: var(--acento-claro);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.45rem 0.85rem;
    cursor: pointer;
}
button:hover, .boton-archivo:hover { border-color: var(--acento); }
button:disabled { opacity: 0.6; cursor: progress; }

.boton-primario {
    color: #fff;
    background: var(--acento);
    padding: 0.6rem 1.25rem;
    font-size: 0.95rem;
}
.boton-primario:hover { background: #1F58C9; }

.boton-icono {
    color: var(--tinta-suave);
    background: transparent;
    padding: 0.2rem 0.5rem;
    line-height: 1;
}
.boton-icono:hover { color: var(--tinta); background: var(--superficie-2); border-color: var(--borde); }

.boton-archivo { display: inline-block; flex-direction: row; }
.boton-archivo input { display: none; }

.barra-acciones {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.barra-acciones select { width: auto; }
.panel > .barra-acciones:first-of-type { margin-top: 0; }
.separador { width: 1px; align-self: stretch; background: var(--borde); margin: 0 0.25rem; }

/* ---------- Tarjetas ---------- */
.lista-tarjetas {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0.75rem 0;
}
.lista-tarjetas:empty { margin: 0.25rem 0; }

.tarjeta {
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 0.75rem 1rem 1rem;
    background: var(--superficie);
}
.tarjeta-pagina { border-left: 4px solid var(--acento); }
.tarjeta-bloque { background: var(--superficie-2); }
.tarjeta-bloque .tarjeta-bloque { background: var(--superficie); }

.tarjeta-cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.tarjeta-titulo { margin: 0; font-size: 1rem; }
.tarjeta-bloque .tarjeta-titulo {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tinta-suave);
}
.tarjeta-acciones { display: flex; gap: 0.15rem; }

/* Filas compactas: hojas de estilo, hitos y campos */
.lista-filas { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.25rem 0 0.75rem; }
.fila { display: flex; align-items: center; gap: 0.5rem; }
.fila > input:not([type]) { flex: 1; }
.fila-campo select { width: 9rem; flex: none; }
.fila-campo input[type="number"] { width: 4.5rem; flex: none; }
.fila .casilla { white-space: nowrap; font-weight: 400; }

/* ---------- Avisos y estados ---------- */
.aviso {
    margin: 0 0 1rem;
    padding: 0.75rem 1rem 0.75rem 2rem;
    border-radius: 8px;
    background: #FFF8E6;
    color: var(--alerta);
}
.aviso-error { background: var(--error-fondo); color: var(--error); }
div.aviso { padding-left: 1rem; }
.estado { margin: 0.5rem 0 0; color: var(--tinta-suave); min-height: 1.2em; }
.estado-alerta { color: var(--alerta) !important; }

/* ---------- Resultado ---------- */
.pestanas {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 1.25rem 0 0;
}
.pestanas button {
    background: var(--superficie-2);
    color: var(--tinta-suave);
    border: 1px solid var(--borde);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
}
.pestanas button[aria-current="true"] { background: var(--acento); color: #fff; border-color: var(--acento); }

#vista-previa {
    display: block;
    width: 100%;
    height: 75vh;
    border: 1px solid var(--borde);
    border-radius: 0 8px 8px 8px;
    background: #fff;
}

details { margin-top: 1rem; }
summary { cursor: pointer; font-weight: 600; }
#xml-generado {
    font-family: var(--mono);
    font-size: 0.8rem;
    background: var(--superficie-2);
    border: 1px solid var(--borde);
    border-radius: 8px;
    padding: 1rem;
    overflow: auto;
    max-height: 60vh;
}

[hidden] { display: none !important; }

/* ---------- Móvil ---------- */
@media (max-width: 720px) {
    .rejilla { grid-template-columns: minmax(0, 1fr); }
    .ancho-2, .ancho-3 { grid-column: auto; }
    .fila { flex-wrap: wrap; }
    .fila > input:not([type]) { flex: 1 1 100%; }
    .panel-generar { position: static; }
}
