body,
html {
  height: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow: visible;
  overflow-x: hidden;

  .sidebar-section.mostrar-al-carregar .submenu-container {
    display: block;
  }
	.ruta-navegacio {
  transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
  /* Aseguramos que sea visible por defecto */
  transform: translateY(0);
  opacity: 1;
}

/* Esta clase la añadiremos con JavaScript */
.ruta-navegacio-hidden {
	
   transform: translateY(-100%); /*Lo desplaza hacia arriba */
   opacity: 0;
   pointer-events: none;  /* Evita que se pueda clicar mientras está oculto */
}

  /*#contenidor,*/
  main {
    position: relative;
    display: block;
    flex: 1 0 auto;
    padding-top: 150px;
    margin-top: 0;
    overflow: visible !important;
    height: auto !important;

  }

  input[list]:focus,
  select:focus {
    scroll-margin-top: 0 !important;
    outline: none;
  }

  .submenu-faq.actiu>a,
  .submenu-faq a.actiu {
    color: #c40000 !important;
    font-weight: 600;
  }

  .submenu-faq.actiu {
    background-color: transparent;
  }


  /* Sidebar FAQ */
  .globus-de-preguntes.sidebar-faq {
    max-width: 320px;
    width: 400px;
    margin-right: auto;
    margin-top: 5%;
    /*modificat*/
    margin-bottom: 5%;
    padding: 0;
    padding-top: 8px;
    display: block;
    flex-direction: column;
    gap: 20px;
    /* overflow-y: visible;  */
    overflow-y: auto !important;	
    overflow-x: visible;
    flex-grow: 1;
    align-self: flex-start;
    position: sticky;

    height: 100vh;
    /* max-height: none; */
    max-height: calc(100vh - 80px);
    flex-shrink: 0;
    z-index: 998;
    background: transparent;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  }

  /* Para columna derecha */
  .globus-de-preguntes.sidebar-faq[data-posicio="dreta"] {
    bottom: 60px;
  }

  /* Ocultar con transiciÃ³n */
  .ocultar-scroll {
    transform: translateY(-100%);
    transition: transform 0.3s ease-in-out;
  }

  .sidebar-section {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    margin-bottom: 20px;
    margin-top: 5px;
    scroll-margin-top: 180px;
    border-radius: 5px;
    padding: 20px;
    border-top: 6px solid #c00;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    transform-origin: center;
    pointer-events: auto;
    background-color: #ffff;
    cursor: pointer;	  
    overflow: visible !important;
    position: relative !important;

    .mostrar-al-carregar .submenu-container {
      display: block;
    }

    &:hover {
      transform: scale(1.02);
      box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    }

    .titol-menu-faq {
      display: flex;
      justify-content: space-between;
      /* align-items: center; */
      position: relative;
      padding-right: 10px;
      margin-bottom: 12px;
      color: #333;
      font-weight: bold;
      font-size: 1.1rem;
      cursor: pointer;
      transition: text-decoration 0.3s;

      &:hover {
        text-decoration: underline;
      }
    }

    .submenu-container {
      margin-top: 10px;
      overflow: visible;
      max-height: none;
      height: auto;
      display: none;

      ul {
        list-style: none;
        padding: 0;
        margin: 0;
      }


      .submenu-faq {
        margin: 10px 0;
        padding-left: 10px;
        border-left: 2px solid #ddd;
        cursor: pointer;
        transition: border-color 0.2s, background-color 0.2s;
        position: relative;

        &:hover {
          border-left-color: #c00;
        }

        &.actiu {
          /* border-left-color: #c00; -- ELIMINAT PERQUÈ SIGUI GRIS */
          /* border-left: 4px solid #c00; -- ELIMINAT PERQUÈ SIGUI PRIM */

          /* Mantenim el color del text actiu o el deixem gris? 
         L'usuari diu "marquin el marge lateral esquerra en vermell només quan passes per sobre".
         Per tant, aquí no posem vermell, només mostrem el contingut. */

          >a,
          .submenu-toggle {
            /* color: #c00; -- ELIMINAT */
            font-weight: bold;
            /* Mantenim negreta per indicar obertura? O no? L'usuari no ho ha especificat, però millor deixar-ho per coherència */
          }

          .sub-submenu {
            display: block !important;
            opacity: 1;
            max-height: 1000px;
            /* Augmentat per si de cas */
            transition: all 0.3s ease;
          }
        }

        a {
          color: #333;
          text-decoration: none;
          display: block;

          &:hover {
            color: #c00;
            text-decoration: underline;
          }
        }

        .sub-submenu {
          display: none;
          opacity: 0;
          max-height: 0;
          overflow: hidden;
          margin-left: 15px;
          padding-left: 10px;
          border-left: 1px dashed #ddd;
          transition: all 0.3s ease;

          li {
            margin: 8px 0;
            padding-left: 5px;
            transition: all 0.2s;

            &:hover {
              border-left: 2px solid #c00;
              padding-left: 8px;
            }
          }

          a {
            color: #666;
            font-size: 14px;
            position: relative;

            &:hover {
              color: #c00;
              text-decoration: underline;
            }

            /* Estilo para opciÃ³n seleccionada */
            &.selected {
              color: #c00;
              font-weight: bold;
              background-color: #fff3f3;
              padding: 4px 6px;
              border-radius: 4px;

              &::after {
                content: "✓";
                margin-left: 5px;
                color: #c00;
              }
            }
          }
        }
      }

      select {
        padding: 8px;
        border: 1px solid #ddd;
        background: #fff;
        transition: border 0.2s;

        p {
          width: 100%;
          margin: 10px 0;
          font-size: 14px;
        }

        &:focus {
          border-color: #000;
          box-shadow: 0 0 0 2px rgba(191, 0, 0, 0.1);
          outline: none;
        }
      }

      .llista-formulari {
        list-style: none;
        padding: 0;
        margin: 0;

        li {
          margin-bottom: 15px;
          position: relative;

          label {
            display: block;
            margin-bottom: 5px;
            font-size: 0.9em;
            color: #555;
            scroll-margin-top: 0 !important;
          }

          select {
            width: 100%;
          }
        }

        .nivell-1 {
          margin-left: 0;
        }

        .nivell-2 {
          margin-left: 15px;

          &::before {
            content: "";
            position: absolute;
            left: -10px;
            top: 20px;
            height: 1px;
            width: 10px;
            background-color: #ddd;
          }
        }

        .nivell-3 {
          margin-left: 30px;

          &::before {
            content: "";
            position: absolute;
            left: -10px;
            top: 20px;
            height: 1px;
            width: 10px;
            background-color: #ddd;
          }

          &::after {
            content: "";
            position: absolute;
            left: -25px;
            top: -15px;
            height: calc(100% + 15px);
            width: 1px;
            background-color: #ddd;
          }
        }

        .nivell-4 {
          margin-left: 45px;

          &::before {
            content: "";
            position: absolute;
            left: -10px;
            top: 20px;
            height: 1px;
            width: 10px;
            background-color: #ddd;
          }

          &::after {
            content: "";
            position: absolute;
            left: -40px;
            top: -15px;
            height: calc(100% + 15px);
            width: 1px;
            background-color: #ddd;
          }
        }

        .nivell-5 {
          margin-left: 50px;

          &::before {
            content: "";
            position: absolute;
            left: -10px;
            top: 20px;
            height: 1px;
            width: 10px;
            background-color: #ddd;
          }

          &::after {
            content: "";
            position: absolute;
            left: -45px;
            top: -15px;
            height: calc(100% + 15px);
            width: 1px;
            background-color: #ddd;
          }
        }
      }
    }

    .submenu-container.visible {
      display: block;
    }

    .select-sin-movimiento {
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
      /* transform: translateZ(0);  */
    }

    .select-sin-movimiento:focus {
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
    }

    /* Prevenir saltos en iOS */
    @supports (-webkit-overflow-scrolling: touch) {
      .select-sin-movimiento {
        transform: translateZ(0);
      }
    }

  }

  select:focus {
    scroll-margin-top: 0px !important;
    scroll-behavior: auto !important;
    outline: none;
    /* nomÃ©s si visualment vols evitar el ressaltat */
  }

  /* Estilo uniforme para select e input list */
  select.select-sin-movimiento,
  input[list].select-sin-movimiento {
    width: 100%;
    font-size: 0.95rem;
    background-color: transparent;
    border: 1px solid #ccc;
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    appearance: none;
    -webkit-appearance: none;
    transition: border 0.2s ease, box-shadow 0.2s ease;
    border-radius: 10px;

    &:hover,
    :focus {
      border-color: #b40e0e;
      box-shadow: 0 0 0 2px rgba(191, 0, 0, 0.1);
      outline: none;
    }
  }

}

