/* Versión para móvil y tablet (pantallas de hasta 900 px). Se carga después de css_intranet.css y mejoras.css. */

#mws-menu-toggle { display: none; }
.solo-movil { display: none; font-style: normal; }

@media only screen and (max-width: 900px) {
    html, body { height: auto; min-height: 100%; overflow-x: hidden; -webkit-text-size-adjust: 100%; }
    body { font-size: 14px; }
    img, video, audio { max-width: 100%; height: auto; }

    /* ---- Cabecera fija: botón de menú, logo y «Salir» ---- */
    div#mws-header { position: fixed; height: 46px; z-index: 60; background-size: auto 100%; }
    #mws-menu-toggle { display: block; float: left; width: 38px; height: 38px; margin: 4px 0 0 6px; border-radius: 4px; background: rgba(0, 0, 0, .35); line-height: 36px; line-height: 40px; text-align: center;
        font-size: 26px; color: #fff; text-decoration: none; -webkit-tap-highlight-color: transparent; }
    div#mws-logo-container { height: 46px; padding: 0 6px; }
    div#mws-logo-container #mws-logo-wrap { width: 120px; height: 42px; }
    div#mws-user-tools { padding: 8px 0; margin-right: 4px; }
    div#mws-user-tools #mws-user-info { width: auto; margin: 0 4px; }
    div#mws-user-tools #mws-user-info #mws-user-functions #mws-username { display: none; }

    /* ---- Menú lateral: oculto hasta pulsar ☰ ---- */
    div#mws-sidebar { position: fixed; top: 50px; left: 0; bottom: 0; width: 82%; max-width: 320px; padding: 8px 0 24px; z-index: 55;
        overflow-y: auto; -webkit-overflow-scrolling: touch; float: none; background: #333 url(/images/fondo_menu.png);
        transform: translateX(-105%); transition: transform .2s ease-out; box-shadow: 2px 0 8px rgba(0, 0, 0, .4); }
    body.menu-abierto div#mws-sidebar { transform: none; }
    div#mws-sidebar-stitch, div#mws-sidebar-bg { display: none; }
    div#mws-navigation ul li a, div#mws-navigation ul li span { padding-top: 12px; padding-bottom: 12px; }   /* zona táctil mayor */
    div#mws-navigation ul li ul li.active { margin-left: 0; padding-left: 0; }

    /* ---- Contenido a todo el ancho ---- */
    div#mws-container { margin: 0; padding-top: 54px; }
    div#mws-container .container { position: static; float: none; width: 98%; margin: 0 auto; left: auto; top: auto; }
    .grid_1, .grid_2, .grid_3, .grid_4, .grid_5, .grid_6, .grid_7, .grid_8, .grid_full { float: none; width: 100%; margin: 0 0 12px; }

    /* Las tablas se desplazan de lado dentro de su panel en lugar de salirse de la pantalla */
    .mws-panel .mws-panel-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table.mws-table { width: 100%; min-width: 640px; }
    table.mws-table th, table.mws-table td { padding-left: 6px; padding-right: 6px; }
    .mws-table td, .mws-table th { font-size: 13px; }

    /* Cabeceras de los paneles (título, filtros y botones) apiladas en varias líneas */
    .mws-panel .mws-panel-header { background: #0083bb linear-gradient(to bottom, #014e86, #008fc7) !important; height: auto !important; min-height: 34px; padding: 8px 10px; overflow: visible; line-height: 1.3; }
    .mws-panel .mws-panel-header table, .mws-panel .mws-panel-header table tbody, .mws-panel .mws-panel-header table tr,
    .mws-panel .mws-panel-header table td { display: block !important; width: auto !important; box-sizing: border-box; }
    .mws-panel .mws-panel-header table td { text-align: left !important; white-space: normal !important; padding: 3px 0 !important; }
    .mws-panel .mws-panel-header table table { display: block !important; }
    .mws-panel .mws-panel-header select { min-width: 84px; width: auto !important; }
    .mws-panel .mws-panel-header input[type=text], .mws-panel .mws-panel-header select { margin: 2px 4px 2px 0; max-width: 100%; vertical-align: middle; }
    .mws-panel .mws-panel-header .enlace_boton, .mws-panel .mws-panel-header .mws-button { display: inline-block; margin: 3px 4px 3px 0; }

    /* Cabecera de los listados: en móvil solo quedan los botones de la derecha (título, año y filtros se ocultan) */
    .mws-panel .mws-panel-header table table > tbody > tr > td:not(:last-child) { display: none !important; }
    .mws-panel .mws-panel-header table table > tbody > tr > td:last-child { padding: 0 !important; }

    /* En móvil, sobre los listados solo quedan los botones: se ocultan la leyenda de iconos y la fila «Mostrar N entradas / Buscar» */
    .mws-panel .mws-panel-toolbar,
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter { display: none !important; }

    .solo-movil { display: inline; }

    /* Leyenda de iconos: en línea y sin solaparse con la tabla */
    div.mws-panel-toolbar { overflow: hidden; }
    div.mws-panel-toolbar ul { float: none; }
    div.mws-panel-toolbar ul li { float: left; }
    div.mws-panel-toolbar ul li a, div.mws-panel-toolbar ul li span { padding: 6px 10px; }

    /* Controles de DataTables (mostrar N entradas / buscar / paginación) */
    .dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_paginate { float: none !important; text-align: left !important; padding: 6px 10px; }
    .dataTables_wrapper .dataTables_filter input { width: 60%; }

    /* ---- Formularios en una columna ---- */
    .mws-form .mws-form-row { padding: 8px 10px; }
    .mws-form .mws-form-inline label, .mws-form .mws-form-inline .mws-form-item { display: block; width: 100%; float: none; margin: 0; }
    .mws-form .mws-form-item.small, .mws-form .mws-form-item.large, .mws-form .mws-form-item.medium { width: 100%; }
    .mws-form input[type=text], .mws-form input[type=password], .mws-form input[type=file], .mws-form select, .mws-form textarea {
        width: 100% !important; max-width: 100%; box-sizing: border-box; font-size: 16px; }   /* 16 px evita el zoom automático de iOS */
    .mws-form input[type=text].fecha-calendario { width: 100% !important; }
    .mws-form .mws-button { padding: 10px 18px; }
    input[type=text], input[type=password], select, textarea { font-size: 16px; }

    /* Calendario emergente más cómodo de tocar */
    #ui-datepicker-div td a, #ui-datepicker-div td span { width: 34px; padding: 7px 0; }

    /* Inicio */
    #mws-container .container > table { max-width: 100%; }
}

