/* ==========================================================================
   Sistema DRM — Estilo Apple
   Tipografía del sistema, tarjetas suaves, modal con desenfoque y acento azul.
   ========================================================================== */

:root {
    --azul:        #0071e3;
    --azul-osc:    #0058b9;
    --texto:       #1d1d1f;
    --texto-sec:   #6e6e73;
    --texto-ter:   #86868b;
    --fondo:       #f5f5f7;
    --tarjeta:     #ffffff;
    --borde:       #d2d2d7;
    --borde-claro: #e8e8ed;
    --error:       #d70015;
    --ok:          #28a745;
    --radio:       18px;
    --radio-sm:    12px;
    --sombra:      0 4px 24px rgba(0,0,0,.08);
    --sombra-fuerte: 0 20px 60px rgba(0,0,0,.20);
    --fuente: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
              Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
    margin: 0;
    font-family: var(--fuente);
    color: var(--texto);
    background: var(--fondo);
    line-height: 1.5;
    /* Sticky footer: si el contenido es corto, el footer baja al pie de la
       ventana en vez de quedar suspendido a media altura. */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
body > main { flex: 1 0 auto; }
body > footer { flex-shrink: 0; }

a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================== Barra superior (oscura) ================== */
.topbar {
    position: sticky; top: 0; z-index: 80;
    background: #0b0b0d;
    border-bottom: 1px solid #1f1f22;
    height: 78px;
    color: #fff;
}
.topbar-inner {
    max-width: 1180px;
    height: 100%;
    margin: 0 auto;
    padding: 0 28px 0 60px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.topbar-brand {
    display: flex; align-items: center; gap: 14px;
    color: #fff; text-decoration: none;
}
.topbar-brand:hover { text-decoration: none; opacity: .85; }
.topbar-logo {
    height: 54px; width: auto;
}
.topbar-org {
    font-weight: 600; font-size: 15px; letter-spacing: -.01em;
    color: #fff;
}
.topbar-sep { color: #444; font-weight: 400; margin: 0 2px; }
.topbar-sub {
    font-size: 15px;
    font-weight: 500;
    color: #c7c7cd;
    letter-spacing: -.01em;
    padding-left: 14px;
    border-left: 1px solid #2a2a2d;
}
.topbar-nav {
    margin-left: auto;
    display: flex; align-items: center; gap: 10px;
}
.topbar-volver {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 13.5px; font-weight: 500;
    color: #d6d6db;
    padding: 7px 14px;
    border-radius: 980px;
    background: rgba(255,255,255,.08);
    border: 1px solid transparent;
    transition: background .2s, color .2s, border-color .2s, transform .1s;
}
.topbar-volver:hover {
    text-decoration: none;
    color: #fff;
    background: rgba(255,255,255,.14);
    border-color: rgba(255,255,255,.08);
}
.topbar-volver:active { transform: scale(.98); }
.topbar-volver svg { flex-shrink: 0; }

/* ================================== Héroe ================================ */
.hero {
    text-align: center;
    max-width: 920px;
    margin: 0 auto;
    padding: 48px 24px 28px;
    position: relative;
}
.hero h1 {
    font-size: clamp(30px, 4.2vw, 48px);
    line-height: 1.08;
    font-weight: 700;
    letter-spacing: -.022em;
    margin: 0 0 14px;
    background: linear-gradient(180deg, #1d1d1f 0%, #2c2c2e 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero p {
    font-size: clamp(17px, 1.8vw, 21px);
    color: var(--texto-sec);
    margin: 0 auto;
    max-width: 640px;
    line-height: 1.4;
}
.hero::after {
    content: '';
    display: block;
    width: 48px; height: 4px;
    margin: 22px auto 0;
    border-radius: 4px;
    background: linear-gradient(90deg, #d70015, #ff3b30);
    opacity: .85;
}

@media (max-width: 720px) {
    .topbar { height: 64px; }
    .topbar-inner { padding: 0 18px; gap: 10px; }
    .topbar-logo { height: 42px; }
    .topbar-volver span { display: none; }
    .topbar-volver { padding: 7px 9px; }
    .hero { padding: 56px 22px 36px; }
}

/* ----------------------------- Catálogo ---------------------------------- */
.contenedor { max-width: 1280px; margin: 0 auto; padding: 0 24px 80px; }

/* ------------------------ Toolbar (buscador + filtros) ------------------- */
.toolbar-pub {
    background: var(--tarjeta);
    border: 1px solid var(--borde-claro);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.05);
    padding: 12px 14px;
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
    margin-bottom: 22px;
}
.toolbar-buscador {
    position: relative;
    flex: 1 1 200px;
    min-width: 180px;
}
.toolbar-buscador input[type="search"] {
    width: 100%;
    padding: 12px 14px 12px 42px;
    font-size: 15px; font-family: var(--fuente);
    border: 1px solid var(--borde-claro);
    border-radius: 12px;
    background: #fafafc;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.toolbar-buscador input[type="search"]:focus {
    outline: none;
    background: #fff;
    border-color: var(--azul);
    box-shadow: 0 0 0 4px rgba(0,113,227,.15);
}
.toolbar-lupa {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: #9a9aa0; pointer-events: none;
    display: inline-flex;
}
.toolbar-sel {
    padding: 12px 12px;
    font-size: 14px; font-family: var(--fuente);
    border: 1px solid var(--borde-claro);
    border-radius: 12px;
    background: #fafafc;
    color: var(--texto);
    min-width: 0;
    flex: 0 1 auto;
    max-width: 200px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236e6e73' d='M6 8 0 1.4 1.4 0 6 4.6 10.6 0 12 1.4z'/></svg>");
    background-repeat: no-repeat; background-position: right 12px center;
    padding-right: 32px;
    text-overflow: ellipsis;
}
.toolbar-sel:focus {
    outline: none; background-color: #fff;
    border-color: var(--azul);
    box-shadow: 0 0 0 4px rgba(0,113,227,.15);
}
.toolbar-fechas {
    display: inline-flex; align-items: center; gap: 6px;
    background: #fafafc;
    border: 1px solid var(--borde-claro);
    border-radius: 12px;
    padding: 4px 10px;
    flex: 0 0 auto;
}
.toolbar-fechas label {
    font-size: 11.5px; color: var(--texto-ter);
    font-weight: 500; text-transform: uppercase; letter-spacing: .04em;
    margin-right: 2px;
}
.toolbar-fechas input[type="date"] {
    border: none; background: transparent;
    padding: 8px 2px; font-size: 13px;
    font-family: var(--fuente); color: var(--texto);
    width: 112px;
}
.toolbar-fechas input[type="date"]:focus { outline: none; }
.toolbar-fechas-sep { color: var(--texto-ter); font-size: 13px; }
.btn-aplicar { padding: 11px 18px; font-size: 14.5px; flex: 0 0 auto; white-space: nowrap; }
.btn-limpiar {
    padding: 10px 10px; font-size: 13.5px;
    color: var(--azul); background: transparent;
    border: none; cursor: pointer; text-decoration: none;
    flex: 0 0 auto; white-space: nowrap;
}
.btn-limpiar:hover { color: var(--azul-osc); text-decoration: underline; }

/* En móvil la toolbar puede volverse a varias filas para evitar overflow */
@media (max-width: 760px) {
    .toolbar-pub { flex-wrap: wrap; }
    .toolbar-buscador { flex: 1 1 100%; }
    .toolbar-sel { max-width: none; }
}

.resumen-filtros {
    font-size: 14px; color: var(--texto-sec);
    margin-bottom: 18px; padding: 0 2px;
}
.resumen-filtros strong { color: var(--texto); }

/* ---------------------- Categoría raíz (sección padre) ----------------- */
.seccion-raiz { margin-top: 14px; }
.seccion-raiz + .seccion-raiz { margin-top: 48px; }

.cat-raiz-titulo {
    font-size: clamp(22px, 2.4vw, 30px);
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--texto);
    margin: 8px 0 22px;
    display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
}
.cat-raiz-cont {
    font-size: 13px; font-weight: 500;
    color: var(--texto-ter);
    letter-spacing: 0;
    padding: 4px 12px;
    background: #eef0f3;
    border-radius: 999px;
}

/* ---------------------- Subcategoría (sección hija) -------------------- */
.subcategoria-titulo {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--texto-ter);
    margin: 32px 0 14px;
    display: flex; align-items: center; gap: 10px;
}
.cat-raiz-titulo + .rejilla + .subcategoria-titulo,
.cat-raiz-titulo + .subcategoria-titulo { margin-top: 4px; }

/* Compatibilidad con el nombre antiguo */
.categoria-titulo {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--texto-ter);
    margin: 22px 0 14px;
    display: flex; align-items: center; gap: 10px;
}
.categoria-cont {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 22px; height: 22px; padding: 0 8px;
    background: #eef0f3; color: var(--texto-ter);
    border-radius: 999px; font-size: 11px; font-weight: 600;
    letter-spacing: 0; text-transform: none;
}

/* --------------------------- Sin resultados ------------------------------ */
.sin-resultados {
    text-align: center;
    padding: 80px 24px 60px;
    color: var(--texto-sec);
}
.sin-resultados-icono {
    display: inline-flex; align-items: center; justify-content: center;
    width: 88px; height: 88px;
    border-radius: 50%; background: #f0f0f3;
    color: var(--texto-ter);
    margin: 0 auto 20px;
}
.sin-resultados h2 { font-size: 22px; color: var(--texto); margin: 0 0 8px; letter-spacing: -.01em; }
.sin-resultados p { margin: 0 0 22px; font-size: 15px; }

/* --------------------------- Meta del documento -------------------------- */
.doc-meta-fecha {
    font-size: 11.5px; color: var(--texto-ter);
    margin: 0 0 14px;
    display: inline-flex; align-items: center; gap: 5px;
}
.doc-meta-fecha svg { opacity: .75; }

.rejilla {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 14px;
}

.doc-card {
    position: relative;
    overflow: hidden;
    background: var(--tarjeta);
    border-radius: 14px;
    padding: 16px 16px 14px;
    box-shadow: var(--sombra);
    display: flex;
    flex-direction: column;
    /* Altura fija (mínima) para que todas las tarjetas tengan el mismo
       tamaño y los botones queden alineados en horizontal. */
    min-height: 260px;
    transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s;
    border: 1px solid var(--borde-claro);
}
.doc-card:hover { transform: translateY(-3px); box-shadow: 0 12px 36px rgba(0,0,0,.12); }

/* Miniatura de la portada del PDF como fondo sutil B/N */
.doc-thumb {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: top center;
    background-repeat: no-repeat;
    filter: grayscale(100%) contrast(.92);
    opacity: .42;
    transition: opacity .35s ease, filter .35s ease;
    pointer-events: none;
    z-index: 0;
}
.doc-card:hover .doc-thumb {
    opacity: .75;
    filter: grayscale(0%) contrast(1);
}
/* Velo blanco muy ligero para garantizar la legibilidad del texto */
.doc-velo {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
                rgba(255,255,255,.10) 0%,
                rgba(255,255,255,.45) 55%,
                rgba(255,255,255,.70) 100%);
    pointer-events: none;
    z-index: 1;
}
/* Contenido por encima del fondo y del velo */
.doc-card > .doc-icon,
.doc-card > h3,
.doc-card > .desc,
.doc-card > .btn { position: relative; z-index: 2; }