.ocultar-moduls {
  display: none !important;
}

.asterisc-obligatori {
  color: #c0392b;
  /* rojo discreto */
  margin-left: 0.25rem;
  font-weight: bold;
}


/* scroll */
.globus-de-preguntes.sidebar-faq.fixat-despres-scroll {
  position: sticky;
  top: calc(60px + 10px);
  z-index: 999;
  max-height: calc(100vh - 80px);
  overflow-y: visible;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease-in-out;
}

.sidebar-scroll-inner {
  max-height: inherit;
  overflow-y: auto;
  overflow-x: visible;
  position: relative;
  z-index: 1;
}

/* Contingut dret entre les dues columnes */
.contingut-dret.fixat-despres-scroll {
  left: 400px;
  right: 400px;
  width: calc(100% - 800px);
  /* Deja margen fijo para sidebars */
}

.globus-de-preguntes.sidebar-faq.scrolled,
.contingut-dret.scrolled {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  /* background-color: #f9fafb; */
  z-index: 999;
}

.contenidor-info.contenidor-fixat {
  /* position: sticky; */
  position: relative;
  top: 50px;
  z-index: 900;
  background-color: #fff;
}

.tooltip-icon {
  cursor: pointer;
  font-size: 0.9em;
  margin-left: 6px;
  position: relative;
  display: inline-block;
}

