/* ==========================================================================
   Estilos Unificados y Modernos para ParaEscolares.com (style.css)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Montserrat:wght@500;700&display=swap');

:root {
    --bg-body: #f8fafc;
    --bg-header: #0f172a;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-accent: #06b6d4;
    --color-card-bg: #ffffff;
    --color-card-border: #e2e8f0;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 10px 15px -3px rgba(79, 70, 229, 0.1), 0 4px 6px -2px rgba(79, 70, 229, 0.05);
    --radius-lg: 16px;
    --radius-md: 10px;
    --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   Header & Navigation (Identical across all pages)
   ========================================================================== */

.header, .pe-header {
    background: #0f172a;
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    color: white;
    padding: 16px 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-inner, .pe-header-inner {
    max-width: 1280px;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.logo, .pe-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: white;
    transition: transform 0.2s ease;
}

.logo:hover, .pe-logo:hover {
    transform: scale(1.02);
}

.logo-icon, .pe-logo-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--color-primary) 0%, #6366f1 100%);
    display: grid;
    place-items: center;
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
}

.logo-text, .pe-logo-text {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.logo-sub, .pe-logo-sub {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 1px;
    font-weight: 500;
}

.nav-links, .pe-nav-links {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-link {
    color: #e2e8f0;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

nav {
    background: var(--bg-header);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

nav ul {
    list-style: none;
    padding: 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin: 0;
    max-width: 1300px;
    margin: 0 auto;
}

nav ul li {
    margin: 0;
}

nav ul li a {
    color: #94a3b8;
    text-decoration: none;
    font-weight: 600;
    font-size: 13.5px;
    display: block;
    padding: 14px 18px;
    transition: all 0.25s ease;
}

nav ul li a:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   Container & Layout
   ========================================================================== */

.container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

main {
    display: flex;
    gap: 30px;
    padding: 30px 0;
    flex-grow: 1;
}

/* ==========================================================================
   Aside (Sidebar)
   ========================================================================== */

aside {
    width: 280px;
    flex-shrink: 0;
    background: #ffffff;
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-card-border);
    box-shadow: var(--shadow-soft);
    align-self: flex-start;
}

aside h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #475569;
    margin: 24px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
    width: 100%;
    background: transparent;
    text-align: left;
}

aside h2:first-of-type {
    margin-top: 0;
}

aside ul {
    list-style: none;
    padding: 0;
}

aside ul li {
    margin: 6px 0;
    margin-left: 0;
}

aside ul li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    text-decoration: none;
    text-transform: capitalize;
    transition: all 0.2s ease;
}

aside ul li a:hover {
    color: var(--color-primary);
    background: #f1f5f9;
}

aside ul li a img {
    margin-right: 0;
    width: 18px;
    height: 18px;
    object-fit: contain;
}

/* ==========================================================================
   Section (Main Content Area)
   ========================================================================== */

section {
    flex-grow: 1;
    background-color: #ffffff;
    padding: 32px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-card-border);
    box-shadow: var(--shadow-soft);
    width: auto;
    margin-left: 0;
}

section h2 {
    font-size: 24px;
    color: #0f172a;
    margin-top: 0;
    margin-bottom: 12px;
    font-weight: 800;
    text-transform: none;
    letter-spacing: -0.5px;
}

section p {
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--color-text-muted);
    line-height: 1.6;
    font-weight: 500;
    text-align: left;
    font-family: var(--font-family);
}

/* ==========================================================================
   Search Form
   ========================================================================== */

section form {
    display: flex;
    gap: 8px;
    max-width: 500px;
    margin-bottom: 30px;
}

section form input[type="text"] {
    flex-grow: 1;
    border: 2px solid #e2e8f0;
    border-radius: 30px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    outline: none;
    transition: all 0.25s ease;
    background: #f8fafc;
    color: #0f172a;
}

section form input[type="text"]:focus {
    border-color: var(--color-primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

section form button {
    background: var(--color-primary);
    color: #ffffff;
    border: none;
    border-radius: 30px;
    padding: 10px 24px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
}

section form button:hover {
    background: var(--color-primary-hover);
}

/* ==========================================================================
   File Items Grid
   ========================================================================== */

.file-item {
    display: inline-flex;
    flex-direction: column;
    width: calc(33.333% - 20px);
    margin: 10px;
    padding: 16px;
    background: #ffffff;
    border: 1px solid var(--color-card-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    vertical-align: top;
    text-align: left;
}

.file-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: rgba(79, 70, 229, 0.2);
}

.file-item a {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    flex-grow: 1;
}

.file-item img.thumbnail {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    object-position: center;
    border-radius: var(--radius-md);
    border: 1px solid #f1f5f9;
    transition: transform 0.3s ease;
    margin-bottom: 12px;
}

.thumbnail-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    border-radius: var(--radius-md);
    background: #f1f5f9;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #f1f5f9;
    margin-bottom: 12px;
}

.thumbnail-wrapper::before {
    content: '📄';
    font-size: 48px;
    position: absolute;
    z-index: 1;
    opacity: 0.15;
}

.thumbnail-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    position: relative;
    z-index: 2;
    transition: opacity 0.2s ease, transform 0.3s ease;
}