@media only screen and (max-width: 480px) {
    div#mws-logo-container #mws-logo-wrap { width: 96px; }
    table.mws-table { min-width: 560px; }
}

/* ---- Ventanas emergentes (Shadowbox) a pantalla completa en móvil ---- */
@media only screen and (max-width: 900px) {
    #sb-container { position: fixed !important; top: 0 !important; left: 0 !important; width: 100% !important; height: 100% !important; }
    #sb-wrapper { left: 0 !important; right: 0 !important; width: 100% !important; max-width: 100% !important; margin: 0 !important; top: 0 !important; }
    #sb-wrapper-inner, #sb-body, #sb-body-inner, #sb-player { width: 100% !important; max-width: 100% !important; }
    #sb-wrapper-inner { height: auto !important; min-height: 100% !important; }
    #sb-body, #sb-body-inner, #sb-player { height: calc(100vh - 44px) !important; }
    #sb-player, #sb-body-inner iframe { width: 100% !important; height: 100% !important; }
    #sb-info, #sb-info-inner { height: 44px !important; }
    #sb-nav a { width: 44px !important; height: 44px !important; }
    #sb-nav-close { background-size: 24px !important; }
}

/* ---- Pantalla de entrada (login) a casi todo el ancho ---- */
@media only screen and (max-width: 900px) {
    div#mws-login { position: fixed; left: 15%; top: 50%; transform: translateY(-50%); width: 70%; height: auto; margin: 0; padding: 18px 5% 22px; box-sizing: border-box; }   /* centrado en la pantalla */
    div#mws-login .mws-login-lock { right: -6px; }
    div#mws-login .TITULO, div#mws-login h1 { font-size: 20px; height: auto; }
    div#mws-login .mws-form-row { padding-top: 10px; padding-bottom: 6px; }
    div#mws-login input.mws-login-username, div#mws-login input.mws-login-password { width: 100% !important; box-sizing: border-box; padding: 13px 10px 13px 38px; font-size: 17px; }
    div#mws-login input.mws-login-button { padding: 13px 10px; font-size: 19px; width: 100%; box-sizing: border-box; }
    div#mws-login .aviso { font-size: 15px; }
}