.tooltip-icon::after {
  content: attr(aria-label);
  position: absolute;
  bottom: 100%;
  right: 0;
  top: -25px;
  transform: translateY(-10px);
  background-color: #f0f0f0;
  color: #333;
  padding: 6px 8px;
  border-radius: 4px;
  white-space: pre-line;
  font-size: 0.75em;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  width: 260px;
  text-align: left;
  z-index: 50000;
  padding: 5px 5px 30px 5px;  
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.tooltip-icon:hover::after {
  opacity: 1;
}

.tooltip-icon::after {
  z-index: 9999 !important;
}

/* scroll FI*/
.menuEntorn {
  position: relative;
  top: 0;
  z-index: 4000;
  background-color: #fff;
}

/* Contenedor principal */
.contenidor-info {
  margin-bottom: 20px;
  position: relative !important;
  top: 40px;
  display: flex;
  z-index: 900;
  flex: 1 0 auto;
  flex-direction: row;
  margin: 0 auto;
  max-width: 1500px;
  justify-content: center;
  align-items: flex-start;
  align-content: flex-start;
  /* padding: 140px 40px 40px; */
  gap: 20px;

  /* overflow: visible !important;
  max-height: none !important; */
  .globus-de-preguntes.globus-central {
    top: 20px;
    width: 320px;
    min-width: 260px;
    max-width: 320px;
    padding: 20px;
    margin-left: 50px;
    background-color: #f5f5f5;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    font-size: 14px;
    color: #333;
    height: fit-content;
    align-self: flex-start;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
  }

  /* Contenido derecho */
  .contingut-dret {
    position: sticky;
    height: auto;
    max-height: 70vh;
    min-height: 400px;
    width: 50vw;
    max-width: 1500px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow-y: auto;
    overflow-x: auto;
    top: 70px;
    right: 0;
    bottom: 0;
    z-index: 999;
    /*scroll-behavior: auto !important;*/
    contain: none;
    /*overscroll-behavior: none;*/
    display: flex;
    flex-direction: column;
    margin-top: 20px;
    box-sizing: border-box;
    gap: 10px;
    padding: 20px;
    background-color: #f9fafb;
    overflow-anchor: none;
    margin-bottom: 60px;

    .globus-conversa.resposta.activa {
      display: block !important;
      visibility: visible !important;
      opacity: 1 !important;
      max-height: unset !important;
    }

    /* scroll-behavior: smooth; */
    .globus-conversa.resposta {
      scroll-margin-top: 200px;
      display: none;
      padding: 40px;

      /* margin-bottom: 180px !important; */
      .bloc-resultats,
      details {
        display: flex;
        flex-direction: column;
        gap: 5px;
        padding: 10px;

        h3 {
          margin-top: 15px;
          font-size: 1rem;
          font-weight: 600;
          color: #222;
          line-height: 2;
        }

        p {
          margin: 0;
          padding-left: 10px;
          line-height: 1.55;
          text-align: justify;
        }
      }
    }

    .detall-variants-instruments summary {
      cursor: pointer;
      font-weight: 600;
      display: block;
      margin-top: 0.5rem;
      margin-bottom: 0.25rem;
      margin-left: 12px;
    }

    .llista-variants-instruments {
      margin: 0.5rem 0 0 1rem;
      padding-left: 1rem;
    }

    .xat-missatge {
      /* display: flex; */
      /* flex-direction: column; */
      gap: 1rem;
      display: block;

    }

    .estat-buit {
      text-align: center;
      color: #666;
      padding: 2rem;
      font-style: italic;
    }


    .xat-missatge.ocult {
      display: none !important;
    }


    .contingut-dret .globus-conversa.pregunta[style*="display: block"],
    .contingut-dret .globus-conversa.resposta[style*="display: block"] {
      display: block !important;
    }


    /* InformaciÃ³n de curso y mÃ³dulo */
    .globus-conversa.resposta#curso-info,
    .globus-conversa.resposta#modulo-info {
      display: flex;
      flex-direction: column;
      gap: 5px;
      padding: 15px;

      h3 {
        font-size: 1rem;
        font-weight: 600;
        color: #222;
        line-height: 1.4;

        &:first-child {
          margin-top: 0;
        }
      }

      p {
        margin: 0;
        line-height: 1.55;
        text-align: justify;
      }

      p+h3 {
        margin-top: 1rem;
      }

      a {
        color: #b20e0e;
        text-decoration: underline;

        &:hover {
          text-decoration: none;
        }
      }
    }

    .bloc-seccio-avaluacio {
      margin-bottom: 1.5rem;
      padding: 1rem;
      background: #fff;
      border-left: 1px solid #c00;

      h2 {
        margin-bottom: 0.75rem;
        font-size: 1.2rem;
        color: #c00;
      }

      h3 {
        font-size: 1.1rem;
        font-weight: 600;
        margin-top: 1.2em;
        margin-bottom: 0.5em;
        color: #333;
        padding-left: 0;
      }

      p {
        margin-left: 1rem;
        text-indent: 1rem;
      }

      ol {
        padding-left: 1.5rem;
        margin-top: 0.5rem;
      }

      li {
        margin-bottom: 0.75rem;
        line-height: 1.5;
      }

    }
  }

  /* Selects */
  #moduls,
  #moduls2,
  #nom-curs,
  #nom-curs2,
  #area-professional2,
  #area-professional,
  #familia-professional2,
  #familia-professional,
  #programa2,
  #select-avaluacio,
  #select-fonaments,
  #modalitat,
  .select-avaluacio,
  .select-fonaments,
  .programa2,
  .familia-professional2,
  .area-professional2 {
    width: 250px;
    padding: 10px 30px 10px 10px;
    font-size: 0.95rem;
    cursor: pointer;
    position: relative;
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
  }

  /* Globus conversaciÃ³n */
  .globus-conversa {
    max-width: 90%;
    padding: 16px 20px;
    margin-bottom: 16px;
    border-radius: 12px;
    position: relative;
    font-size: 1rem;
    line-height: 1.6;
    word-break: break-word;
    word-wrap: break-word;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: none;
    position: relative;
    background-color: #fff;
    color: #212529;


    &.pregunta {
      position: relative;
      margin-left: auto;
      background-color: #f7efef;
      border-radius: 8px 0 8px 8px;
      border: 1px solid #ccc;
      margin-top: 10px;
    }

    &.resposta {
      position: relative;
      margin-right: auto;
      background: #fff;
      border-radius: 0 8px 8px 8px;
      border: 1px solid #ccc;

      &::before {
        content: "";
        position: absolute;
        top: 12px;
        left: -11px;
        border-width: 10px 10px 10px 0;
        border-style: solid;
        border-color: transparent #ccc transparent transparent;
        z-index: 1;
      }

      &::after {
        content: "";
        position: absolute;
        top: 13px;
        left: -9px;
        border-width: 9px 9px 9px 0;
        border-style: solid;
        border-color: transparent #fff transparent transparent;
        z-index: 2;
      }
    }
  }

  /* TÃ­tulos de subapartados */
  .titol-subapartat {
    font-size: 1.5em;
    margin-top: 20px;
    margin-bottom: 10px;
    color: #c00;
    border-bottom: 2px solid #c00;
    padding-bottom: 5px;
  }

  .bloc-subapartat {
    margin-bottom: 20px;
  }

  /* Nuevo estilo para el botÃ³n (combinando funcionalidad con el estilo deseado) --- Modificat, afegit left per amagra-lo a la dreta de la pantalla---*/
  .boto-exportar-pdf {
    background: #c00;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    width: 65%;
    max-width: 260px;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 20px;
    font-size: 12px;
    color: blanchedalmond;
    text-align: center;
    position: relative;
    left: 48%;
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease, transform 0.2s ease;
    clip-path: polygon(20px 0, 100% 0, 100% 100%, 20px 100%, 0 50%);

    a {
      text-decoration: none;
      color: blanchedalmond;
    }

    &:hover {
      background-color: #a00 !important;
      transform: translateY(-15%) translateX(-70%);
      /* Modificat -- afegit translateX, per que aparegui des de la dreta de l a pantalla en passar per sobre*/
      color: blanchedalmond !important;
    }

    /*&:active {
          transform: translateY(-5%) scale(0.98);
      }*/
  }

  /* --- Modificat, afegit left per amagra-lo a la dreta de la pantalla---*/
  .neteja-xat,
  .imprimir,
  .descarregar {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    width: 65%;
    max-width: 260px;
    justify-content: space-between;
    font-size: 12px;
    /* font-weight: bold; */
    background-color: #c00;
    color: blanchedalmond;
    align-items: center;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    text-align: center;
    position: relative;
    left: 48%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease, transform 0.2s ease;
    clip-path: polygon(20px 0, 100% 0, 100% 100%, 20px 100%, 0 50%);

    .visible {
      display: inline-block;
    }

    &:hover {
      background-color: #a00;
      transform: translateY(-15%) translateX(-70%);
      /* Modificat -- afegit translateX, per que aparegui des de la dreta de l a pantalla en passar per sobre*/
    }

    /*&:active {
      transform: translateY(-50%) scale(0.98);
    }*/
    .estatic {
      position: static;
      transform: none;
      top: auto;
      right: auto;
      clip-path: none;
      margin: 5px 10px;
    }

    .ocultar {
      display: none !important;
    }
  }

  .boto-exportar-pdf .text,
  .neteja-xat .text,
  .imprimir .text,
  .descarregar .text {
    flex: 1;
    text-align: center;
  }

  .neteja-xat .icon,
  .imprimir .icon,
  .descarregar .icon,
  .boto-exportar-pdf .icon {
    width: 18px;
    height: 18px;
    filter: invert(1);
    flex-shrink: 0;
  }


  .botons-xat {
    position: fixed;
    bottom: 50px;
    right: 10px;
    margin-bottom: 100px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: left;
    gap: 12px;
    z-index: 9999;
    pointer-events: auto;

    .ocultar {
      display: none !important;
    }

  }

  /* Autocompletat amb ombra visual */
  .envoltori-autocompletar {
    position: relative;
    width: 100%;

    /* margin-bottom: 20px; */
    label {
      display: block;
      margin-bottom: 6px;
      font-weight: 500;
    }

    .camp-autocompletar {
      position: relative;
      width: 100%;
    }

    .input-usuari {
      position: relative;
      background: transparent;
      z-index: 2;
      will-change: contents;
    }

    .missatge-no-resultats {
      position: absolute;
      bottom: 50px;
      right: 12px;
      color: #c00;
      display: none;
      pointer-events: none;
      z-index: 3;
      font-size: 12px;
      transition: opacity 0.2s ease;
    }

    input[list]::-webkit-calendar-picker-indicator {
      display: none !important;
    }

    input[list] {
      position: relative;
      z-index: 1;
    }
  }
}

/* --- ICONA FILTRE MODULS --- */
.camp-autocompletar--moduls-filtrats {
  position: relative;

  .input-usuari {
    padding-right: 2.5rem;
  }

  .icona-filtre-moduls {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    z-index: 3;

    svg {
      width: 100%;
      height: 100%;
      fill: currentColor;
    }
  }
}

.missatge-sense-moduls {
  font-size: 0.85rem;
  margin-top: 4px;
  color: #b3261e;
}

.globus-conversa.resposta.collapsada .contingut-colapsable {
  max-height: 350px;
  overflow: hidden;
  position: relative;
}


/* Gradiente al final del texto */
.globus-conversa.resposta.collapsada .contingut-colapsable::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  height: 40px;
  width: 100%;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff);
  pointer-events: none;
}

/* BotÃ³n debajo del contenido colapsado */
.globus-conversa.resposta .mostrar-mes-btn {
  display: block;
  margin-top: 8px;
  text-align: center;
  margin: 0 auto;
  background: none;
  border: none;
  color: #c00;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.9rem;
  z-index: 2;
  background-color: #fff;
  padding: 2px 6px;
  align-self: center;
}