.thumbnail-wrapper img:hover {
    transform: scale(1.05);
}

.file-item h3 {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    text-transform: capitalize;
    line-height: 1.4;
    min-height: 38px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: none;
}

.file-item:hover h3 {
    color: var(--color-primary);
}

.download-button {
    display: inline-block;
    width: 100%;
    padding: 8px 16px;
    background: var(--color-primary);
    color: #ffffff !important;
    text-decoration: none;
    font-weight: 700;
    border-radius: 30px;
    font-size: 13px;
    margin: 0;
    text-align: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.15);
}

.download-button:hover {
    background-color: var(--color-primary-hover);
    color: #ffffff !important;
    box-shadow: 0 6px 12px rgba(79, 70, 229, 0.25);
}

/* ==========================================================================
   Details Page
   ========================================================================== */

.file-details {
    text-align: center;
}

.file-details p {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.file-details img.detail-image {
    width: 100%;
    max-width: 600px;
    height: auto;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    border: 1px solid var(--color-card-border);
    margin: 20px auto;
}

.detail-image {
    width: 100% !important;
    max-width: 500px !important;
    height: auto !important;
    display: block !important;
    margin: 20px auto !important;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    border: 1px solid var(--color-card-border);
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
}

.detail-image:hover {
    transform: scale(1.02) !important;
    box-shadow: 0 15px 30px rgba(0,0,0,0.1) !important;
}

@media (min-width: 769px) {
    .file-details img.detail-image {
        max-width: 800px;
        margin: 30px auto;
    }
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination {
    text-align: center;
    margin-top: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 16px;
    text-decoration: none;
    background: #ffffff;
    color: #475569;
    border-radius: 30px;
    font-size: 13.5px;
    font-weight: 600;
    border: 1px solid var(--color-card-border);
    transition: all 0.2s ease;
}

.pagination a:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.pagination span {
    background: var(--color-primary);
    color: #ffffff;
    border-color: var(--color-primary);
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.15);
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
    width: 100%;
    background-color: var(--bg-header);
    color: #94a3b8;
    text-align: center;
    padding: 30px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.footer-robnei-menu ul {
    list-style: none;
    padding: 0;
    margin: 0 auto 12px;
    display: inline-flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-robnei-link {
    color: #94a3b8;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: color 0.2s ease;
}

.footer-robnei-link:hover {
    color: #ffffff;
}

.footer-robnei-text {
    margin: 0;
    font-size: 13px;
    color: #64748b;
}

/* ==========================================================================
   Responsive adjustments
   ========================================================================== */

@media (max-width: 1024px) {
    main {
        gap: 20px;
    }
    
    .file-item {
        width: calc(33.333% - 16px);
        margin: 8px;
    }
}

@media (max-width: 768px) {
    header img {
        width: 200px;
    }

    .container {
        padding: 0 12px;
    }

    /* Orden móvil: El contenido principal (.section) va PRIMERO, el menú de colecciones (.aside) va DEBAJO */
    main {
        display: flex;
        flex-direction: column;
        padding: 16px 0 32px;
        gap: 20px;
    }

    section {
        order: 1;
        width: 100%;
        padding: 20px 16px;
        border-radius: var(--radius-lg);
        box-sizing: border-box;
    }

    aside {
        order: 2;
        width: 100%;
        align-self: stretch;
        padding: 0;
        background: transparent;
        border: none;
        box-shadow: none;
        box-sizing: border-box;
    }

    /* Widgets de Colecciones y Redes en Móvil */
    .aside-widget {
        background: #ffffff;
        border: 1px solid var(--color-card-border);
        border-radius: var(--radius-lg);
        padding: 16px;
        margin-bottom: 16px;
        box-shadow: var(--shadow-soft);
        box-sizing: border-box;
    }

    .aside-widget h3 {
        font-size: 13.5px;
        font-weight: 800;
        margin-bottom: 12px;
        color: #334155;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    /* Presentación en Grid amigable al tacto para colecciones */
    aside .aside-widget ul,
    .aside-widget .collections-list {
        display: grid !important;
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 8px !important;
        list-style: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    aside .aside-widget ul li,
    .aside-widget .collections-list li {
        margin: 0 !important;
        width: 100%;
    }

    aside .aside-widget ul li a,
    .aside-widget .collections-list li a {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 10px 12px !important;
        background: #f8fafc !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: var(--radius-md) !important;
        font-size: 12.5px !important;
        font-weight: 600 !important;
        color: #334155 !important;
        text-decoration: none !important;
        transition: all 0.2s ease !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        box-sizing: border-box !important;
    }

    aside .aside-widget ul li a:hover,
    aside .aside-widget ul li a:active {
        background: #f1f5f9 !important;
        border-color: #cbd5e1 !important;
        color: var(--color-primary) !important;
    }

    aside .aside-widget ul li a.active-folder,
    .aside-widget .collections-list li a.active-folder {
        background: rgba(79, 70, 229, 0.1) !important;
        border-color: rgba(79, 70, 229, 0.35) !important;
        color: var(--color-primary) !important;
        font-weight: 700 !important;
    }

    /* Redes sociales en móvil */
    .social-links-list {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .social-link-btn {
        justify-content: center !important;
        padding: 10px 12px !important;
        font-size: 13px !important;
        border-radius: var(--radius-md) !important;
    }

    /* Header y Sub-Navbar móvil */
    .pe-header {
        padding: 12px 14px !important;
    }

    .pe-header-inner {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
    }

    .pe-logo {
        gap: 10px;
    }

    .pe-logo-icon {
        width: 38px !important;
        height: 38px !important;
        font-size: 20px !important;
        border-radius: 10px !important;
    }

    .pe-logo-text {
        font-size: 18px !important;
    }

    .pe-logo-sub {
        font-size: 10.5px !important;
    }

    .pe-nav-links {
        gap: 6px !important;
    }

    .pe-nav-links .nav-link {
        padding: 6px 10px !important;
        font-size: 12px !important;
        border-radius: 8px !important;
    }

    /* Sub-Navbar con desplazamiento horizontal táctil (estilo App) */
    .pe-subnav {
        padding: 0 8px !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .pe-subnav-container {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 6px !important;
        padding: 6px 0 !important;
    }

    .pe-nav-categories {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important; /* Firefox */
        gap: 6px !important;
        padding: 4px 2px 6px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .pe-nav-categories::-webkit-scrollbar {
        display: none !important; /* Chrome/Safari */
    }

    .pe-nav-categories li {
        flex-shrink: 0 !important;
    }

    .pe-nav-categories li a {
        display: inline-block !important;
        padding: 8px 14px !important;
        font-size: 12.5px !important;
        font-weight: 600 !important;
        background: rgba(255, 255, 255, 0.06) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        border-radius: 20px !important;
        color: #cbd5e1 !important;
        white-space: nowrap !important;
    }

    .pe-nav-categories li a:hover,
    .pe-nav-categories li a:active {
        color: #ffffff !important;
        background: rgba(255, 255, 255, 0.15) !important;
    }

    .pe-nav-user {
        display: flex !important;
        justify-content: center !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        padding: 2px 0 4px !important;
    }

    .pe-nav-user li a {
        padding: 6px 14px !important;
        font-size: 12.5px !important;
        border-radius: 8px !important;
        white-space: nowrap !important;
    }

    /* Buscador en Móvil */
    section form {
        max-width: 100% !important;
        flex-wrap: nowrap !important;
        margin-bottom: 20px !important;
    }

    section form input[type="text"] {
        padding: 10px 14px !important;
        font-size: 13.5px !important;
    }

    section form button {
        padding: 10px 18px !important;
        font-size: 13.5px !important;
        white-space: nowrap !important;
    }

    /* Grid de Archivos en móvil (2 columnas bien optimizadas) */
    .file-grid {
        margin: 0 -6px !important;
    }

    .file-item {
        width: calc(50% - 12px) !important;
        margin: 6px !important;
        padding: 12px !important;
        border-radius: var(--radius-md) !important;
    }

    .file-item h3 {
        font-size: 12.5px !important;
        min-height: 34px !important;
        margin-bottom: 8px !important;
    }

    .download-button {
        padding: 7px 10px !important;
        font-size: 12px !important;
    }
}

@media (max-width: 480px) {
    aside .aside-widget ul,
    .aside-widget .collections-list {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .file-item {
        width: calc(50% - 8px) !important;
        margin: 4px !important;
        padding: 10px !important;
    }

    .file-item h3 {
        font-size: 12px !important;
        min-height: 32px !important;
    }

    .download-button {
        padding: 6px 8px !important;
        font-size: 11.5px !important;
    }
}

@media (max-width: 360px) {
    .file-item {
        width: 100% !important;
        margin: 6px 0 !important;
    }

    aside .aside-widget ul,
    .aside-widget .collections-list {
        grid-template-columns: 1fr !important;
    }
}
