/* ========================================
   OPTIMISATIONS SUPPLÉMENTAIRES DU HEADER MOBILE
   À ajouter à StyleHeader_v2.css ou créer un fichier séparé
   ======================================== */

@media screen and (max-width: 768px) {
  
  /* Header mobile - ajustements fins */
  header {
    flex-wrap: nowrap;
    height: 35px;
    min-height: 50px;
    padding-top: 5px;
    padding-bottom: 5px;
    width: 100%;
    min-width: inherit;
  }

  /* Logo centré et plus petit */
  .logoContainer {
    justify-content: center;
    margin-left: 7%;
  }

  .logoContainer .logo {
    display: flex;
    align-items: center;
  }

  .logoTxt {
    white-space: nowrap;
    margin-left: 0;
  }

  /* threadInfo-container ne doit plus prendre d'espace dans le flex du header */
  .threadInfo-container {
    width: 0;
    overflow: hidden;
  }

  /* ========================================
     CONTEXT BAR — GLASSMORPHISM (mobile)
     ======================================== */

  .thread-toolbar {
    position: fixed;
    top: 50px;
    left: 8px;
    right: 8px;
    height: auto;
    max-width: 97vw;
    z-index: 900;
    border-radius: 16px;
    /* Override desktop pill styles */
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.03);
    transform: none;
    padding: 2px 6px 2px 4px;
    gap: 0;
  }

  .thread-toolbar:hover {
    transform: none;
    box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.03);
  }

  .thread-toolbar::before {
    display: none;
  }

  /* Folder trigger — compact sur mobile */
  .folder-dropdown-wrapper {
    flex-shrink: 0;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    padding-right: 6px;
    margin-right: 4px;
  }

  .folder-trigger {
    font-size: 12px;
    padding: 4px 8px 4px 6px;
    gap: 4px;
    border-radius: 8px;
  }

  .folder-trigger-chevron { width: 12px; height: 12px; }

  /* Le panel reste positionné normalement (absolute par rapport au wrapper) */
  .folder-panel {
    max-height: 260px;
    min-width: 180px;
  }

  /* Input titre inline */
  .chat-title {
    flex: 1;
    min-width: 0;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 6px;
    outline: none;
    font-size: 14px;
    font-weight: 700;
    text-align: left;
    padding: 0 4px;
    color: #5a5c66;
    box-shadow: none;
    letter-spacing: 0;
  }

  .chat-title::placeholder {
    font-size: 13px;
    color: var(--muted, #94a3b8);
  }

  .chat-title:hover {
    background: transparent;
    border-color: transparent;
  }

  .chat-title:focus {
    background: rgba(99, 102, 241, 0.06);
    box-shadow: none;
    padding-left: 6px;
    border-radius: 6px;
    border-color: transparent;
  }

  /* Status message caché sur mobile */
  #nameStatusMsg {
    display: none;
  }

  /* Bouton de suppression */
  .btn-delete {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 10px;
    flex-shrink: 0;
  }

  .btn-delete:active {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    box-shadow: none;
  }

  /* Bouton de déconnexion mobile */
  .logoutContainer {
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
  }

  .logoutBox {
    white-space: nowrap;
    padding: 5px 8px;
  }

  /* Nav non-connecté mobile */
  .logoutContainer nav ul {
    flex-wrap: nowrap;
    gap: 4px;
  }

  .logoutContainer nav ul li a {
    padding: 4px 10px;
    font-size: 0.78em;
    white-space: nowrap;
    line-height: 1;
  }

  /* Connexion pill — hauteur réduite */
  .logoutContainer nav ul li:first-child a {
    padding: 4px 12px;
    border-radius: 6px;
  }

  /* Masquer "Info & support" sur tout mobile */
  .logoutContainer nav ul li:nth-child(3) {
    display: none;
  }

  /* Notifications mobiles */
  #notification-container {
    left: 10px;
    right: 10px;
    top: 60px;
    width: auto;
    max-width: calc(100% - 20px);
  }

  .notification {
    font-size: 0.85em;
    padding: 12px 13px;
  }

  /* Dark mode */
  [data-theme="dark"] .thread-toolbar {
    background: rgba(15, 23, 42, 0.82);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.05);
  }

  [data-theme="dark"] .folder-dropdown-wrapper {
    border-right-color: rgba(255, 255, 255, 0.1);
  }

  [data-theme="dark"] .chat-title {
    color: #c7d2fe;
  }

  [data-theme="dark"] .btn-delete {
    color: #64748b;
  }

  [data-theme="dark"] .btn-delete:active {
    background: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
  }
}

@media screen and (max-width: 480px) {

  /* Très petits écrans */
  header {
    min-height: 45px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .logoTxt {
    font-size: 15px;
  }

  .logoContainer .logo img {
    max-height: 28px;
  }

  .logoutBox {
    font-size: 0.65em;
    padding: 4px 6px;
  }

  /* Ajustements taille sur très petit écran */
  .folder-trigger { font-size: 11px; }

  .chat-title {
    font-size: 13px;
  }

  /* Nav non-connecté — très petit écran */
  .logoutContainer nav ul {
    gap: 3px;
  }

  .logoutContainer nav ul li a {
    padding: 3px 8px;
    font-size: 0.73em;
    line-height: 1;
    border-radius: 6px;
  }

  .logoutContainer nav ul li:first-child a {
    padding: 3px 10px;
  }

  /* Masquer "Info & support" sous 480px pour éviter l'overflow */
  .logoutContainer nav ul li:nth-child(3) {
    display: none;
  }

  /* Logo texte — taille réduite */
  .logoTxt {
    font-size: 14px;
  }

  /* Logo icône — réduit sur très petit écran */
  .logoContainer .logo img {
    max-height: 24px;
  }

  /* Logo margin réduit */
  .logoContainer {
    margin-left: 0;
  }
}

/* ========================================
   MODE PAYSAGE MOBILE
   ======================================== */

@media screen and (max-width: 900px) and (orientation: landscape) {

  header {
    min-height: 40px;
  }

  .logoContainer .logo img {
    max-height: 32px;
  }

  .logoTxt {
    font-size: 16px;
  }

  .chat-title {
    font-size: 13px;
  }
}

/* ========================================
   TABLETTES (768px - 1024px)
   ======================================== */

@media screen and (min-width: 769px) and (max-width: 1024px) {
  .nav_container {
    width: 220px;
  }
}