.boto-toggle-sidebar {
  display: none;
  position: fixed;
  top: 280px;
  left: 20px;
  z-index: 10000;
  background-color: #c00;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

table {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}


/* =======================
   RESPONSIVE DESIGN
   ======================= */

/*nomès s'aplica si girem el telèfon -- amaga la secció breadcrumbs i fa el header estatic per alliberar espai i que es vegi el contingut -- */
@media (orientation: landscape) and (max-height: 500px) {
  header {
	position: static !important;
    padding: 0.3rem 0.1rem; /* Reduïm espais */
	font-size: 1.2rem; /* Fem la lletra més petita */
    margin: 0;
	}  
	
  .ruta-navegacio, .ruta-navegacio-container {
    display: none; /* Sovint, les molles de pa es poden ocultar en landscape per guanyar espai */
  }  
}

/*Maquetació per a tauletes, tipus iPad*/
@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 1300px) and (min-height: 500px) {
    #header_guia, #ruta-navegacio_guia {
      position: fixed !important;    
    }
      
      footer {
      position: static !important;
       margin-top: -100dvh !important;
      }      
    
     #contenidor {
         top: 15dvh !important;
      }   
  }

/* Només s'aplica a pantalles petites (mòbils)  per a maquetació de les taules a les recomanacions */
@media screen and (max-width: 600px) {
   
    /* --- MISSATGE EN CATALÀ (quan l'HTML té lang="ca") --- */
    html[lang="ca"] .taula-gma::before {
        content: "🔍 Toca la taula per ampliar i desplaçar-te";
    }
    html[lang="ca"] .taula-gma.es-expandida::before {
        content: "❌ Toca per tancar";
    }

    /* --- MISSATGE EN CASTELLÀ (quan l'HTML té lang="es") --- */
    html[lang="es"] .taula-gma::before {
        content: "🔍 Toca la tabla para ampliar y desplazarte";
    }
    html[lang="es"] .taula-gma.es-expandida::before {
        content: "❌ Toca para cerrar";
    }

    /* --- ESTILS COMUNS taules --- */
    .taula-gma::before {
        display: block !important;
        margin-left: -8dvw !important;
        font-size: 13px;
        font-weight: bold;
        color: #000000;
        padding: 10px;
        margin-bottom: 12px;
        white-space: nowrap !important;
        width: 74dvw!important;
    }

    .taula-gma.es-expandida::before {
        color: #000000;
        position: sticky;
        top: 0;
        z-index: 1000001;
        white-space: normal !important;
		width: 40dvw !important;
    }

	
    /* --- ESTAT NORMAL --- */
    .taula-gma {
        display: table !important;
        width: 100% !important;
        table-layout: fixed !important;
        touch-action: manipulation; /* Millora la resposta al toc */
    }

    .taula-gma td, .taula-gma th {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        font-size: 10px !important;
        height: 35px !important;
        border: 1px solid #ccc !important;
    }

    /* --- ESTAT EXPANDIT (MODAL) --- */
   .taula-gma.es-expandida {
    /* ... manté el que hi ha (fixed, top, left, z-index) ... */

    /* Forçem que la taula es comporti com un element amb scroll propi */
    display: block !important;
    overflow-y: scroll !important; 
    overflow-x: auto !important;
    
    /* 2. EVITEM QUE EL NAVEGADOR BLOQUEGI EL GEST */
    touch-action: pan-x pan-y !important; /* Diu al mòbil: deixa moure en X i en Y */
    pointer-events: all !important;      /* Assegura que els tocs arribin a la taula */

    /* 3. MIDA FIXA DE LA "FINESTRA" (Sense això l'scroll vertical no existeix) */
    height: 80vh !important; /* Si la taula és més alta que el 80% de la pantalla, farà scroll */
}

/* 4. ASSEGUREM QUE EL CONTINGUT INTERN ÉS EL QUE "ESTIRA" LA TAULA */
.taula-gma.es-expandida tbody {
    display: block !important;
    width: 1000px !important; /* Amplada pel zoom horitzontal */
    height: auto !important;  /* Alçada lliure perquè l'scroll vertical tingui sentit */
}

    .taula-gma.es-expandida td, 
    .taula-gma.es-expandida th {
        display: table-cell !important;
        white-space: normal !important;
        font-size: 16px !important;
        padding: 12px !important;
        min-width: 150px !important;
        border: 1px solid #000 !important;
        color: #000 !important;
    }
}

/****** Només s'aplica a pantalles petites (mòbils) *****/
@media screen and (max-width: 600px) {
    
      .taula-gma {
        display: block;
        width: 100% !important;/*Forcem que la taula s'ajusti a l'amplada del contenidor */
        border: none;
    }

    /* Amaguem el capçal per no crear confusió visual en l'apilament */
    .taula-gma thead {
        display: none;
    }    
    
}

/* ========== 1. Muy pequeÃ±as pantallas: hasta 425px (mÃ³vil pequeÃ±o) ========== */
@media screen and (max-width: 580px) {

  body {


    .botons-xat {
      position: fixed;
      bottom: 50px;
      right: 10px;
      margin-bottom: 150px !important;
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 12px;
      z-index: 9999;
      pointer-events: auto;
    }
	  .bloc-resultats {
	  width: 80dvw !important;
	  margin-left: -30px !important;
	  }
	  
	  .contenidor-info {
	  margin-bottom: 50px;
	  }

	  .tooltip-icon {
	  padding: 10px;
	  }
  }
}


@media screen and (max-width: 450px) {

  body {
    max-width: 100dvw !important: overflow: hidden !important;
  }

  .globus-de-preguntes.sidebar-faq[data-posicio="esquerra"],
  .globus-de-preguntes.sidebar-faq[data-posicio="dreta"] {
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto 20px auto !important;
    padding: 0 10px !important;
    position: relative !important;
    top: auto !important;
    z-index: 1 !important;
  }

  .contenidor-info {
    position: absolute !important;
    top: 0 !important;
  }

  .globus-de-preguntes.sidebar-faq .sidebar-section {
    width: 100% !important;
    padding: 15px !important;
  }

  .submenu-faq a,
  .sub-submenu a {
    font-size: 0.85rem;
  }

  .contingut-dret {
    position: absolute !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 10px !important;
    max-height: none !important;
    overflow-y: auto !important;
    margin-bottom: 120px;
  }

  #xat-missatge {
    margin-bottom: 10dvh !important;
  }

  #pregunta-finalitat {
    margin-bottom: 20px !important;
  }

  .globus-conversa {
    font-size: 0.9rem !important;
    /* padding: 16px !important; */
    margin-bottom: 30dvh !important;
    margin-top: 5dvh !important;
  }

  .pregunta {
    margin-bottom: 8dvh !important;
  }

  .resposta {
    margin-top: -5dvh !important;
    margin-bottom: 5dvh !important;
    padding-left: 50px !important;
  }

  .globus-conversa.resposta::before,
  .globus-conversa.resposta::after {
    display: none !important;
  }

  .boto-exportar-pdf {
    width: 50% !important;
    padding: 12px !important;
    font-size: 12px;
    justify-content: center;
    left: 4% !important;
  }


  .botons-xat {
    position: fixed;
    /* bottom: 100px !important; */
    right: 10px;
    margin-bottom: 100px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    z-index: 9999;
    pointer-events: auto;
    width: 80px;
  }

  .neteja-xat,
  .imprimir,
  .descarregar {
    width: 44px !important;
    height: 44px !important;
    padding: 0 0 0 15px !important;
    left: 2% !important;
    bottom: 20% !important;
    font-size: 0 !important;
    /* Oculta el texto */
    border-radius: 6px !important;
    /* Forma rectangular con bordes suaves */
    /*clip-path: none !important;       Elimina forma de flecha */
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    position: relative;
    overflow: hidden !important;
    clip-path: polygon(20px 0, 100% 0, 100% 100%, 20px 100%, 0 50%) !important;
  }

  .neteja-xat .icon,
  .imprimir .icon,
  .descarregar .icon {
    width: 20px;
    height: 20px;
    filter: invert(1);
    display: block;
    margin-left: 5px;
  }

  /* Tooltip estilitzat */
  .neteja-xat::after,
  .imprimir::after,
  .descarregar::after {
    content: attr(title);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 10000;
  }
	
  .neteja-xat:hover::after,
  .imprimir:hover::after,
  .descarregar:hover::after {
    opacity: 1;
  }

  input,
  select {
    width: 100% !important;
    font-size: 1rem !important;
    padding: 10px !important;
  }

  .envoltori-autocompletar {
    width: 100% !important;
  }

  .camp-autocompletar {
    padding: 0 !important;
  }

	