.doc-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ff5f57, #d70015);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 11px;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(215,0,21,.25);
}
.doc-card h3 {
    font-size: 14.5px; font-weight: 600;
    margin: 0 0 6px; letter-spacing: -.01em;
    line-height: 1.3;
}
.doc-card .desc {
    font-size: 13px; color: var(--texto-sec);
    margin: 0 0 12px;
    line-height: 1.4;
    /* Limitar a 3 líneas para mantener altura consistente */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.doc-card .meta { font-size: 11.5px; color: var(--texto-ter); margin-bottom: 10px; }

.btn {
    appearance: none; border: none; cursor: pointer;
    font-family: var(--fuente); font-size: 15px; font-weight: 500;
    color: #fff; background: var(--azul);
    border-radius: 980px; padding: 10px 20px;
    transition: background .2s, transform .1s;
    display: inline-flex; align-items: center; gap: 7px;
    text-decoration: none;
}
.btn:hover { background: var(--azul-osc); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { background: #b9b9be; cursor: not-allowed; }
.btn-bloque { width: 100%; padding: 13px; font-size: 16px; justify-content: center; }
.btn-sec {
    background: var(--fondo); color: var(--texto);
    border: 1px solid var(--borde);
}
.btn-sec:hover { background: #ececef; }

.doc-card .btn {
    align-self: flex-start;
    margin-top: auto;   /* empuja el botón al pie de la tarjeta */
    font-size: 13.5px; padding: 8px 16px;
}
.doc-card .btn svg { width: 12px; height: 12px; }

/* ------------------------------ Modal ------------------------------------ */
.overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px; z-index: 1000;
    opacity: 0; visibility: hidden;
    transition: opacity .3s ease, visibility .3s;
}
.overlay.abierto { opacity: 1; visibility: visible; }

.modal {
    background: var(--tarjeta);
    border-radius: 28px;
    width: 100%; max-width: 560px;
    max-height: 92vh; overflow: hidden;
    box-shadow: var(--sombra-fuerte);
    display: flex; flex-direction: column;
    transform: scale(.96) translateY(10px);
    transition: transform .35s cubic-bezier(.2,.9,.3,1.1);
}
.overlay.abierto .modal { transform: scale(1) translateY(0); }

.modal-cab {
    padding: 32px 36px 8px;
    text-align: center;
    position: relative;
}
.modal-cab h2 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 4px; }
.modal-cab .sub { font-size: 14px; color: var(--texto-sec); margin: 0; }
.cerrar {
    position: absolute; top: 18px; right: 20px;
    width: 30px; height: 30px; border-radius: 50%;
    border: none; background: #e8e8ed; color: #6e6e73;
    font-size: 17px; cursor: pointer; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s;
}
.cerrar:hover { background: #dcdce1; }

.modal-cuerpo { padding: 14px 36px 28px; overflow-y: auto; }

/* ------------------------------ Formulario ------------------------------- */
.campos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 6px; }
.campo-full { grid-column: 1 / -1; }

.campo input, .campo select, .campo textarea, input.campo, select.campo {
    width: 100%;
    font-family: var(--fuente); font-size: 16px; color: var(--texto);
    background: #f5f5f7;
    border: 1px solid transparent;
    border-radius: var(--radio-sm);
    padding: 13px 15px;
    transition: border-color .2s, background .2s, box-shadow .2s;
}
.campo input::placeholder, .campo textarea::placeholder { color: #9a9aa0; }
.campo input:focus, .campo select:focus, .campo textarea:focus {
    outline: none; background: #fff;
    border-color: var(--azul);
    box-shadow: 0 0 0 4px rgba(0,113,227,.15);
}
.campo input.invalido, .campo select.invalido { border-color: var(--error); box-shadow: 0 0 0 4px rgba(215,0,21,.12); }
.campo select { appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236e6e73' d='M6 8 0 1.4 1.4 0 6 4.6 10.6 0 12 1.4z'/></svg>");
    background-repeat: no-repeat; background-position: right 15px center; padding-right: 38px;
}

.etiqueta-legal {
    font-size: 13px; font-weight: 600; color: var(--texto-sec);
    margin: 18px 0 8px;
}

.legal {
    height: 180px; overflow-y: auto;
    background: #f5f5f7;
    border: 1px solid var(--borde-claro);
    border-radius: var(--radio-sm);
    padding: 18px 20px;
    font-size: 13px; line-height: 1.65; color: var(--texto-sec);
    -webkit-overflow-scrolling: touch;
}
.legal p { margin: 0 0 12px; }
.legal strong { color: var(--texto); }
.legal::-webkit-scrollbar { width: 8px; }
.legal::-webkit-scrollbar-thumb { background: #c7c7cc; border-radius: 8px; }
.legal-aviso {
    background: #fff4e5;
    border-left: 3px solid #ff9500;
    color: #7a4a00;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    margin: 0 0 14px;
}
.legal-disclaimer {
    background: #f2f2f4;
    border-left: 3px solid var(--texto-ter);
    color: var(--texto);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    margin-top: 14px;
}

.aviso-scroll {
    text-align: center; font-size: 13px; font-weight: 600; color: var(--error);
    margin: 12px 0 4px; transition: opacity .3s;
}
.aviso-scroll.oculto { opacity: 0; height: 0; margin: 0; overflow: hidden; }

.acepto {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    margin: 16px 0; font-size: 15px; font-weight: 600; color: var(--texto);
}
.acepto input { width: 20px; height: 20px; accent-color: var(--azul); cursor: pointer; }
.acepto.deshabilitado { opacity: .45; pointer-events: none; }

/* Estados de envío */
.estado-msg {
    display: none; text-align: center; padding: 8px 0; font-size: 15px; font-weight: 500;
}
.estado-msg.error { display: block; color: var(--error); }
.estado-msg.ok    { display: block; color: var(--ok); }

.cargando { display: inline-flex; align-items: center; gap: 8px; }
.spinner {
    width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff; border-radius: 50%;
    animation: girar .7s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* Vista de éxito */
.exito { text-align: center; padding: 24px 0; }
.exito .check {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--ok); color: #fff; font-size: 34px;
    display: flex; align-items: center; justify-content: center; margin: 0 auto 18px;
    animation: aparecer .4s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes aparecer { from { transform: scale(0); } to { transform: scale(1); } }
.exito h3 { font-size: 21px; margin: 0 0 6px; }
.exito p { color: var(--texto-sec); margin: 0 0 20px; font-size: 15px; }

/* Pie de página (oscuro) */
.pie-web {
    background: #0b0b0d;
    border-top: 1px solid #1f1f22;
    padding: 36px 24px 32px;
    font-size: 12.5px;
    color: #9a9aa3;
}
.pie-inner {
    max-width: 1180px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: center;
    justify-content: space-between;
}
.pie-org {
    font-weight: 600;
    color: #d6d6db;
    letter-spacing: -.01em;
}
.pie-links { display: flex; gap: 22px; flex-wrap: wrap; }
.pie-links a {
    color: #b3b3ba;
    font-weight: 500;
}
.pie-links a:hover { color: #fff; text-decoration: none; }

@media (max-width: 520px) {
    .cabecera h1 { font-size: 30px; }
    .modal-cab, .modal-cuerpo { padding-left: 22px; padding-right: 22px; }
    .campos { grid-template-columns: 1fr; }
}
