/* ================================
   HEADER (SEGÚN BRIEF)
================================ */

.header {
    width: 100%;
    height: 100px;
    background: var(--azul-header);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 30px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    position: relative;
}

.menu-btn {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 28px;
    cursor: pointer;
    background: none;
    border: none;
    color: #ffffff;
    z-index: 100;
}

.logo {
    position: absolute !important;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000 !important;
    cursor: pointer !important;
}

.logo a {
    display: block;
    cursor: pointer;
    position: relative;
    z-index: 10000 !important;
}

.logo img {
    height: 90px;
    display: block;
    filter: brightness(0) invert(1) !important;
    pointer-events: none;
}

.header .logo img {
    filter: brightness(0) invert(1) !important;
}

.acceso {
    display: flex;
    align-items: center;
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
}

.btn-acceso {
    color: var(--azul-prusiano);
    background-color: var(--blanco);
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: bold;
    text-decoration: none;
}

/* ================================
   MENÚ LATERAL OFF-CANVAS
================================ */

.menu-lateral {
    position: fixed;
    top: 0;
    left: -280px;
    width: 260px;
    height: 100%;
    background: var(--azul-prusiano);
    color: #ffffff;
    padding: 20px;
    transition: left 0.3s ease;
    z-index: 1100;
}

.menu-lateral.activo {
    left: 0;
}

.menu-cerrar {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 28px;
    cursor: pointer;
    display: block;
    margin-left: auto;
}

.menu-lista {
    list-style: none;
    margin-top: 20px;
}

.menu-lista li {
    margin-bottom: 10px;
}

.menu-lista a {
    color: #ffffff;
    text-decoration: none;
    font-size: 16px;
}

/* Fondo oscuro cuando el menú está abierto */
.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    z-index: 1050;
}

.menu-overlay.activo {
    opacity: 1;
    visibility: visible;
}

/* ================================
   MENÚ DE USUARIO LOGUEADO
================================ */

#usuario-logueado {
    position: relative;
    padding: 8px 16px;
}

#usuario-logueado:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

#menu-usuario a:hover {
    background-color: #f0f4f8;
}

/* ================================
   MENÚ DESPLEGABLE LATERAL (del index original)
================================ */

.menu {
    position: absolute;
    display: inline-block;
    font-size: 1.1em;
    top: 100%;
    left: 0;
    height: calc(100vh - 100px);
    width: 220px;
    max-width: 80%;
    overflow-y: auto;
    background-color: #333;
    color: white;
    padding-top: 12px;
    z-index: 8000;
    box-shadow: -1px 0 5px 2px rgba(0,0,0,0.7);
    margin-top: 0;
    transform: none;
}

.menu-icon {
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 32px;
    z-index: 9999;
    color: white;
    width: 50px;
    height: 50px;
    border: none;
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-icon:hover {
    color: #ddd;
}

.menu-icon.active {
    color: #ddd;
}

.menu-items {
    padding: 16px 12px;
}

.menu-items h3 {
    cursor: pointer;
    margin: 8px 0;
    font-size: 1rem;
}

.menu-items h3:hover {
    color: aquamarine;
}

.menu:not(.oculto) .menu-items,
.menu:not(.oculto) .menu-items h3 {
    text-align: left !important;
}

.menu-items hr {
    background-color: rgba(255,255,255,0.6);
    box-shadow: 0 2px 2px 0 rgba(255,255,255,0.2);
    border: none;
    height: 1px;
}

.oculto {
    display: none !important;
}

/* ================================
   BUSCADOR EN HEADER
================================ */

.search-wrapper {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 330px; /* Desplazar a la derecha del logo */
    z-index: 100;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 0;
    position: relative;
}

.search-form input[type="search"] {
    padding: 8px 12px;
    border-radius: 4px 0 0 4px;
    border: 1px solid rgba(255,255,255,0.6);
    outline: none;
    min-width: 200px;
    width: 200px;
    font-size: 14px;
}

.search-form input[type="search"]::placeholder {
    color: rgba(0,0,0,0.5);
}

.search-form button[type="submit"] {
    padding: 8px 12px;
    border-radius: 0 4px 4px 0;
    border: 1px solid rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.15);
    color: white;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.search-form button[type="submit"]:hover {
    background: rgba(255,255,255,0.25);
}

.search-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1001;
}

.suggestion-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    color: #333;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item:focus {
    background: #f0f6ff;
    outline: none;
}

.sugerencia-autor {
    color: #666;
    font-size: 0.9em;
    margin-left: 8px;
}

.search-toggle-icon {
    display: none; /* Oculto por defecto en desktop */
}

/* Responsive para 1440x900 */
@media (max-width: 1440px) and (min-width: 1025px) {
    .search-wrapper {
        margin-left: 200px;
    }
}

/* Responsive para tablets */
@media (max-width: 1024px) {
    .search-wrapper {
        left: auto;
        right: 180px;
        margin-left: 0;
        transform: translateY(-50%);
    }
    
    .search-form input[type="search"] {
        min-width: 150px;
        width: 150px;
    }
    
    .acceso {
        right: 15px;
    }
}

/* Responsive para tablets pequeños - mostrar icono colapsable */
@media (max-width: 768px) {
    .header {
        padding: 0 16px;
    }

    .logo img {
        height: 45px;
    }

    .search-wrapper {
        right: 140px;
    }
    
    .acceso {
        right: 10px;
    }
    
    .search-toggle-icon {
        display: inline-block;
        width: 36px;
        height: 36px;
        background: rgba(255,255,255,0.15);
        border: 1px solid rgba(255,255,255,0.6);
        border-radius: 4px;
        cursor: pointer;
        position: relative;
        transition: background 0.2s;
    }
    
    .search-toggle-icon:hover {
        background: rgba(255,255,255,0.25);
    }
    
    .search-toggle-icon::before {
        content: "🔍";
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        font-size: 18px;
    }
    
    .search-form input[type="search"],
    .search-form button[type="submit"] {
        display: none;
    }
    
    .search-wrapper.expanded .search-form input[type="search"],
    .search-wrapper.expanded .search-form button[type="submit"] {
        display: inline-block;
    }
    
    .search-wrapper.expanded .search-form input[type="search"] {
        width: 120px;
        min-width: 120px;
        animation: expandSearch 0.3s ease-out;
    }
    
    .search-wrapper.expanded .search-toggle-icon {
        display: none;
    }
    
    @keyframes expandSearch {
        from {
            width: 0;
            min-width: 0;
            padding-left: 0;
            padding-right: 0;
        }
        to {
            width: 120px;
            min-width: 120px;
        }
    }
}

/* Ocultar en móviles muy pequeños */
@media (max-width: 480px) {
    .search-wrapper {
        display: none;
    }
}