.tileft::after {
 transform: translateX(10px);
  z-index: 50000;
  width: 150px;	
  height: 30px;
}

.tiright::after {
  transform: translateX(-20px);
  z-index: 50000;
  width: 150px;	
  height: 30px;
}
  /* MenÃº hamburguesa */
  #menu-hamburguesa {
    width: 32px;
    height: 32px;
    top: 10px;
    left: 10px;
  }

  .menu-desplegable {
    top: 50px !important;
    width: 100vw;
    font-size: 14px;
  }

  .estat-buit {
    font-size: 0.95rem;
    padding: 1.5rem;
  }

  footer {

    position: absolute !important;
    width: 100dvw !important;

    nav:first-of-type {
      flex-direction: column;
      text-align: center;
      padding: 10px;
    }

    #logos-XXSS {
      justify-content: center;
      gap: 10px;
      flex-wrap: wrap;
      max-width: 300px;
      margin: 0 auto !important;
      /* margin: 0 0 0 30px !important; */
    }

    nav:nth-of-type(2) {
      .logoPeuGeneral img {
        width: 90px;
        margin: 10px auto;
      }

      .enllacos-peu a {
        font-size: 10px;
      }

      .icona-enllac {
        width: 10px;
        height: 10px;
      }
    }
  }

  /* Estils Peu */
  .footer-guia {
    width: 100%;
    ;
    margin-top: auto;
    margin: 0;
    padding: 0;
    position: absolute;
    left: 0px;
    bottom: 0px;
    z-index: 9999;
    font-family: Arial, sans-serif;

  }

  body:not(.scrolled) .contenidor-info,
  body:not(.scrolled) #contenidor,
  body:not(.scrolled) .contingut-dret,
  body:not(.scrolled) .globus-de-preguntes.sidebar-faq {
    /* margin-top: 80px !important; */
    transition: margin-top 0.25s ease-in-out;
  }
}

/* ========== 2. MÃ³viles medianos-grandes: hasta 768px ========== */
@media screen and (max-width: 768px) {

  body {
    flex-direction: column;

    .enllacos-superiors {
      >*:not(:last-child) {
        opacity: 0;
        visibility: hidden;
        height: 0;
        overflow: hidden;
        transition: opacity 0.4s, height 0.4s, visibility 0.4s;
      }

      > :last-child {
        opacity: 1;
        visibility: visible;
        height: 16px;
      }

      .cerca-icon {
        width: 22px;
        height: 22px;
      }
    }

    /* === CONTENEDOR PRINCIPAL === */
    .contenidor-info {
      position: absolute !important;
      top: 0 !important;
    }

    /* === ASIDE ESQUERRA === */
    .globus-de-preguntes.sidebar-faq[data-posicio="esquerra"] {
      display: grid !important;
      grid-template-columns: repeat(2, 1fr) !important;
      gap: 20px !important;
      /*margin-top: 0 !important;*/
      margin-bottom: 10px !important;
      position: relative !important;
      top: auto !important;
      z-index: 1 !important;
    }

    /* === ASIDE DRETA === */
    .globus-de-preguntes.sidebar-faq[data-posicio="dreta"] {
      display: grid !important;
      grid-template-columns: 1fr !important;
      gap: 20px !important;
      margin-top: 10px !important;
      margin-bottom: 20px !important;
      position: relative !important;
      top: auto !important;
      z-index: 1 !important;
    }

    .globus-de-preguntes.sidebar-faq .sidebar-section {
      width: 100% !important;	 
    }
	
	  .dreta-responive {
	  margin-left: -3.5dvw;
	  }

    /* === CONTINGUT PRINCIPAL CON SCROLL === */
    .contingut-dret {
      /* position: relative !important; */
      position: sticky;
      /* top: auto !important; */
      width: 100% !important;
      max-width: 800px !important;
      margin: 0 auto !important;
      padding: 20px !important;
      overflow-y: auto !important;
      max-height: 65vh !important;
      z-index: 1 !important;
    }

    /* .globus-de-preguntes.sidebar-faq.fixat-despres-scroll,
    .contingut-dret.fixat-despres-scroll {
      position: relative !important;
      top: auto !important;
      max-height: none !important;
      overflow: visible !important;
    } */
    .botons-xat {
      position: fixed;
      bottom: 24px;
      right: 10px;
      margin-bottom: 100px;
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 12px;
      z-index: 9999;
      pointer-events: auto;
    }

    /* === FOOTER (PEU DE PÃ€GINA) === */

    footer {
      nav:first-of-type {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 10px;
        padding: 10px;
      }

      #logos-XXSS {
        display: flex;
        justify-content: center;
        align-items: center;
        flex-wrap: wrap;
        gap: 10px;
        margin: 0 auto;
        width: 100%;
        max-width: 300px;
      }

      nav:nth-of-type(2) {
        .logoPeuGeneral img {
          width: 100px;
          margin-top: 10px;
        }

        .enllacos-peu {
          margin: 0 auto;
          margin-top: 5px;

          a {
            font-size: 10px;
          }

          .icona-enllac {
            width: 10px;
            height: 10px;
          }
        }
      }

      .logoPeuGeneral {
        order: 1;
        margin: 0 auto;

        img {
          margin-top: 0;
        }
      }
    }

    /* === BARRA SUPERIOR - ENLLAÃ‡OS === */
    .enllacos-superiors {

      .cerca-icon {
        width: 22px;
        height: 22px;
      }

      >*:not(:last-child) {
        opacity: 0;
        visibility: hidden;
        height: 0;
        overflow: hidden;
        transition:
          opacity 0.4s ease-in-out,
          height 0.4s ease-in-out,
          visibility 0.4s ease-in-out;
      }

      > :last-child {
        opacity: 1;
        visibility: visible;
        height: 16px;
        overflow: visible;
      }
    }
  }
}

