/* ── MOBILE SPECIFIC ─────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 80vw;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .debug-panel {
    position: fixed;
    inset: auto 0 0 0; /* Começa da base em vez de acima da bottom-nav para evitar gaps */
    height: 60vh;
    width: 100%;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 400; /* Acima da bottom-nav (300) */
    border-top: 1px solid var(--border);
    padding-bottom: 60px; /* Compensa a bottom-nav se necessário ou apenas garante scroll */
  }
  .debug-panel.open {
    transform: translateY(0);
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    height: calc(60px + env(safe-area-inset-bottom, 0px));
    padding: 0 10px env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--border);
    background: var(--surface);
    z-index: 300;
    justify-content: space-around;
    align-items: center;
  }

  .bottom-nav-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    cursor: pointer;
    transition: color 0.2s;
  }

  .bottom-nav-btn.active {
    color: var(--gold);
  }

  .bottom-nav-btn span.icon {
    font-size: 18px;
  }

  .main {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); /* Espaço real para a bottom nav */
  }

  .chat-panel {
    width: 100%;
    border-right: none;
  }

  /* Overlay para fechar os drawers no mobile */
  .mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s, visibility 0.3s;
    backdrop-filter: blur(2px);
  }

  .mobile-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* Ajustes de tamanhos para mobile */
  .bubble {
    max-width: 95%;
    font-size: 15px;
    padding: 12px 16px;
  }
  
  .input-area {
    padding: 12px 16px 16px;
  }
  
  .topbar {
    padding: 8px 16px;
  }
  
  .quick-chips {
    overflow-x: auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  
  .quick-chips::-webkit-scrollbar {
    display: none;
  }

  /* Esconder elementos quando o teclado sobe */
  body.keyboard-open .quick-chips,
  body.keyboard-open .bottom-nav,
  body.keyboard-open .debug-panel {
    display: none !important;
  }
  
  body.keyboard-open .main {
    padding-bottom: 0;
  }
  
  /* Garante que o painel de input nunca fique escondido por z-index */
  .input-area {
    position: relative;
    z-index: 10;
  }
}

@media (min-width: 769px) {
  .bottom-nav, .mobile-overlay {
    display: none;
  }
}