/* === SIDEBAR: MATERIAS === */
.izquierda h3 {
    font-family: var(--font-brand);
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.get_materias {
    list-style: none;
    padding: 0;
    margin: 0 0 2rem;
}

.get_materias li a {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
    transition: color 0.15s, padding-left 0.15s;
}

.get_materias li a:hover {
    color: var(--primary);
    padding-left: 0.4rem;
}

.get_materias li a.active {
    color: var(--primary);
    font-weight: 600;
}

/* === CABECERA SECCIÓN === */
.libros .titulo_seccion {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.libros .titulo_seccion h1 {
    font-size: 1.4rem;
    margin: 0;
}

/* === MOSAICO DE LIBROS === */
.listado-mosaico {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.listado-mosaico .item {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: none;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(27, 42, 74, 0.07);
    transition: box-shadow 0.25s, transform 0.25s;
    border-top: 3px solid transparent;
}

.listado-mosaico .item:hover {
    box-shadow: 0 8px 24px rgba(27, 42, 74, 0.13);
    transform: translateY(-3px);
    border-top-color: var(--coral);
}

/* Imagen portada */
.listado-mosaico .img-container {
    position: relative;
    background: var(--bg-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 0.5rem;
}

.listado-mosaico .img-container figure {
    margin: 0;
    line-height: 0;
}

.listado-mosaico .img-container .portada {
    height: 180px;
    width: auto;
    max-width: 100%;
    display: block;
}

/* Tags (oferta/novedad) */
.listado-mosaico .tags {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.listado-mosaico .tags .oferta,
.listado-mosaico .tags .novedad {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.4rem;
    border-radius: 2px;
    color: #fff;
}

.listado-mosaico .tags .oferta { background: #e05a2b; }
.listado-mosaico .tags .novedad { background: var(--primary); }

/* Textos */
.listado-mosaico .item h2 {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
}

.listado-mosaico .item h2 a.titulo {
    color: var(--text);
}

.listado-mosaico .item h2 a.titulo:hover {
    color: var(--primary);
}

.listado-mosaico .item h3.subtitulo {
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--text-muted);
    margin: 0.2rem 0 0;
}

.listado-mosaico .item .autor {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0.35rem 0 0;
}

.listado-mosaico .item .editorial {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0.2rem 0 0;
}

/* Precio y botón */
.listado-mosaico .item .mt-auto {
    padding: 0 0.75rem 0.75rem;
}

.listado-mosaico .item .pvp {
    margin-bottom: 0.5rem;
}

.listado-mosaico .item .pvp .ahora {
    font-size: 1rem;
    font-weight: 700;
    color: var(--coral-dark);
    margin: 0;
}

.listado-mosaico .item .pvp .antes {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

/* Paginación y ordenación */
.resultados .tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

/* === FICHA LIBRO === */
.ficha {
    display: grid;
    grid-template-columns: 220px 1fr 220px;
    grid-template-areas:
        "imagen  titulo   compras"
        "imagen  autor    compras"
        "imagen  datos    compras";
    column-gap: 2.5rem;
    row-gap: 0;
    align-items: start;
    margin-top: 1.5rem;
}

.ficha .imagen  { grid-area: imagen; }
.ficha .titulo  { grid-area: titulo; }
.ficha .autor   { grid-area: autor; }
.ficha .datos   { grid-area: datos; }
.ficha .compras { grid-area: compras; }

/* Portada */
.ficha .imagen .portada {
    width: 100%;
    height: auto;
    display: block;
}

.ficha .imagen .img-container {
    position: relative;
}

.ficha .imagen .preview,
.ficha .imagen p {
    margin-top: 0.75rem;
}

/* Título */
.ficha .titulo h1 {
    font-size: 1.6rem;
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.ficha .titulo h2 {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-bottom: 0;
}

/* Autor / editorial */
.ficha .autor {
    padding-top: 0.75rem;
}

.ficha .autor .autor {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.ficha .autor .autor cite a {
    color: var(--text);
    font-style: normal;
    font-weight: 500;
}

.ficha .autor .autor cite a:hover {
    color: var(--primary);
}

.ficha .autor .editorial {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.ficha .autor .editorial a {
    color: var(--text-muted);
}

/* Datos técnicos */
.ficha .datos {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    margin-top: 1rem;
}

.ficha .datos ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ficha .datos ul li {
    font-size: 0.82rem;
    color: var(--text-muted);
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border);
}

.ficha .datos ul li strong {
    color: var(--text);
    font-weight: 600;
    margin-right: 0.25rem;
}

.ficha .datos ul li a {
    color: var(--primary);
}

/* Compras */
.ficha .compras {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.25rem;
}

.ficha .compras .pvp .ahora {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--coral-dark);
    margin: 0;
}

.ficha .compras .pvp .antes {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
}

.ficha .compras .estado {
    font-size: 0.82rem;
    margin: 0.75rem 0;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    background: var(--primary-light);
    color: var(--primary-dark);
}

.ficha .compras .estado.verde { background: #e6f4ea; color: #1e6b35; }
.ficha .compras .estado.naranja { background: #fff3e0; color: #b45309; }
.ficha .compras .estado.rojo { background: #fde8e8; color: #b91c1c; }

.ficha .compras .btn {
    width: 100%;
    margin-top: 0.75rem;
    text-align: center;
}

.ficha .compras .valoracion {
    margin-top: 1rem;
    font-size: 0.8rem;
}

/* Tags en ficha */
.ficha .tags {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ficha .tags .novedad,
.ficha .tags .oferta {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.4rem;
    border-radius: 2px;
    color: #fff;
}

.ficha .tags .novedad { background: var(--primary); }
.ficha .tags .oferta  { background: #e05a2b; }

/* Tabs (resumen, comentarios...) */
.ficha ~ section .nav-tabs {
    border-bottom: 1px solid var(--border);
}

.ficha ~ section .nav-tabs .nav-link {
    color: var(--text-muted);
    border: none;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.ficha ~ section .nav-tabs .nav-link h2 {
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0;
    color: inherit;
}

.ficha ~ section .nav-tabs .nav-link.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    background: none;
}

/* === RESPONSIVE === */
@media (max-width: 1199px) {
    .listado-mosaico {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .ficha {
        grid-template-columns: 180px 1fr 200px;
    }
}

@media (max-width: 767px) {
    .izquierda {
        display: none;
    }

    .listado-mosaico {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 1rem;
    }

    .ficha {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "imagen   compras"
            "titulo   titulo"
            "autor    autor"
            "datos    datos";
    }
}

@media (max-width: 480px) {
    .ficha {
        grid-template-columns: 1fr;
        grid-template-areas:
            "imagen"
            "compras"
            "titulo"
            "autor"
            "datos";
    }

    .ficha .imagen {
        max-width: 200px;
        margin: 0 auto;
    }
}