/* ========== 3. MÃ³viles medianos-grandes: hasta 948px ========== */
@media screen and (max-width: 940px) {
  body {
    header {
      flex-direction: column;

      .menuEntorn {
        position: relative;

        #menu-hamburguesa {
          display: flex;
          flex-direction: column;
          justify-content: center;
          gap: 5px;
          width: 35px;
          height: 35px;
          position: absolute;
          top: 8px;
          left: 10px;
          z-index: 1100;
          background: transparent;
          border: none;
          cursor: pointer;

          span {
            width: 100%;
            height: 2px;
            background: white;
            border-radius: 2px;
            transition: transform 0.3s ease, opacity 0.3s ease;
          }

          &.open {
            span:nth-child(1) {
              transform: translateY(7.5px) rotate(45deg);
            }

            span:nth-child(2) {
              opacity: 0;
            }

            span:nth-child(3) {
              transform: translateY(-7.5px) rotate(-45deg);
            }
          }
        }

        #logo_cerca {
          position: absolute;
          top: -40px;
          right: 10px;
          width: 25px;
          height: 25px;
          filter: invert(1);
          z-index: 1100;
          cursor: pointer;
        }

        .menu-desplegable {
          position: absolute;
          top: 70px;
          right: 0;
          background: white;
          width: 100%;
          padding: 10px 20px;
          z-index: 3000 !important;
          line-height: 1.6;


          ul {
            list-style: none;
            margin: 0;
            padding: 0;

            li {
              margin: 10px 0;
              position: relative;

              &.paginaActual::after {
                content: "";
                position: absolute;
                top: 0;
                left: 0;
                height: 80%;
                width: 4px;
                background-color: rgba(180, 14, 14, 0.6);
              }

              a {
                margin-left: 18px;
                color: #222;
                text-decoration: none;
                font-size: 16px;
              }
            }
          }

          &.active {
            display: flex;
          }
        }
      }

      > :first-child {
        position: sticky;
        flex-direction: column;
        top: 0;
        z-index: 1000;
        justify-content: center;
        align-items: center;
        gap: 10px;
        padding: 10px 20px;
        height: 45px;

        > :first-child {
          margin-left: 0;
          display: flex;
          justify-content: center;
          width: 100%;
          margin-top: 35px;

          #logo_gencat {
            height: 25px;
          }
        }

        > :nth-child(2) {
          display: none;
        }

        > :nth-child(3) {
          margin-left: 0;
          margin-right: 0;
          justify-content: flex-end;
          width: 100%;
          padding: 0 10px;
          display: flex !important;

          /* Ocultar tot excepte la cerca */
          a:not(:has(#logo_cerca)),
          span,
          #idiomes-contenidor {
            display: none !important;
          }

          a:has(#logo_cerca) {
            display: flex !important;
            align-items: center;
            justify-content: center;
            padding: 5px;
          }
        }
      }

      /* Segona franja centrada */
      > :nth-child(2) {
        position: sticky;
        top: 45px;
        z-index: 999;
        justify-content: center;
        align-items: center;
        padding: 15px 20px;
        height: 35px;
        text-align: center;

        a {
          margin-left: 0;
          font-size: 14px;
          text-align: center;
          color: white;
          text-decoration: none;
          line-height: 1.4;
        }

        #titol-sitio {
          display: inline-block;
          text-align: center;
        }
      }

      > :nth-child(3) {
        background-color: #222;
        color: #222;
        height: 20px;

        ul,
        li,
        a {
          display: none;
        }
      }
    }
	
	
    .ruta-navegacio-container {
      top: 80px !important;
      z-index: 2000;
    }

    &.scrolled {		 
      #titol-sitio {
        display: none !important;
      }

      header> :first-child> :nth-child(2) {
        display: none !important;
      }

      header> :first-child> :nth-child(2)::before {
        content: none !important;
      }
    }

    /* ASIDE ESQUERRA EN FLUJO */
    .globus-de-preguntes.sidebar-faq[data-posicio="esquerra"] {
      position: relative !important;
      top: auto !important;
      z-index: 1 !important;
      /*margin-top: 0 !important;*/
      grid-template-columns: repeat(2, 1fr) !important;
      gap: 20px !important;
    }

    /* ASIDE DRETA TAMBIÃ‰N EN FLUJO */
    .globus-de-preguntes.sidebar-faq[data-posicio="dreta"] {
      position: relative !important;
      top: auto !important;
      grid-template-columns: 1fr !important;
      margin-top: 30px !important;
      margin-bottom: 50px !important;
      gap: 20px !important;
    }

    /* CONTINGUT-DRET CON SCROLL INTERNO */
    .contingut-dret {
      /* position: relative !important; */
      position: sticky;
      top: auto !important;
      width: 100% !important;
      max-width: 800px !important;
      margin: 0 auto !important;
      padding: 20px !important;
      overflow-y: auto !important;
      max-height: 65vh !important;
      z-index: 1 !important;
      margin-bottom: 20px;
    }

    /* .contenidor-info {
      margin-top: 0 !important;
      padding: 0 15px !important;
      gap: 20px !important;
    } */
    .contenidor-info {
      position: absolute !important;
      top: 0 !important;
    }

    .globus-de-preguntes.sidebar-faq.fixat-despres-scroll,
    .contingut-dret.fixat-despres-scroll {
      /* position: relative !important; */
      top: auto !important;
      max-height: none !important;
      overflow: visible !important;
    }
  }
}

