/* =========================================================
   DoMySocial — Responsive core
   Layout uniquement : aucune couleur de thème n'est imposée.
   Ce fichier corrige le débordement horizontal du header et
   garantit que le contenu reste dans la largeur du téléphone.
   ========================================================= */

@media (max-width: 980px) {
  html,
  body.dms-app {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  @supports (overflow: clip) {
    html,
    body.dms-app {
      overflow-x: clip;
    }
  }

  /* Le header ne doit jamais imposer une largeur desktop. */
  .dms-header {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: .5rem .5rem 0;
  }

  .dms-header__pill {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "user clock"
      "actions actions";
    align-items: center;
    justify-content: stretch;
    gap: .45rem .6rem;
    padding: .55rem .65rem;
  }

  .dms-header__left {
    grid-area: user;
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
  }

  .dms-header__center {
    grid-area: clock;
    min-width: 0;
    max-width: 100%;
    justify-content: flex-end;
    text-align: right;
  }

  .dms-header__right {
    grid-area: actions;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex !important;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: .4rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    padding: .05rem 0 .1rem;
  }

  .dms-header__right::-webkit-scrollbar {
    display: none;
  }

  .dms-user {
    min-width: 0 !important;
    max-width: 100%;
    flex: 1 1 auto;
  }

  .dms-user > div:last-child {
    min-width: 0;
    max-width: 100%;
  }

  .dms-user__name {
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
    gap: .25rem .45rem;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  .dms-user__sub {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dms-visitors-live {
    min-width: 0;
    max-width: 100%;
  }

  .dms-timechip {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 0;
    max-width: 100%;
    line-height: 1.15;
    white-space: nowrap;
  }

  .dms-timechip .dms-dot {
    display: none;
  }

  .dms-iconbtn {
    flex: 0 0 auto;
    min-width: 2.55rem;
    max-width: none;
  }

  /* Le layout principal doit rester à la largeur du viewport. */
  .dms-layout,
  .dms-layout--with-news,
  .dms-layout--without-news {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) !important;
    padding: .6rem .5rem;
    gap: .65rem;
  }

  .ds-left,
  .ds-center,
  .dms-rail,
  .ds-left-card,
  .rail-section,
  .rail-card,
  .post-form,
  .post {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }

  /* Les médias ne doivent jamais élargir la page. */
  body.dms-app img,
  body.dms-app video,
  body.dms-app iframe,
  body.dms-app canvas,
  body.dms-app svg {
    max-width: 100%;
  }

  body.dms-app input,
  body.dms-app select,
  body.dms-app textarea,
  body.dms-app button {
    max-width: 100%;
  }
}

@media (max-width: 620px) {
  .dms-header__pill {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .4rem .45rem;
    padding: .5rem .55rem;
  }

  .dms-user {
    gap: .5rem;
  }

  .dms-user__avatar {
    flex: 0 0 auto;
  }

  .dms-user__name {
    font-size: .92rem;
  }

  .dms-user__sub {
    font-size: .7rem;
  }

  .dms-visitors-live {
    width: 100%;
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
    white-space: normal;
  }

  .dms-timechip {
    font-size: .7rem;
  }

  .dms-header__right {
    gap: .35rem;
  }

  .dms-iconbtn {
    min-height: 2.45rem;
    min-width: 2.45rem;
    padding-left: .55rem;
    padding-right: .55rem;
  }

  .dms-layout,
  .dms-layout--with-news,
  .dms-layout--without-news {
    padding: .5rem .4rem;
  }

  .ds-left-card {
    padding: .7rem;
  }
}

@media (max-width: 390px) {
  .dms-header__pill {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "user"
      "clock"
      "actions";
  }

  .dms-header__center {
    justify-content: flex-start;
    text-align: left;
  }

  .dms-timechip {
    flex-direction: row;
    align-items: center;
    gap: .35rem;
  }
}

/* =========================================================
   Correctif mobile 2026-08-22
   Sur certains thèmes, les règles desktop .ds-left/.dms-rail
   repassent en position:sticky après leurs media queries.
   En vue mobile, cela faisait glisser le fil au-dessus du menu
   et la zone À la une au-dessus/derrière d'autres cartes.
   ========================================================= */
@media (max-width: 980px) {
  .dms-layout > .ds-left,
  .dms-layout > .dms-rail {
    position: static !important;
    top: auto !important;
    inset: auto !important;
    z-index: auto !important;
    max-height: none !important;
    overflow: visible !important;
    align-self: auto !important;
  }

  .dms-layout > .ds-center {
    position: relative;
    z-index: auto !important;
  }

  .dms-layout > .ds-left,
  .dms-layout > .ds-center,
  .dms-layout > .dms-rail {
    grid-column: 1 !important;
    min-width: 0;
    transform: none;
  }

  .ds-left-card,
  .rail-news,
  .ds-center > .card,
  .ds-center > .post,
  .ds-center > .post-form {
    isolation: isolate;
  }
}

/* Header visiteur mobile compact */
@media (max-width: 620px) {
  .dms-header {
    padding: .35rem .4rem 0;
  }

  .dms-header__pill--guest {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "user clock"
      "actions actions";
    gap: .35rem .5rem;
    padding: .5rem .65rem;
    border-radius: 1.35rem;
  }

  .dms-header__pill--guest .dms-header__left {
    display: flex !important;
    align-items: center;
    flex-wrap: wrap;
    gap: .18rem .6rem;
    min-width: 0;
  }

  .dms-header__pill--guest .dms-user {
    flex: 0 1 auto;
    width: auto;
  }

  .dms-header__pill--guest .dms-user__name {
    font-size: .88rem;
    line-height: 1.05;
    white-space: nowrap;
  }

  .dms-header__pill--guest .dms-visitors-live {
    width: auto;
    margin: 0;
    padding: 0;
    border-left: 0;
    gap: .22rem;
    font-size: .66rem;
    line-height: 1.05;
    white-space: nowrap;
  }

  .dms-header__pill--guest .dms-visitors-live__label {
    display: none;
  }

  .dms-header__pill--guest .dms-visitors-live strong {
    font-size: .72rem;
  }

  .dms-header__pill--guest .dms-header__center {
    justify-content: flex-end;
    align-self: center;
    text-align: right;
  }

  .dms-header__pill--guest .dms-timechip {
    font-size: .61rem;
    line-height: 1.05;
    opacity: .82;
    white-space: nowrap;
  }

  .dms-header__pill--guest .dms-header__right {
    justify-content: center;
    align-items: center;
    overflow: visible;
    gap: .35rem;
    padding: .05rem 0 0;
  }

  .dms-header__pill--guest .dms-header__right .btn {
    flex: 0 1 auto;
    width: auto;
    min-width: 0;
    min-height: 2.2rem;
    padding: .42rem .7rem;
    font-size: .78rem;
    line-height: 1;
    white-space: nowrap;
  }

  .dms-header__pill--guest .dms-iconbtn {
    width: 2.2rem;
    min-width: 2.2rem;
    height: 2.2rem;
    min-height: 2.2rem;
    padding: 0;
  }
}

@media (max-width: 390px) {
  .dms-header__pill--guest {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "user clock"
      "actions actions";
    gap: .32rem .4rem;
    padding: .48rem .55rem;
  }

  .dms-header__pill--guest .dms-header__center {
    justify-content: flex-end;
    text-align: right;
  }

  .dms-header__pill--guest .dms-timechip {
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
  }

  .dms-header__pill--guest .dms-header__right {
    gap: .28rem;
  }

  .dms-header__pill--guest .dms-header__right .btn {
    padding-left: .55rem;
    padding-right: .55rem;
    font-size: .74rem;
  }
}

/* =========================================================
   Header visiteur mobile — version réellement compacte
   Dimensions en px pour rester petites même si l'instance
   utilise une échelle d'interface élevée.
   ========================================================= */
@media (max-width: 620px) {
  .dms-header {
    padding: 4px 6px 0 !important;
  }

  .dms-header__pill--guest {
    min-height: 0 !important;
    padding: 6px 9px !important;
    border-radius: 16px !important;
    gap: 4px 8px !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-areas:
      "user clock"
      "actions actions" !important;
  }

  .dms-header__pill--guest .dms-header__left {
    gap: 2px 8px !important;
    min-height: 0 !important;
    line-height: 1 !important;
  }

  .dms-header__pill--guest .dms-user,
  .dms-header__pill--guest .dms-user > div {
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .dms-header__pill--guest .dms-user__name {
    font-size: 14px !important;
    line-height: 16px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .dms-header__pill--guest .dms-visitors-live {
    gap: 3px !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 11px !important;
    line-height: 14px !important;
  }

  .dms-header__pill--guest .dms-visitors-live strong {
    font-size: 12px !important;
    line-height: 14px !important;
  }

  .dms-header__pill--guest .dms-header__center {
    min-height: 0 !important;
    line-height: 1 !important;
  }

  .dms-header__pill--guest .dms-timechip {
    font-size: 10px !important;
    line-height: 11px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .dms-header__pill--guest .dms-header__right {
    width: 100% !important;
    min-height: 0 !important;
    gap: 5px !important;
    padding: 1px 0 0 !important;
    margin: 0 !important;
    justify-content: flex-end !important;
    overflow: hidden !important;
  }

  .dms-header__pill--guest .dms-header__right .btn {
    width: auto !important;
    min-width: 0 !important;
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    padding: 0 10px !important;
    margin: 0 !important;
    border-radius: 10px !important;
    font-size: 12px !important;
    line-height: 30px !important;
    white-space: nowrap !important;
    box-shadow: none !important;
  }

  .dms-header__pill--guest .dms-iconbtn,
  .dms-header__pill--guest #dmsPwaInstallBtn {
    flex: 0 0 30px !important;
    width: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 10px !important;
    font-size: 14px !important;
    line-height: 28px !important;
    box-shadow: none !important;
  }
}

@media (max-width: 390px) {
  .dms-header__pill--guest {
    padding: 5px 7px !important;
    gap: 3px 6px !important;
  }

  .dms-header__pill--guest .dms-user__name {
    font-size: 13px !important;
  }

  .dms-header__pill--guest .dms-visitors-live {
    font-size: 10px !important;
  }

  .dms-header__pill--guest .dms-timechip {
    font-size: 9px !important;
  }

  .dms-header__pill--guest .dms-header__right {
    gap: 4px !important;
  }

  .dms-header__pill--guest .dms-header__right .btn {
    height: 28px !important;
    min-height: 28px !important;
    max-height: 28px !important;
    padding: 0 8px !important;
    border-radius: 9px !important;
    font-size: 11px !important;
    line-height: 28px !important;
  }

  .dms-header__pill--guest .dms-iconbtn,
  .dms-header__pill--guest #dmsPwaInstallBtn {
    flex-basis: 28px !important;
    width: 28px !important;
    min-width: 28px !important;
    max-width: 28px !important;
    height: 28px !important;
    min-height: 28px !important;
    max-height: 28px !important;
    border-radius: 9px !important;
    font-size: 13px !important;
    line-height: 26px !important;
  }
}

/* =========================================================
   Bloc principal mobile — version compacte
   Réduit uniquement la carte logo / statistiques / navigation.
   ========================================================= */
@media (max-width: 620px) {
  .ds-left-card {
    padding: 10px !important;
  }

  .ds-left-card .ds-logo {
    gap: 4px !important;
    margin-bottom: 6px !important;
  }

  .ds-left-card .ds-logo img {
    width: 64px !important;
    height: 64px !important;
    min-width: 64px !important;
    min-height: 64px !important;
  }

  .ds-left-card .ds-site {
    font-size: 16px !important;
    line-height: 18px !important;
  }

  /* Statistiques : compactes, toujours lisibles en 2 x 2. */
  .ds-left-card > .ds-logo + .ds-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    margin-top: 6px !important;
  }

  .ds-left-card > .ds-logo + .ds-kpis .ds-kpi {
    min-height: 50px !important;
    padding: 5px 4px !important;
    border-radius: 11px !important;
    font-size: 11px !important;
    line-height: 13px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2px !important;
  }

  .ds-left-card > .ds-logo + .ds-kpis .ds-kpi > span:first-child {
    font-size: 12px !important;
    line-height: 14px !important;
    font-weight: 800 !important;
  }

  .ds-left-card > .ds-logo + .ds-kpis .ds-kpi .muted {
    font-size: 10px !important;
    line-height: 12px !important;
  }

  .ds-left-card > .ds-sep {
    margin: 7px 0 !important;
  }

  /* Navigation : les 4 boutons sur UNE seule ligne. */
  .ds-left-card > .ds-sep + .ds-kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 6px !important;
    margin-top: 0 !important;
  }

  .ds-left-card > .ds-sep + .ds-kpis .ds-kpi {
    min-width: 0 !important;
    min-height: 54px !important;
    padding: 5px 2px !important;
    border-radius: 11px !important;
    font-size: 10px !important;
    line-height: 12px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2px !important;
    overflow: hidden !important;
  }

  .ds-left-card > .ds-sep + .ds-kpis .ds-kpi > span:first-child {
    font-size: 20px !important;
    line-height: 22px !important;
  }

  .ds-left-card > .ds-sep + .ds-kpis .ds-kpi > span:nth-child(2) {
    max-width: 100% !important;
    font-size: 10px !important;
    line-height: 12px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}

@media (max-width: 390px) {
  .ds-left-card {
    padding: 8px !important;
  }

  .ds-left-card .ds-logo img {
    width: 58px !important;
    height: 58px !important;
    min-width: 58px !important;
    min-height: 58px !important;
  }

  .ds-left-card .ds-site {
    font-size: 15px !important;
    line-height: 17px !important;
  }

  .ds-left-card > .ds-logo + .ds-kpis,
  .ds-left-card > .ds-sep + .ds-kpis {
    gap: 5px !important;
  }

  .ds-left-card > .ds-logo + .ds-kpis .ds-kpi {
    min-height: 46px !important;
  }

  .ds-left-card > .ds-sep + .ds-kpis .ds-kpi {
    min-height: 50px !important;
  }

  .ds-left-card > .ds-sep + .ds-kpis .ds-kpi > span:first-child {
    font-size: 18px !important;
    line-height: 20px !important;
  }

  .ds-left-card > .ds-sep + .ds-kpis .ds-kpi > span:nth-child(2) {
    font-size: 9px !important;
    line-height: 11px !important;
  }
}

/* =========================================================
   News mobile dans le header
   - Sur desktop, le mode "rail" reste inchangé.
   - Sur mobile, la colonne À la une disparaît du bas de page.
   - La petite pastille 📰 du header ouvre la même zone en popup.
   ========================================================= */
.dms-news-mobile-close {
  display: none;
}

@media (min-width: 981px) {
  .dms-iconbtn--news-mobile-rail {
    display: none !important;
  }
}

@media (max-width: 980px) {
  body.dms-news-modal-open {
    overflow: hidden !important;
  }

  .dms-iconbtn--news-mobile-rail {
    display: inline-flex !important;
  }

  .dms-layout > .dms-rail#dmsNewsMobileRail {
    display: none !important;
  }

  .dms-layout > .dms-rail#dmsNewsMobileRail.dms-news-mobile-open {
    display: block !important;
    position: fixed !important;
    inset: 10px !important;
    width: auto !important;
    max-width: none !important;
    max-height: calc(100dvh - 20px) !important;
    overflow: auto !important;
    z-index: 10050 !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
  }

  #dmsNewsMobileRail .dms-news-mobile-close {
    display: flex !important;
    position: sticky !important;
    top: 6px !important;
    z-index: 2 !important;
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
    margin: 6px 6px -36px auto !important;
    padding: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 9px !important;
    font-size: 18px !important;
    line-height: 1 !important;
  }

  #dmsNewsMobileRail .rail-news {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding-top: 42px !important;
  }
}

@media (max-width: 620px) {
  .dms-header__right .dms-iconbtn--news-mobile-rail,
  .dms-header__pill--guest .dms-iconbtn--news-mobile-rail {
    flex: 0 0 30px !important;
    width: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    padding: 0 !important;
    border-radius: 9px !important;
    font-size: 14px !important;
    line-height: 28px !important;
  }
}
