/* =====================================================================
   DAY Stock — VERSION SMARTPHONE
   Ce fichier n'est chargé que sur un écran de moins de 700 px de large
   (voir la balise <link media="…"> dans index.html). Sur ordinateur il
   n'est même pas lu : la version ordinateur reste exactement la même.
   ===================================================================== */

@media (max-width: 700px) {
  html {
    -webkit-tap-highlight-color: transparent;
  }
  body {
    background: #eef1f5;
  }

  /* ------------------------------------------------------------------
     Barre du haut : bandeau sombre, deux lignes
     1re ligne : DAY Stock · recherche · cloche · profil
     2e ligne  : Pommes de terre / Poireaux · saison
     ------------------------------------------------------------------ */
  .haut {
    flex-wrap: wrap;
    gap: 10px 8px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 12px;
    background: linear-gradient(160deg, #0f1e33 0%, #16283f 100%);
    border-bottom: 0;
    box-shadow: 0 6px 18px rgba(10, 21, 38, 0.22);
  }
  .haut::after {
    content: "";
    order: 5;
    flex-basis: 100%;
    height: 0;
  }
  .haut-droite {
    display: contents;
  }
  .haut-menu {
    display: none !important;
    order: 0;
  }
  body:not(.tel-avec-onglets) .haut-menu {
    display: flex !important;
  }
  .haut-menu span {
    background: #fff;
  }

  #tel-marque {
    order: 1;
    display: flex;
    align-items: center;
    gap: 9px;
    margin-right: auto;
    min-width: 0;
  }
  #tel-marque svg {
    width: 32px;
    height: 32px;
    flex: none;
  }
  #tel-marque b {
    color: #fff;
    font: 800 18px/1 var(--sans);
    letter-spacing: -0.02em;
    white-space: nowrap;
  }
  #tel-marque em {
    font-style: normal;
    color: var(--vert-500);
  }

  /* recherche : une loupe, qui s'ouvre sur toute la largeur */
  .recherche {
    order: 2;
    flex: none;
    width: 40px;
    height: 40px;
    max-width: none;
    position: static;
  }
  .recherche > svg {
    left: auto;
    right: auto;
    stroke: #fff;
    width: 19px;
    height: 19px;
    z-index: 2;
    position: absolute;
    transform: none;
    margin: 10px 0 0 10px;
    top: auto;
  }
  .recherche input {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: transparent;
    font-size: 16px;
    cursor: pointer;
    caret-color: transparent;
  }
  .recherche input::placeholder {
    color: transparent;
  }
  .recherche:focus-within input {
    position: absolute;
    left: 14px;
    right: 14px;
    top: calc(10px + env(safe-area-inset-top, 0px));
    width: auto;
    height: 44px;
    padding: 0 14px 0 42px;
    background: #fff;
    border-color: #fff;
    color: var(--encre);
    caret-color: auto;
    z-index: 3;
    cursor: text;
  }
  .recherche:focus-within input::placeholder {
    color: var(--sourdine);
  }
  .recherche:focus-within > svg {
    stroke: var(--sourdine);
    position: absolute;
    left: 28px;
    top: calc(22px + env(safe-area-inset-top, 0px));
    margin: 0;
    z-index: 4;
  }
  .recherche-res {
    position: fixed;
    top: calc(64px + env(safe-area-inset-top, 0px));
    left: 10px;
    right: 10px;
    max-height: 70vh;
    border-radius: 16px;
  }

  .cloche {
    order: 3;
    color: #fff;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
  }
  .cloche:hover {
    background: rgba(255, 255, 255, 0.14);
  }
  .profil {
    order: 4;
    padding: 0;
    background: none;
    border: 0;
  }
  .profil .chev,
  .profil-txt {
    display: none;
  }
  .profil .avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--vert-600);
    color: #fff;
  }

  /* 2e ligne : interface + saison */
  .activite {
    order: 6;
    flex: 1 1 0;
    min-width: 0;
    height: 42px;
    margin: 0;
    padding: 3px;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
  }
  .activite button {
    flex: 1;
    justify-content: center;
    padding: 0 8px;
    color: rgba(255, 255, 255, 0.75);
    border-radius: 9px;
    font-size: 13.5px;
  }
  .activite button > span {
    display: inline !important;
  }
  .activite .act-long {
    display: none !important;
  }
  .activite .act-court {
    display: inline !important;
  }
  .activite button[aria-pressed="true"] {
    color: #fff;
  }
  .saison {
    order: 7;
    height: 42px;
    margin: 0;
    padding: 0 6px 0 10px;
    border-radius: 12px;
    border: 0;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
  }
  .saison {
    flex: none;
  }
  .saison select {
    color: #fff;
    font-size: 14px;
    min-width: 108px;
    max-width: 132px;
    padding-right: 0;
  }
  .activite button {
    min-width: 0;
    gap: 6px;
  }
  .activite .act-ico svg {
    width: 20px;
    height: 20px;
  }
  .saison select option {
    color: var(--encre);
  }
  .saison.archive {
    background: var(--ambre-100);
  }
  .saison.archive select {
    color: #6b5000;
  }

  /* panneaux alertes / profil : sous la barre, pleine largeur */
  .panneau {
    position: fixed !important;
    top: calc(118px + env(safe-area-inset-top, 0px)) !important;
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    max-height: 70vh;
    overflow: auto;
    border-radius: 18px !important;
    z-index: 70;
  }

  /* ------------------------------------------------------------------
     Menu latéral (bouton « Plus »)
     ------------------------------------------------------------------ */
  .barre {
    width: min(86vw, 330px);
    border-radius: 0 22px 22px 0;
    z-index: 90;
  }
  .voile {
    z-index: 85;
  }
  .nav button {
    padding-top: 13px;
    padding-bottom: 13px;
    font-size: 15.5px;
  }

  /* ------------------------------------------------------------------
     Barre d'onglets en bas
     ------------------------------------------------------------------ */
  #tel-onglets {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.94);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
    border-top: 1px solid var(--bord);
    box-shadow: 0 -6px 20px rgba(15, 30, 51, 0.07);
  }
  #tel-onglets button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 2px 5px;
    border: 0;
    border-radius: 12px;
    background: none;
    color: var(--sourdine);
    font: 600 10.5px/1.1 var(--sans);
    cursor: pointer;
  }
  #tel-onglets svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  #tel-plus svg {
    fill: currentColor;
    stroke: none;
  }
  #tel-onglets button[aria-current="page"] {
    color: var(--vert-700);
    background: var(--vert-50);
  }
  body.tel-avec-onglets .contenu {
    padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px));
  }

  /* ------------------------------------------------------------------
     Bouton principal de la page : rond, en bas à droite
     ------------------------------------------------------------------ */
  .entete-actions .tel-fab {
    position: fixed;
    right: 16px;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    z-index: 55;
    min-height: 52px;
    padding: 0 20px 0 16px;
    border-radius: 999px;
    font: 700 15px var(--sans);
    box-shadow: 0 10px 24px rgba(224, 133, 47, 0.45), 0 2px 6px rgba(15, 30, 51, 0.18);
  }
  .entete-actions .tel-fab svg {
    width: 20px;
    height: 20px;
  }
  body:not(.tel-avec-onglets) .entete-actions .tel-fab {
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  /* ------------------------------------------------------------------
     Contenu
     ------------------------------------------------------------------ */
  .contenu {
    padding: 16px 14px 60px;
  }
  .entete {
    gap: 12px;
    margin-bottom: 16px;
  }
  .entete > div:first-child {
    width: 100%;
  }
  .entete-saison {
    display: none !important;
  }
  .entete h1 {
    font-size: 26px;
    line-height: 1.15;
  }
  .entete p {
    font-size: 13.5px;
    margin-top: 5px;
  }
  .entete-actions {
    width: calc(100% + 28px);
    margin: 0 -14px;
    padding: 2px 14px 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .entete-actions::-webkit-scrollbar {
    display: none;
  }
  .entete-actions > * {
    flex: none;
  }
  .entete-actions .select {
    max-width: 62vw;
  }

  .btn {
    min-height: 42px;
    padding: 8px 14px;
    border-radius: 12px;
    font-size: 14px;
  }

  /* filtres : une ligne qui défile avec le doigt */
  .outils {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -14px 14px;
    padding: 2px 14px 6px;
    scrollbar-width: none;
    gap: 8px;
  }
  .outils::-webkit-scrollbar {
    display: none;
  }
  .outils > * {
    flex: none;
  }
  .segm {
    flex: none;
    border-radius: 12px;
    border-color: var(--bord);
  }
  .segm button {
    padding: 9px 13px;
    white-space: nowrap;
    font-size: 13.5px;
  }
  .select,
  .outils select {
    min-height: 40px;
    border-radius: 12px;
    font-size: 14px;
    max-width: 70vw;
  }

  /* chiffres clés : deux par ligne, compacts */
  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
  }
  .stats > .stat:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
  .stat {
    padding: 13px 13px 12px;
    border-radius: 18px;
  }
  .stat-haut {
    flex-direction: column;
    gap: 9px;
  }
  .stat-ico {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }
  .stat-ico svg {
    width: 18px;
    height: 18px;
  }
  .stat-lbl {
    font-size: 12.5px;
    line-height: 1.25;
  }
  .stat-val {
    font-size: 22px !important;
    margin-top: 2px;
    overflow-wrap: anywhere;
  }
  .stat-bas {
    margin-top: 8px;
    font-size: 11.5px;
    line-height: 1.35;
    gap: 4px 6px;
  }
  .kpi-duo b {
    font-size: 20px;
  }

  /* cartes */
  .carte {
    border-radius: 18px;
    border-color: transparent;
    box-shadow: 0 1px 3px rgba(15, 30, 51, 0.06), 0 6px 16px rgba(15, 30, 51, 0.04);
  }
  .carte-pad {
    padding: 14px;
  }
  .carte-tete {
    padding: 14px 14px 10px;
    gap: 10px;
  }
  .carte-tete h2 {
    font-size: 16.5px;
  }
  .carte-tete p {
    font-size: 12.5px;
  }
  .carte-corps {
    padding: 4px 12px 12px;
  }
  .grille {
    gap: 12px;
  }

  /* listes (tableaux affichés en fiches) : une fiche par ligne,
     les informations rangées sur deux colonnes */
  table.tab.repli tr {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 9px 14px;
    margin: 0 0 9px;
    padding: 12px 13px;
    border: 0;
    border-radius: 16px;
    background: #f6f8fb;
  }
  table.tab.repli tbody tr:last-child {
    margin-bottom: 0;
  }
  table.tab.repli td {
    display: block !important;
    padding: 0;
    text-align: left !important;
    font-size: 14px;
    line-height: 1.3;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  table.tab.repli td::before {
    display: block;
    margin-bottom: 2px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #9aa4b2;
  }
  /* la première information sert de titre à la fiche */
  table.tab.repli td:first-child {
    grid-column: 1 / -1;
    font-size: 15.5px;
    font-weight: 700;
    padding-bottom: 8px;
    border-bottom: 1px solid #e8ecf1;
  }
  table.tab.repli td[data-l="Remarques"],
  table.tab.repli td[data-l="Activité"],
  table.tab.repli td[data-l="Big bags sortis"],
  table.tab.repli td[data-l="Détail"] {
    grid-column: 1 / -1;
  }
  /* boutons de la ligne (···, imprimer) : en bas à droite */
  table.tab.repli td[data-l=""] {
    grid-column: 1 / -1;
    display: flex !important;
    justify-content: flex-end;
    gap: 6px;
    margin-top: -2px;
  }
  table.tab.repli td[data-l=""]:empty {
    display: none !important;
  }
  table.tab.repli .menu-pts {
    min-width: 40px;
    min-height: 34px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--bord);
  }

  /* ------------------------------------------------------------------
     Fenêtres de saisie : elles montent du bas de l'écran
     ------------------------------------------------------------------ */
  dialog#modale,
  dialog#modale.modale-large {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
    border: 0;
    border-radius: 24px 24px 0 0;
    max-height: 94dvh;
    animation: tel-monte 0.22s ease-out;
  }
  @keyframes tel-monte {
    from {
      transform: translateY(40px);
      opacity: 0.6;
    }
    to {
      transform: none;
      opacity: 1;
    }
  }
  #modale-form {
    max-height: 94dvh;
  }
  #modale-form header {
    position: relative;
    padding: 22px 18px 12px;
  }
  #modale-form header::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 40px;
    height: 5px;
    margin-left: -20px;
    border-radius: 3px;
    background: var(--bord-fort);
  }
  #modale-form h2 {
    font-size: 19px;
  }
  .modale-x {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: var(--page);
  }
  .champs {
    grid-template-columns: 1fr !important;
    gap: 14px;
    padding: 16px 18px 18px;
  }
  .champ > span {
    font-size: 13px;
    font-weight: 600;
  }
  /* 16 px : l'iPhone ne zoome plus quand on touche une case */
  .champ input,
  .champ select,
  .champ textarea,
  .combo-in {
    font-size: 16px !important;
    min-height: 46px;
    padding: 11px 13px;
    border-radius: 12px;
  }
  .champ textarea {
    min-height: 84px;
  }
  .radios {
    display: flex;
    width: 100%;
    border-radius: 12px;
  }
  .radios label {
    flex: 1 1 auto;
    justify-content: center;
    padding: 11px 10px;
    text-align: center;
  }
  .modale-erreur {
    margin: 0 18px 10px;
  }
  #modale-form footer {
    padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
    box-shadow: 0 -6px 16px rgba(15, 30, 51, 0.05);
  }
  #modale-form footer .btn {
    min-height: 48px;
    font-size: 15px;
    justify-content: center;
  }
  #modale-ok {
    flex: 1 1 140px;
  }
  #modale-form footer .espace {
    display: none;
  }
  #modale-suppr:not([hidden]) {
    order: 3;
    flex: 1 1 100%;
  }

  /* ------------------------------------------------------------------
     Messages et barres flottantes : au-dessus des onglets
     ------------------------------------------------------------------ */
  /* petits messages (« Entrée enregistrée »…) : en haut, sous la barre */
  #notif,
  body.tel-avec-onglets #notif {
    top: calc(126px + env(safe-area-inset-top, 0px));
    bottom: auto;
    border-radius: 14px;
    text-align: center;
  }
  body.tel-avec-onglets .prl-barre {
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
  .prl-barre {
    width: calc(100vw - 20px);
    justify-content: center;
    border-radius: 18px;
  }
  .prl-barre > b,
  .prl-barre > span {
    flex-basis: 100%;
    text-align: center;
  }
  #infobulle {
    display: none !important;
  }

  /* plan des frigos et du bâtiment */
  .prl-zone,
  .bat-zone {
    margin: 0 -4px;
  }
  .bat-svg {
    min-width: 520px;
  }
}

