/* ============================================================
   MOBILE.CSS — Responsividade para todos os painéis
   Breakpoint principal: 768 px
   ============================================================ */

/* ── Toque geral ─────────────────────────────────────────── */
* { -webkit-tap-highlight-color: transparent; }
input, textarea, select, button { touch-action: manipulation; }
/* Previne zoom automático em iOS ao focar inputs */
@media (max-width: 768px) {
  input, textarea, select { font-size: 16px !important; }
}

/* ================================================================
   HAMBURGER BUTTON
   ================================================================ */
.btn-hamburger {
  display: none;          /* visível só via media query abaixo */
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  background: var(--clr-glass, rgba(255,255,255,0.06));
  border: 1px solid var(--clr-border, rgba(255,255,255,0.08));
  border-radius: 10px;
  color: var(--clr-muted-lt, #94a3b8);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-hamburger:hover { background: var(--clr-surface-2, #1a2540); color: var(--clr-text, #e2e8f0); }
.btn-hamburger svg { width: 20px; height: 20px; }

/* Overlay que fecha a sidebar ao clicar fora */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 89;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: opacity 0.25s;
}
.sidebar-overlay.visible { display: block; }

/* ================================================================
   SIDEBAR DRAWER — mobile
   ================================================================ */
@media (max-width: 768px) {

  /* ── Mostrar botão hamburger ── */
  .btn-hamburger { display: flex; }

  /* ── Header compacto ── */
  .header {
    height: 56px !important;
    padding: 0 0.75rem !important;
  }
  :root { --header-h: 56px; }

  .header-logo   { height: 28px !important; }
  .header-right  { gap: 0.5rem !important; }
  .header-subtitle { display: none !important; }

  /* Nome do usuário: ocultar em telas muito estreitas */
  .user-name { display: none; }

  /* User chip: só o avatar */
  .user-chip {
    background: none !important;
    border: none !important;
    padding: 0.25rem !important;
    border-radius: 50% !important;
  }

  /* ── SIDEBAR: drawer a partir da esquerda ── */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 270px !important;
    height: 100% !important;
    /* estado fechado: fora da tela */
    transform: translateX(-100%) !important;
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1) !important;
    z-index: 300 !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    padding: 1rem !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }

  /* ── Estado aberto (JS adiciona .sidebar-open) ── */
  .sidebar.sidebar-open {
    transform: translateX(0) !important;
  }

  /* ── Main: largura total sem offset de sidebar ── */
  .main {
    margin-left: 0 !important;
    padding: 1rem !important;
    padding-top: calc(var(--header-h, 56px) + 0.75rem) !important;
    padding-bottom: 1.5rem !important;
  }

  /* ── Layout flex do admin/dashboard ── */
  .layout { flex-direction: column !important; }

  /* ── KPI grid: 2 colunas ── */
  .kpi-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.65rem !important;
  }
  .kpi-card { padding: 1rem !important; }
  .kpi-value { font-size: 1.6rem !important; }

  /* ── Charts: 1 coluna ── */
  .charts-grid { grid-template-columns: 1fr !important; }
  .chart-card.wide { grid-column: span 1 !important; }

  /* ── Tabelas: scroll horizontal ── */
  .table-wrap { overflow-x: auto; }
  table { min-width: 480px; }

  /* ── Search card ── */
  .search-card { padding: 1rem !important; }
  .search-row  { flex-direction: column !important; gap: 0.65rem !important; }
  .btn-search  { width: 100% !important; height: 44px !important; }

  /* ── QR code ── */
  #qr-reader { width: 100% !important; }

  /* ── Formulário de inspeção ── */
  .question-row    { flex-direction: column !important; align-items: flex-start !important; gap: 0.5rem !important; }
  .answer-btns     { width: 100% !important; justify-content: stretch !important; }
  .answer-btns button { flex: 1 !important; padding: 0.7rem 0 !important; }

  /* ── Fotos ── */
  .fotos-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 0.4rem !important; }
  .foto-thumb { height: 90px !important; }

  /* ── NC cards ── */
  .nc-group-card { border-radius: 12px !important; }
  .nc-item {
    flex-direction: column !important;
    gap: 0.5rem !important;
    padding: 0.75rem !important;
  }
  .btn-abrir-trat {
    width: 100% !important;
    padding: 0.55rem 0 !important;
    text-align: center !important;
  }

  /* ── Seção ── */
  .section-header h1 { font-size: 1.2rem !important; }

  /* ── Modal de inspeção: bottom sheet ── */
  .insp-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .insp-modal-panel {
    border-radius: 18px 18px 0 0 !important;
    max-width: 100% !important;
    max-height: 90dvh !important;
  }
  .insp-modal-body { max-height: 55vh !important; }

  /* ── Modal de tratamento: bottom sheet ── */
  .trata-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .trata-panel {
    max-width: 100% !important;
    border-radius: 18px 18px 0 0 !important;
    max-height: 92dvh !important;
    padding: 1.25rem !important;
  }
}

/* ================================================================
   LOGIN PAGE (mobile)
   ================================================================ */
@media (max-width: 480px) {
  .login-wrapper { padding: 1.5rem 1rem !important; }
  .login-card    { border-radius: 16px !important; padding: 1.5rem !important; }
  .btn-entrar    { height: 50px !important; font-size: 1rem !important; }
  .btn-theme     { position: fixed; top: 0.75rem; right: 0.75rem; }
}

/* ================================================================
   SAFE AREA — iPhone notch / home indicator
   ================================================================ */
.sidebar {
  padding-top: max(1rem, env(safe-area-inset-top)) !important;
}
body { padding-bottom: env(safe-area-inset-bottom, 0); }