/* ========== 4. Tablets en vertical / pantallas medias: hasta 1024px ========== */
@media screen and (max-width: 1024px) {
  /* .contenidor-info {
    margin-top: 0 !important;
    gap: 25px;
  } */

  .contenidor-info {
    position: absolute !important;
    top: 0 !important;
  }

  /* .globus-de-preguntes.sidebar-faq[data-posicio="esquerra"] {
    grid-template-columns: repeat(2, 1fr) !important;
    position: relative !important;
    top: auto !important;
    z-index: 1 !important;
    margin-top: 600px !important;
    margin-top: 0 !important;
  } */
  .globus-de-preguntes.sidebar-faq.fixat-despres-scroll {
    position: relative !important;
    top: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  /* .globus-de-preguntes.sidebar-faq[data-posicio="dreta"] {
    grid-template-columns: repeat(2, 1fr) !important;
  } */

  .globus-de-preguntes.sidebar-faq[data-posicio="esquerra"],
  .globus-de-preguntes.sidebar-faq[data-posicio="dreta"] {
    grid-template-columns: repeat(2, minmax(120px, 1fr)) !important;
    width: 90% !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }


  .contingut-dret {
    max-height: 70vh !important;
    overflow-y: auto !important;
  }
}

/* ========== 5. Escritorio pequeÃ±o o tablet horizontal: hasta 1300px ========== */
@media (max-width: 1300px) {
  body {
    header {
      > :first-child {
        > :first-child {
          margin-left: 0;
        }

        > :nth-child(3) {
          margin-right: 0;
        }
      }

      > :nth-child(2) {
        a {
          margin-left: 0;
        }
      }

      .menuEntorn {
        position: sticky;
        z-index: 1001;
      }

      .globus-de-preguntes.sidebar-faq {
        z-index: 10;
      }

      .contingut-dret {
        z-index: 5;
        /* position: relative !important; */
        margin-bottom: 100px !important;
      }

      .enllacos-superiors {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        padding-right: 40px;
        gap: 12px;
        position: relative;
        z-index: 999;
      }
    }

    .ruta-navegacio-container {
      position: sticky;
      top: 150px;
      z-index: 2000;
    }

    .contenidor-info {
      display: grid !important;
      grid-template-columns: 1fr;
      grid-template-areas:
        "aside"
        "boton"
        "contingut";
      gap: 20px;
      /*margin-top: 140px !important;
      position: relative !important;*/
      z-index: 1;
      width: 90% !important;
      max-width: 100% !important;
      position: absolute !important;
      top: 0 !important;
      margin-left: 20px;
      margin-right: 10px;
    }

    .globus-de-preguntes.sidebar-faq {
      all: unset;
      display: grid !important;
      width: 100% !important;
      gap: 20px !important;
      position: relative !important;
      /*margin-top: 400px;*/
      top: auto !important;
    }

    .globus-de-preguntes.sidebar-faq[data-posicio="esquerra"] {
      display: grid !important;
      grid-area: aside !important;
      grid-template-columns: repeat(2, 1fr) !important;
      margin-right: 20px !important;
      /*margin-top: 400px !important;*/
      scroll-behavior: auto !important;
      overflow: visible !important;
      position: relative !important;
      top: auto !important;
      max-height: none !important;
      z-index: 1 !important;
      width: 90% !important;
      margin: 700px auto 50px auto !important;
      gap: 20px !important;
    }

    .globus-de-preguntes.sidebar-faq[data-posicio="dreta"] {
      display: grid !important;
      grid-template-columns: repeat(2, 1fr) !important;
      margin-right: 20px !important;
      margin-top: 80px !important;
      /* margin-bottom: 20px !important; */
      width: 90% !important;
      margin: 0 auto !important;
      gap: 20px !important;
    }
	  
	  /* Aquí estarà*/

    .globus-de-preguntes.sidebar-faq .sidebar-section {
      width: 100% !important;
      scroll-margin-top: 0 !important;
      scroll-padding-top: 0 !important;
    }

    .contingut-dret {
      grid-area: contingut !important;
      /* position: relative !important; */
      /* top: auto !important; */
      right: auto !important;
      bottom: auto !important;
      z-index: 1 !important;
      width: 100% !important;
      max-width: 800px !important;
      margin: 0 auto !important;
      padding: 20px !important;
      overflow-y: auto !important;
      max-height: 60vh !important;
      height: 10% !important;
    }

    .contingut-dret.fixat-despres-scroll,
    .globus-de-preguntes.sidebar-faq.fixat-despres-scroll {
      /* position: relative !important; */
      top: auto !important;
      max-height: none !important;
      overflow: visible !important;
    }

    .globus-de-preguntes.sidebar-faq[data-posicio="esquerra"],
    .sidebar-section,
    .submenu-container,
    .sub-submenu {
      scroll-margin-top: 0 !important;
      scroll-padding-top: 0 !important;
      /*scroll-behavior: auto !important;
      overscroll-behavior: contain !important;*/
      contain: layout !important;
      /* transform: translateZ(0); */
    }

    .globus-de-preguntes.sidebar-faq .sidebar-section,
    .globus-de-preguntes.sidebar-faq .submenu-container,
    .globus-de-preguntes.sidebar-faq .sub-submenu {
      scroll-margin-top: 180px;
      scroll-padding-top: 180px;
    }

    .globus-de-preguntes.sidebar-faq,
    .globus-de-preguntes.sidebar-faq[data-posicio="esquerra"],
    .globus-de-preguntes.sidebar-faq[data-posicio="dreta"],
    .globus-de-preguntes.sidebar-faq.fixat-despres-scroll {
      position: relative !important;
      top: auto !important;
      margin-top: 40px !important;
      margin-bottom: 40px !important;
      overflow: visible !important;
      max-height: none !important;
      z-index: auto !important;
      /* width: 100vw !important; */
    }

    .contenidor-info {
      overflow: visible !important;
    }

    .sidebar-section,
    .submenu-container,
    .sub-submenu {
      scroll-margin-top: 200px !important;
      scroll-padding-top: 200px !important;
    }

    .globus-de-preguntes.sidebar-faq {
      z-index: 20 !important;
    }

    .botons-xat {
      position: fixed;
      bottom: 24px;
      right: 10px;
      margin-bottom: 100px;
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 12px;
      z-index: 9999;
      pointer-events: auto;
    }

    #botons-xat button:hover {
      background-color: #a00;
    }


    footer {
      nav:first-of-type {
        p {
          /* margin-left: 10%; */
        }

        #logos-XXSS {
          /* margin-left: 5%; */
          margin: 0 auto !important;
        }
      }

      nav:nth-of-type(2) {
        .logoPeuGeneral img {
          margin-left: 0;
        }

        .enllacos-peu {
          margin-right: 0;

        }
      }
    }
  }
}

/* === FIX FINAL guiametodologica: alineación y comportamiento scroll === */

/* 1 Contenedor de información general: sin offsets fijos */
#contenidor-info,
.contenidor-info {
  /* margin-top: 0 !important; */
  padding-top: 0 !important;
  position: relative;
  top: 0 !important;
  /* elimina el desplazamiento visual extra */
}

/* 2 Contenedor derecho y área principal: sin margenes adicionales */
.contingut-dret {
  /* margin-top: 0 !important; */
  padding-top: 0 !important;
  overflow-y: auto;
}

/* 3 Los globus laterales: sin scroll inicial */
.globus-de-preguntes.sidebar-faq {
  overflow: hidden !important;
  /* no mostrar scroll al cargar */
  max-height: none !important;
  padding-top: 0 !important;
}

/* Cuando se despliegan (con clase expandit o <details open>), permitir scroll */
.globus-de-preguntes.sidebar-faq.expandit,
.globus-de-preguntes.sidebar-faq:has(details[open]) {
  overflow-y: auto !important;
  max-height: 80vh;
  /* límite razonable si el bloque crece */
}

/* 4 Alinea correctamente las columnas */
.contenidor-principal,
.contenidor-flex,
#contenidor {
  align-items: flex-start !important;
}

/* 5 Transiciones suaves cuando cambian los menús */
body:not(.scrolled) .contingut-dret,
body:not(.scrolled) .globus-de-preguntes.sidebar-faq {
  transition: padding-top 0.25s ease-in-out;
}

/* transición suave cuando se ajusta el margin-top / padding-top */
.contenidor-info,
#contenidor,
.contingut-dret,
.globus-de-preguntes.sidebar-faq {
  transition: margin-top 0.18s ease, padding-top 0.18s ease;
  box-sizing: border-box;
}

/* === Offset visual cuando los menús están visibles === */
body:not(.scrolled) .contenidor-info,
body:not(.scrolled) #contenidor,
body:not(.scrolled) .contingut-dret,
body:not(.scrolled) .globus-de-preguntes.sidebar-faq {
  /* Ajusta este valor según la altura real de tus menús */
  margin-top: 80px !important;
  transition: margin-top 0.25s ease-in-out;
}

/* Cuando se hace scroll (menús ocultos), eliminamos ese espacio */
body.scrolled .contenidor-info,
body.scrolled #contenidor,
body.scrolled .contingut-dret,
body.scrolled .globus-de-preguntes.sidebar-faq {
  margin-top: 10px !important;
}

/* === Scroll solo en el globo izquierdo (FAQ izquierda) === */

/* 1 Estado normal: sin scroll y debajo de los menús */
.globus-de-preguntes.sidebar-faq[data-posicio="esquerra"] {
  overflow: visible !important;
  max-height: none !important;
  margin-top: var(--menus-offset, 120px);
  transition: max-height 0.3s ease, overflow 0.3s ease, margin-top 0.3s ease;
}

/* 2 Cuando se expanden secciones (submenu abierto, details open, etc.) */
.globus-de-preguntes.sidebar-faq[data-posicio="esquerra"]:has(details[open]),
.globus-de-preguntes.sidebar-faq[data-posicio="esquerra"]:has(.submenu-container.visible),
.globus-de-preguntes.sidebar-faq[data-posicio="esquerra"]:has(.submenu-container.expanded),
.globus-de-preguntes.sidebar-faq[data-posicio="esquerra"]:has(.has-submenu.open) {
  overflow-y: auto !important;
  /* max-height: 80vh !important;  */
  scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
}

/* Scrollbar visual (WebKit) */
.globus-de-preguntes.sidebar-faq[data-posicio="esquerra"]::-webkit-scrollbar {
  width: 8px;
}

.globus-de-preguntes.sidebar-faq[data-posicio="esquerra"]::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
}

.globus-de-preguntes.sidebar-faq[data-posicio="esquerra"]::-webkit-scrollbar-track {
  background-color: transparent;
}

