:root {
    --bg-page: #f5f6fa;
    --card-bg: #ffffff;
    --card-border: #e5e7eb;
    --text-main: #1f2937;
    --text-dim: #6b7280;
    --accent: #4f46e5;
    --accent-light: rgba(79,70,229,0.08);
    --radius-lg: 16px;
    --radius-sm: 8px;
    --header-h: 64px;    /* alto del header en desktop */
}

@media (max-width: 640px){
    :root{ --header-h: 56px; }   /* un poco más bajo en mobile */
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg-page);
    color: var(--text-main);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.45;
}

header.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    z-index: 1000;                          /* por encima de todo */
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    padding: 0 .75rem;                      /* quitamos padding vertical (lo da la altura) */
    display: flex; align-items: center;     /* centra contenido verticalmente */            
}

/* Alineación interna sin romper el layout existente */
.nav-inner{
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
}

.brand {
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.brand-badge {
    background: var(--accent-light);
    color: var(--accent);
    font-size: .7rem;
    font-weight: 600;
    padding: .25rem .5rem;
    border-radius: var(--radius-sm);
    line-height: 1.2;
}

nav a {
    color: var(--text-dim);
    font-size: .9rem;
    text-decoration: none;
    margin-left: 1rem;
    padding: .4rem .6rem;
    border-radius: var(--radius-sm);
}

nav a.active,
nav a:hover {
    background: var(--accent-light);
    color: var(--accent);
}

main.page {
    /* padding: 0 1rem 4rem; */
    padding: 0 1rem 1rem 1rem;
    margin: calc(var(--header-h) + 1rem) auto 0;  /* deja espacio debajo del header fijo */
    max-width: 1200px;
}

.layout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media(min-width: 768px){
    .layout-grid-2col {
        grid-template-columns: 1fr 1fr;
    }
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.25rem 1rem;
    box-shadow: 0 20px 40px rgb(0 0 0 / 2%);
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: .75rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.card-sub {
    color: var(--text-dim);
    font-size: .8rem;
    line-height: 1.4;
    margin-top: .25rem;
}

.muted {
    color: var(--text-dim);
}

.ok-msg {
    background: #ecfdf5;
    border: 1px solid #10b98133;
    color: #065f46;
    font-size: .85rem;
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.error-msg {
    background: #fef2f2;
    border: 1px solid #ef444433;
    color: #991b1b;
    font-size: .85rem;
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

label {
    font-size: .8rem;
    font-weight: 500;
    color: var(--text-main);
    display: block;
    margin-bottom: .4rem;
}

textarea,
input[type="text"],
input[type="password"],
input[type="number"] {
    width: 100%;
    background: #fff;
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
    padding: .7rem .75rem;
    font-size: .9rem;
    line-height: 1.4;
    color: var(--text-main);
    font-family: inherit;
    resize: vertical;
}

textarea.readonly {
    background: #f9fafb;
    color: var(--text-main);
}

.form-group {
    margin-bottom: 1rem;
}

.btn-row {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    margin-top: .5rem;
}

button,
.btn {
    appearance: none;
    border: 0;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    font-size: .9rem;
    font-weight: 500;
    line-height: 1.2;
    padding: .7rem 1rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 20px rgb(79 70 229 / 20%);
    text-decoration: none;
}

button.secondary,
.btn.secondary {
    background: #fff;
    color: var(--text-main);
    border: 1px solid var(--card-border);
    box-shadow: none;
}

.mini-meta {
    font-size: .7rem;
    color: var(--text-dim);
    line-height: 1.4;
}

.list-card {
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    background: #fff;
    padding: 1rem 1rem .75rem;
    box-shadow: 0 8px 20px rgb(0 0 0 / 2%);
    border-top: 3px solid var(--accent);              /* línea superior azul */
    position: relative;            
}

.list-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-bottom: .5rem;
}

/* Pills de evaluación */
.pill {
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    display: inline-block;
}

/* Muy útil → verde */
.pill-muy-util {
    background-color: #16a34a;   /* verde intenso */
}

/* Algo útil → azul */
.pill-algo-util {
    background-color: #3b82f6;   /* azul clásico */
}

/* Poco útil → rojo */
.pill-poco-util {
    background-color: #dc2626;   /* rojo */
}        

/* No evaluada → gris */
.pill-no-evaluada {
    background-color: #343536;   /* gris */
}        

/* .pill {
    display: inline-block;
    background: var(--accent-light);
    color: var(--accent);
    font-size: .7rem;
    font-weight: 500;
    line-height: 1.2;
    padding: .3rem .5rem;
    border-radius: 999px;
} */

pre.answer-block {
    background: #f9fafb;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: .75rem;
    font-size: .85rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    color: var(--text-main);
    max-height: 300px;
    overflow-y: auto;
}

footer.site-footer {
    text-align: center;
    font-size: .9rem;
    color: var(--text-dim);
    padding: 0 1rem 1rem 1rem;
}

/* Estilo del botón logout igual al enlace */
.logout-link {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: .9rem;
    text-decoration: none;
    margin-left: 1rem;
    padding: .4rem .6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
}

.logout-link:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.logout-link:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-light);
}

/* ---- Normalización de los botones de logout ---- */
.nav-link {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: .9rem;
    font-weight: 400;            /* igual que los links normales */
    text-decoration: none;
    margin-left: 1rem;
    padding: .4rem .6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    box-shadow: none;
    display: inline-block;
}

/* Estado hover igual al <a> */
.nav-link:hover {
    background: var(--accent-light);
    color: var(--accent);
}

/* Estado activo igual */
.nav-link.active {
    background: var(--accent-light);
    color: var(--accent);
}

/* Evitar resaltado o sombra de enfoque */
.nav-link:focus,
.nav-link:active {
    outline: none;
    box-shadow: none;
}

/* --- Logo y marca --- */
.brand-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.brand-logo {
    height: 38px;
    width: auto;
    display: block;
    object-fit: contain;
}

@media (max-width: 640px) {
    .brand-logo {
        height: 30px;
    }
}

/* --- Filtro de fechas en historial --- */
.filter-bar {
    background: #f0f2f9; 
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 0.8rem 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 6px 12px rgba(0,0,0,0.02);
} 

.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.8rem;  /* espacio entre campos */
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-field label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-dim);
}