@media (max-width: 700px) {
  /* notifications : le bouton d'action passe sous le texte */
  .notif-l {
    flex-wrap: wrap;
  }
  .notif-l .notif-ouvrir {
    flex: 1 1 calc(100% - 50px);
  }
  .notif-l .notif-agir {
    order: 3;
    margin: 0 0 4px 52px;
  }
  .notif-tete {
    flex-wrap: wrap;
    gap: 4px 10px;
  }
}
/* plusieurs cultures : sur téléphone, les noms courts sans icône */
@media (max-width: 700px) {
  .activite.act-plein .act-ico { display: none !important; }
  .activite.act-plein button { padding: 0 6px; font-size: 13px; }
}

/* bulle « Nous contacter » : en bas à GAUCHE, au-dessus des onglets (le bouton rond de la page est à droite) */
@media (max-width: 700px) {
  .contact { right: auto; left: 14px; bottom: calc(134px + env(safe-area-inset-bottom, 0px)); align-items: flex-start; }
  .contact-bulle { width: 40px; height: 40px; }
  .contact-bulle svg { width: 28px; height: 28px; }
  .contact-boite { transform-origin: bottom left; }
}
/* v22u : lieux de stockage sur téléphone : sans icône, noms courts */
@media (max-width: 900px) {
  #lieux .act-ico { display: none !important; }
  #lieux button, #lieux button[data-lieu="tous"] { padding: 0 9px; }
  #lieux button[aria-pressed="true"] { background: #334155 !important; color: #fff !important; }
}