/* 3 Evita que quede tapado por los menús al estar arriba */
/* body:not(.scrolled) .globus-de-preguntes.sidebar-faq[data-posicio="esquerra"] {
  margin-top: var(--menus-offset, 160px) !important;
} */
body.scrolled .globus-de-preguntes.sidebar-faq[data-posicio="esquerra"] {
  margin-top: 0 !important;
}

/* === FIX responsive: elimina offset excesivo en móvil/tablet === */

/* 1) Solo en escritorio mantenemos los offsets de cabecera */
@media (min-width: 1025px) {

  /* Si usas la regla del offset visual cuando no hay .scrolled */
  body:not(.scrolled) .contenidor-info,
  body:not(.scrolled) #contenidor,
  body:not(.scrolled) .contingut-dret,
  body:not(.scrolled) .globus-de-preguntes.sidebar-faq {
    margin-top: 75px !important;
    /* solo desktop */
    transition: margin-top .25s ease-in-out;
  }

  /* Mantén el padding-top amplio del main solo en desktop */
  main {
    padding-top: 150px !important;
    /* definido arriba en tu CSS global */
  }

  /* Mantén el margen superior del panel derecho solo en desktop */
  .contingut-dret {
    margin-top: 70px !important;
  }
}

/* 2) En tablets y móviles eliminamos offsets acumulados */
@media (max-width: 1024px) {

  /* Sin desplazamiento extra por menú en móvil/tablet */
  body:not(.scrolled) .contenidor-info,
  body:not(.scrolled) #contenidor,
  body:not(.scrolled) .contingut-dret,
  body:not(.scrolled) .globus-de-preguntes.sidebar-faq {
    margin-top: 10px !important;
  }

  /* Quitamos el padding-top global del main que empuja todo hacia abajo */
  main {
    padding-top: 0 !important;
    /* antes era 150px */
  }

  /* Quitamos también el margen fijo del contenido derecho */
  .contingut-dret {
    margin-top: 0 !important;
    /* antes era 70px */
    top: auto !important;
    /* evita sumar con position:sticky/top */
  }

  /* Si lo necesitas totalmente plano en móvil: */
  .contenidor-info {
    top: 0 !important;
    /* neutraliza el top:40px de desktop */
    margin-top: 0 !important;
  }
}

/* === Móviles y tablets: permitir que el contenedor crezca === */
@media (max-width: 1024px) {
  .contenidor-info {
    position: static !important;
    /* libera del layout absoluto */
    top: auto !important;
    min-height: 110vh !important;
    /* ahora sí tendrá efecto */
    margin-top: 0 !important;
    padding-top: 1rem;
    /* opcional: aire arriba */
  }

  /* Deja respirar el panel derecho */
  .contingut-dret {
    position: relative !important;
    /* evita stickiness rara en móviles */
    max-height: none !important;
    /* elimina el tope de 65–70vh */
    min-height: 80vh !important;
    /* muestra más contenido */
  }
}

/* Móviles pequeños: aún más alto */
@media (max-width: 480px) {
  .contenidor-info {
    min-height: 120vh !important;
  }

  .contingut-dret {
    min-height: 100vh !important;
  }
}

/* MÓVIL/TABLET ≤1024px: mantener el margen grande */
@media (max-width: 1024px) {
  .contingut-dret .globus-conversa.resposta {
    margin-bottom: 180px !important;
  }
}

/* ESCRITORIO ≥1025px: quitar ese margen extra */
@media (min-width: 1025px) {
  .contingut-dret .globus-conversa.resposta {
    margin-bottom: 20px !important;
    /* ajusta el valor que quieras en desktop */
  }
}

/* Fallback de datalist para móviles/tablets */
.camp-autocompletar {
  position: relative;
}

.auto-menu {
  position: absolute;
  inset: auto 0 auto 0;
  top: calc(100% + 4px);
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  z-index: 10000;
  display: none;
}

.auto-menu.visible {
  display: block;
}

.auto-menu li {
  list-style: none;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f2f2f2;
  font-size: 0.95rem;
}

.auto-menu li:last-child {
  border-bottom: none;
}

.auto-menu li:hover {
  background: #f7f7f7;
}

.auto-menu li.buit {
  color: #999;
  cursor: default;
}

/* Separación robusta (no depende de margin de <p>) */
.contingut-dret .wrap-instruments-destacats {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

/* Opcional: neutraliza reglas generales que te indenten/peguen estas líneas */
.contingut-dret .wrap-instruments-destacats .linia-instruments-destacats {
  margin: 0 !important;
  text-indent: 0 !important;
  padding-left: 10px;
}

/* Párrafos de evaluación con aire visual */
.contingut-dret .paragraf-avaluacio {
  margin: 0 0 0.9rem 0 !important;
  text-indent: 0 !important;
  line-height: 1.6;
}

/* Modalitat: párrafos con aire aunque haya p { margin:0 } en otros sitios */
.contingut-dret .paragraf-modalitat {
  margin: 0 0 0.9rem 0 !important;
  text-indent: 0 !important;
  line-height: 1.6;
}

/* =========================================
   LAPTOPS BAJAS: scroll interno + sticky OK
   ========================================= */
@media (min-width: 1025px) and (max-height: 900px) {

  /* IMPORTANTE: el layout NO debe ser absolute en laptop */
  .contenidor-info {
    position: relative !important;
    top: 20px;
    /* mantienes tu ajuste de arriba */
  }

  /* Panel derecho: scroll interno con altura real (no se corta) */
  .contenidor-info .contingut-dret {
    position: sticky !important;
    top: 50px !important;
    /* tu top actual */

    height: calc(100dvh - 70px - 40px) !important;
    /* viewport - top - margen */
    max-height: none !important;

    overflow-y: auto !important;
    overflow-x: auto !important;
  }

  /* Sidebars: también sticky y con su propio alto */
  .globus-de-preguntes.sidebar-faq {
    position: sticky !important;
    top: 50px !important;

    height: calc(100dvh - 70px - 40px) !important;
    max-height: none !important;

    overflow-y: auto !important;
    overflow-x: visible !important;
  }
}

/* =========================================
   LAPTOPS BAJAS: sidebar IZQUIERDO con scroll propio
   (evita que se tape el último item)
   ========================================= */
@media (min-width: 1025px) and (max-height: 900px) {

  /* SOLO el sidebar de la izquierda */
  .globus-de-preguntes.sidebar-faq[data-posicio="esquerra"] {
    position: sticky !important;
    top: 70px !important;

    height: calc(100dvh - 70px - 40px) !important;
    max-height: none !important;

    overflow-y: auto !important;
    overflow-x: visible !important;

    /* aire abajo para que el último item no quede pegado/tapado */
    padding-bottom: 24px !important;
  }

  /* Si tienes un wrapper interno que hace scroll, úsalo también */
  .globus-de-preguntes.sidebar-faq[data-posicio="esquerra"] .sidebar-scroll-inner {
    max-height: 100% !important;
    overflow-y: auto !important;
    overflow-x: visible !important;
    padding-bottom: 24px !important;
  }
/* Regles per que el generador de PDF de la guía metodològica no trenqui les ffrases a la meitat en horitzontal*/
	/* Regles que SEMPRE s'apliquen (millor per a html2pdf) */
  .pdf-container > * {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    display: block;
    position: relative;
    margin-bottom: 10px;
    /* AFEGEIX AIXÒ: */
    overflow-wrap: break-word; 
    transform: translateZ(0); /* Força un nou context de renderitzat */
}