/* ============================================================================
   Filtros y ordenamiento de listas de productos en moviles (<= 978px)
   ----------------------------------------------------------------------------
   Aplica a busqueda, categorias, marcas, aplicacion, ofertas, lo nuevo, lo mas
   vendido... (todas usan .head_section + fstore_selectOrderList y, si hay filtros
   activos, fstore_template_filtros en #body_tv_izq).

   - "Ordenar segun" (.mstore_orden) se reduce al icono AZ, en linea con el campo
     de busqueda. Al tocarlo despliega debajo un panel con la etiqueta y el select
     (.mstore_orden_opciones); js/filtros_movil.js lo abre/cierra con .abierto.
   - Los filtros (.store_filtros) dejan de ir al final de la pagina: js/filtros_movil.js
     agrega el boton "Mostrar filtros" bajo esa linea y los presenta como panel
     lateral izquierdo, igual que el menu general (css/menu_movil.css).
   ============================================================================ */

/* icono AZ y boton de filtros: solo en movil */
.mstore_orden_btn,
.mstore_filtros_salto,
.mstore_filtros_btn,
.mstore_filtros_topbar{display:none;}

@media (max-width:978px){

  /* ===== LINEA: titulo / busqueda + orden / boton de filtros ===== */
  div.head_section{
    flex-wrap:wrap;
    gap:8px;
  }
  div.head_section > div:first-child{
    flex:0 0 100%;
    width:100%;
    margin-right:0;
  }
  div.head_section > div.search-container{
    flex:1 1 0;
    min-width:0;
    width:auto;
    max-width:none;
  }
  div.head_section > div.search-container .search-input{width:100%;}

  /* ===== ORDENAR SEGUN: icono AZ que despliega "Ordenar segun" + select ===== */
  div.head_section > div.mstore_orden{
    position:relative;
    flex:0 0 auto;
    width:42px;
    height:42px;
  }
  .mstore_orden_btn{
    display:flex;
    align-items:center;
    justify-content:center;
    width:100%;
    height:100%;
    padding:0;
    border:0;
    border-radius:50%;
    background:#efefef;
    color:#333;
    font-size:18px;
    cursor:pointer;
    transition:background-color .2s ease, box-shadow .2s ease;
  }
  .mstore_orden_btn:hover{background:#e2e2e2;}
  .mstore_orden_btn:focus{outline:none; box-shadow:0 0 0 3px rgba(0,0,0,.12);}
  .mstore_orden.abierto .mstore_orden_btn{background:#e2e2e2;}

  /* panel desplegable bajo el icono */
  .mstore_orden_opciones{
    position:absolute;
    top:calc(100% + 8px);
    right:0;
    z-index:60;
    display:flex;
    flex-direction:column;
    gap:6px;
    width:240px;
    max-width:calc(100vw - 32px);
    padding:12px;
    border-radius:12px;
    background:var(--tema-fondo, #fff);
    color:var(--tema-texto, #333);
    box-shadow:0 8px 24px rgba(0,0,0,.18);
    text-align:left;
    opacity:0;
    visibility:hidden;
    transform:translateY(-6px);
    transition:opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
  }
  .mstore_orden.abierto .mstore_orden_opciones{
    opacity:1;
    visibility:visible;
    transform:none;
    transition:opacity .2s ease, transform .2s ease, visibility 0s;
  }
  .head_section .mstore_orden_opciones label{
    margin:0;
    font-size:13px;
    font-weight:600;
  }
  .head_section .mstore_orden_opciones select{
    width:100%;
    font-size:16px; /* evita el zoom de iOS */
  }

  /* ===== BOTON "MOSTRAR FILTROS" ===== */
  /* salto de linea: el boton siempre empieza renglon, debajo de busqueda + orden */
  .mstore_filtros_salto{
    display:block;
    flex:0 0 100%;
    height:0;
    margin-top:-8px; /* compensa el gap del renglon vacio */
  }
  .mstore_filtros_btn{
    flex:1 1 auto;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    min-height:42px;
    padding:8px 16px;
    border:0;
    border-radius:20px;
    background:#efefef;
    color:#333;
    font-size:14px;
    font-weight:600;
    cursor:pointer;
    transition:background-color .2s ease;
  }
  .mstore_filtros_btn:hover,
  .mstore_filtros_btn:focus{background:#e2e2e2; outline:none;}
  .mstore_filtros_btn .badge{
    background:var(--tema-boton, #374151);
    color:var(--tema-tinta-boton, #fff);
    border-radius:10px;
    font-size:11px;
  }
  div.head_section > .view-icons{margin:0;}

  /* ===== PANEL LATERAL DE FILTROS ===== */
  #body_tv_izq.mstore_izq_filtros{display:none;}

  .store_filtros.mstore_filtros_panel{
    position:fixed;
    top:0;
    left:0;
    width:300px;
    max-width:85vw;
    height:100vh;
    height:100dvh;
    margin:0;
    padding:15px 15px 20px;
    background:var(--tema-fondo, #fff);
    color:var(--tema-texto, #333);
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
    text-align:left;
    box-shadow:4px 0 20px rgba(0,0,0,.15);
    z-index:1100;
    transform:translateX(-100%);
    visibility:hidden;
    transition:transform .3s ease, visibility 0s linear .3s;
  }
  .store_filtros.mstore_filtros_panel.abierto{
    transform:translateX(0);
    visibility:visible;
    transition:transform .3s ease, visibility 0s;
  }
  .mstore_filtros_panel .store_filtros_head_title{display:none;}
  .mstore_filtros_panel .store_filtros_head{padding:0;}

  #mstore_filtros_fondo{
    position:fixed;
    top:0;left:0;right:0;bottom:0;
    background:rgba(0,0,0,.35);
    z-index:1099;
    opacity:0;
    visibility:hidden;
    transition:opacity .3s ease, visibility 0s linear .3s;
  }
  #mstore_filtros_fondo.abierto{
    opacity:1;
    visibility:visible;
    transition:opacity .3s ease, visibility 0s;
  }
  body.mstore_filtros_abierto{overflow:hidden;}

  /* topbar: boton cerrar + titulo, como el menu general */
  .mstore_filtros_topbar{
    display:flex;
    align-items:center;
    padding-bottom:15px;
  }
  .mstore_filtros_cerrar{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:42px;
    height:42px;
    padding:0;
    border:0;
    border-radius:10px;
    background:#374151;
    color:#fff;
    font-size:18px;
    cursor:pointer;
  }
  .mstore_filtros_cerrar:hover{opacity:.9;}
  .mstore_filtros_titulo{font-weight:600;margin-left:15px;}

  /* ===== TEMA OSCURO ===== */
  .tema_oscuro .mstore_orden_btn,
  .tema_oscuro .mstore_filtros_btn{
    background:rgba(255,255,255,.12);
    color:#eef1f5;
  }
  .tema_oscuro .mstore_orden_btn:hover,
  .tema_oscuro .mstore_orden.abierto .mstore_orden_btn,
  .tema_oscuro .mstore_filtros_btn:hover,
  .tema_oscuro .mstore_filtros_btn:focus{background:rgba(255,255,255,.2);}
  .tema_oscuro .mstore_filtros_cerrar{background:rgba(255,255,255,.16);}
}

@media (max-width:978px) and (prefers-reduced-motion:reduce){
  .store_filtros.mstore_filtros_panel,
  #mstore_filtros_fondo,
  .mstore_orden_opciones{transition:none;}
}