.filter-field input[type="date"] {
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
    color: var(--text-main);
    width: 10rem;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: auto;  /* empuja los botones hacia la derecha */
}

.filter-actions .btn,
.filter-actions .btn.secondary {
    padding: 0.55rem 0.9rem;
    font-size: 0.85rem;
}

.filter-field select {
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
    color: var(--text-main);
    min-width: 9rem;
}        

@media (max-width: 700px) {
    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-actions {
        margin-left: 0;
        justify-content: flex-start;
    }
}

/* Barra de filtros sticky */
.filter-bar {
    /* position: sticky; */
    top: 0; /* queda debajo del header fijo  calc(var(--header-h) + 6px); */
    z-index: 40;            /* por encima de las cards del listado */
    background: rgba(240,242,249,0.92); /* leve transparencia para efecto “fijo” */
    backdrop-filter: saturate(160%) blur(6px);
    -webkit-backdrop-filter: saturate(160%) blur(6px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 0.8rem 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 10px 20px rgba(0,0,0,0.04);
}

/* Mantener layout compacto en fila */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.8rem;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-field label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-dim);
}

.filter-field input[type="date"] {
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
    color: var(--text-main);
    width: 10rem;
}

/* Botones en la misma fila que los campos y alineados a la derecha */
.filter-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: auto;
}

.filter-actions .btn,
.filter-actions .btn.secondary {
    padding: 0.55rem 0.9rem;
    font-size: 0.85rem;
}

/* Responsive: apilar en móviles */
@media (max-width: 700px) {
    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-actions {
        margin-left: 0;
        justify-content: flex-start;
    }
}

/* ----- BLOQUE DE RESPUESTA HTML ----- */
.respuesta-html {
    background: #f9fafb;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text-main);
    overflow-wrap: break-word;
    box-shadow: 0 8px 20px rgba(0,0,0,0.03);
    min-height: 260px; /* doble de altura inicial */
}

/* Ajusta las imágenes incrustadas */
.respuesta-html img {
    max-width: 100%;
    height: auto;
    margin: 0.75rem 0;
    border-radius: 8px;
    border: 1px solid var(--card-border);
}

/* Estilo de negritas, cursivas, enlaces */
.respuesta-html strong { font-weight: 600; }
.respuesta-html em { font-style: italic; }

.respuesta-html a {
    color: var(--accent);
    text-decoration: underline;
}
.respuesta-html a:hover {
    color: #312e81;
}

.respuesta-html p {
    margin-bottom: 0.9rem;
}

.respuesta-html ul {
    margin: 0.5rem 0 1rem 1.4rem;
}

.respuesta-html li {
    margin-bottom: 0.4rem;
}   

/* Estado colapsado para respuestas en el listado */
.respuesta-html.is-collapsed {
    display: none;
}

/* Opcional: transición suave al mostrar */
.respuesta-html {
    transition: all 0.2s ease-in-out;
}

/* --- Acciones en cabecera de cards --- */
.card-header {
    position: relative;
}

.card-header-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

/* Botón icono compacto */
.icon-btn {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 999px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--text-dim);
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    padding: 0;
}

.icon-btn:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.icon-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-light);
}

.icon-btn.is-active {
    background: var(--accent-light);
    color: var(--accent);
}

/* Feedback visual cuando se copia */
.icon-btn.copied {
    background: var(--accent);
    color: #fff;
}

/* Estado colapsado para respuestas */
.respuesta-html.is-collapsed {
    display: none;
}

/* Fila de combos en hacer_pregunta */
.form-row-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.form-group.inline {
    flex: 1 1 180px;
    min-width: 150px;
}

.form-group.inline select {
    width: 100%;
    background: #fff;
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
    color: var(--text-main);
}        