/* ============================================================
   MOBILE / UTILITIES — Tema Escuro Imper Credi Brasil
   ============================================================ */

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--color-surface); }
::-webkit-scrollbar-thumb { background: var(--color-surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-brand-gold-dark); }

/* === STAT GRID (responsivo) === */
@media (max-width: 600px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-col-4, .grid-col-6, .grid-col-8, .grid-col-12 { grid-column: 1 / -1; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-height: 92vh; max-width: 100%; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header-actions { width: 100%; }
}

/* === UTILITIES === */
.text-center    { text-align: center; }
.text-right     { text-align: right; }
.text-muted     { color: var(--color-text-muted); }
.text-success   { color: var(--color-success); }
.text-danger    { color: var(--color-danger); }
.text-warning   { color: var(--color-warning); }
.text-gold      { color: var(--color-brand-gold); }
.text-sm        { font-size: var(--font-size-sm); }
.text-xs        { font-size: var(--font-size-xs); }
.font-bold      { font-weight: var(--font-weight-bold); }
.font-semibold  { font-weight: var(--font-weight-semibold); }
.d-flex         { display: flex; }
.align-center   { align-items: center; }
.justify-between{ justify-content: space-between; }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.mb-2   { margin-bottom: var(--space-2); }
.mb-3   { margin-bottom: var(--space-3); }
.mb-4   { margin-bottom: var(--space-4); }
.mb-5   { margin-bottom: var(--space-5); }
.mb-6   { margin-bottom: var(--space-6); }
.mt-4   { margin-top: var(--space-4); }
.mt-6   { margin-top: var(--space-6); }
.p-4    { padding: var(--space-4); }
.p-5    { padding: var(--space-5); }
.hidden { display: none !important; }
.w-100  { width: 100%; }
.cursor-pointer { cursor: pointer; }
.flex-1 { flex: 1; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link   { color: var(--color-brand-gold); cursor: pointer; }
.link:hover { text-decoration: underline; }

/* ============================================================
   GRUPO 48 (2026-10-10) — CELULARES (360px a 430px)
   ------------------------------------------------------------
   Causa principal do "dashboard cortando / precisa diminuir o zoom /
   menu flutuando": cards de números em 2 colunas sem limite de largura
   (o conteúdo empurrava a coluna para fora da tela). Com a página mais
   larga que o celular, o navegador deixava arrastar para o lado e o
   menu fixo parecia "solto". Aqui: nada passa da largura da tela.
   ============================================================ */

/* Rede de segurança: a página nunca rola para o lado */
html { overflow-x: hidden; }
body { overflow-x: clip; }
img, svg, video, canvas { max-width: 100%; }

/* Cabeçalho de card quebra linha (título + botões de filtro) */
.card-header { flex-wrap: wrap; row-gap: 8px; }
.card-title { min-width: 0; overflow-wrap: anywhere; }
.period-pills { display: flex; gap: 6px; flex-wrap: wrap; }

/* Painel Financeiro */
.fin-body { padding: 16px; }
.fin-section-title { font-size: 11px; font-weight: 700; color: #888; text-transform: uppercase; letter-spacing: 1px; margin: 4px 0 10px; }
.fin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; margin-bottom: 20px; }
.fin-grid:last-of-type { margin-bottom: 0; }
.fin-box { background: #1a1a1a; border-radius: 10px; padding: 14px; min-width: 0; }
.fin-box-title { font-size: 11px; font-weight: 700; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 1px; }
.fin-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12px; padding: 3px 0; }
.fin-row span { color: #888; min-width: 0; }
.fin-row strong { font-weight: 700; white-space: nowrap; }
.fin-total { border-top: 1px solid #2a2a2a; margin-top: 6px; padding-top: 8px; }

/* Cards de números: colunas nunca mais largas que a tela */
.stat-grid, .stats-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.stat-card { min-width: 0; }
.stat-label { overflow-wrap: anywhere; }
.stat-value { overflow-wrap: anywhere; }

/* Rodapé das janelas: botões quebram linha em vez de sumir pela esquerda */
.modal-footer { flex-wrap: wrap; }
.modal { max-width: min(540px, 100%); }
.modal-lg { max-width: min(720px, 100%); }
.modal-body { overflow-wrap: anywhere; }

/* Menu lateral (equipe): altura real da tela no celular (barra do navegador) */
.adm-sidebar { height: 100vh; height: 100dvh; }

/* Aviso "Instale o app" nunca fica por cima das janelas (PIX, cobrança...) */
.ios-install-banner { z-index: 150; }
body:has(.modal-backdrop) .ios-install-banner,
body:has(.modal-backdrop) #push-offer { display: none !important; }

/* iPhone com entalhe / barra de gestos: cabeçalho e menu de baixo
   encostam nas bordas certas (o app instalado usa a tela inteira) */
.adm-topbar, .topbar { padding-top: env(safe-area-inset-top, 0px); height: calc(56px + env(safe-area-inset-top, 0px)); }
@media (max-width: 1024px) {
  .bottom-nav { padding-bottom: env(safe-area-inset-bottom, 0px); height: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .main-with-bottomnav { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 768px) {
  .ios-install-banner { bottom: calc(var(--bottom-nav-height, 64px) + env(safe-area-inset-bottom, 0px) + 12px); }
}

/* Caixa de avisos (sininho) — Grupo 48 */
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid #2a2a2a; }
.notif-head-title { font-size: 13px; font-weight: 700; color: #f0f0f0; }
.notif-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.notif-action { background: #1f1f1f; border: 1px solid #333; color: #c9a84c; border-radius: 6px; padding: 5px 9px; font-size: 11px; cursor: pointer; white-space: nowrap; }
.notif-action:hover { border-color: #c9a84c; }
.notif-action.danger { color: #f87171; }
.notif-section { padding: 8px 14px; border-bottom: 1px solid #2a2a2a; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #888; }
.notif-section.gold { color: #c9a84c; }
.inbox-item { padding: 10px 14px; border-bottom: 1px solid #222; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; }
.inbox-item.unread { background: rgba(201,168,76,.07); }
.inbox-item:hover { background: #202020; }
.inbox-dot { width: 7px; height: 7px; border-radius: 50%; background: #c9a84c; margin-top: 6px; flex-shrink: 0; }
.inbox-dot.read { background: transparent; }
.inbox-main { flex: 1; min-width: 0; }
.inbox-top { display: flex; justify-content: space-between; gap: 8px; }
.inbox-title { font-size: 12.5px; font-weight: 600; color: #f0f0f0; line-height: 1.35; min-width: 0; overflow-wrap: anywhere; }
.inbox-time { font-size: 10px; color: #666; white-space: nowrap; padding-top: 2px; }
.inbox-body { font-size: 12px; color: #aaa; line-height: 1.4; margin-top: 2px; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.inbox-push { padding: 10px 14px; border-top: 1px solid #2a2a2a; font-size: 11px; color: #888; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.notif-task { padding: 10px 14px; border-bottom: 1px solid #222; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.notif-task:hover { background: #202020; }
.notif-task-icon { font-size: 16px; flex-shrink: 0; }
.notif-task-text { font-size: 12px; color: #d0d0d0; line-height: 1.4; min-width: 0; overflow-wrap: anywhere; }
.av-item .inbox-body { -webkit-line-clamp: 4; }
.av-del { background: none; border: none; color: #666; cursor: pointer; font-size: 14px; padding: 0 2px; flex-shrink: 0; }
.av-del:hover { color: #f87171; }

/* Configurações — Grupo 48 */
.cfg-section { margin-bottom: 20px; }
.cfg-section:last-child { margin-bottom: 0; }
.cfg-section-title { font-size: 12px; font-weight: 700; color: #c9a84c; text-transform: uppercase; letter-spacing: 1px; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid #222; }
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 0 16px; }
.cfg-grid .form-group { min-width: 0; }
.cfg-grid .cfg-full { grid-column: 1 / -1; }
.cfg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.cfg-check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 6px 0; cursor: pointer; color: #ddd; }
.cfg-check input { width: 18px; height: 18px; min-height: 0; flex-shrink: 0; }
.cfg-module { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; padding: 12px; background: #1c1c1c; border-radius: 10px; border: 1px solid #2a2a2a; }
.cfg-module input { width: 18px; height: 18px; min-height: 0; accent-color: #c8102e; flex-shrink: 0; margin-top: 2px; }
.cfg-backup { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.cfg-backup-text { flex: 1 1 260px; min-width: 0; font-size: 13px; color: #aaa; line-height: 1.5; }

@media (max-width: 768px) {
  /* Caixa de avisos ocupa a largura do celular, logo abaixo do cabeçalho */
  #notification-dropdown, #client-notif-dropdown, #partner-notif-dropdown {
    position: fixed !important;
    left: 8px !important; right: 8px !important;
    top: calc(56px + env(safe-area-inset-top, 0px) + 4px) !important;
    width: auto !important; max-width: none !important;
    max-height: calc(100dvh - 56px - env(safe-area-inset-top, 0px) - 24px);
    overflow: hidden;
  }
  #notification-list, #client-notif-list, #partner-notif-list {
    max-height: calc(100dvh - 160px - env(safe-area-inset-top, 0px)) !important;
    -webkit-overflow-scrolling: touch;
  }
  .page-header-actions .btn { flex: 1 1 auto; }
}

@media (max-width: 600px) {
  .adm-content { padding: 12px; }
  .main-with-bottomnav #page-content, .main-with-bottomnav .page-content { padding: 12px; }
  .card-header { padding: 12px 14px; }
  .card-body { padding: 14px; }
  .card-body.p-0, .card-body[style*="padding:0"] { padding: 0; }
  .stat-grid, .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 12px; gap: 10px; border-radius: 12px; }
  .stat-icon { width: 34px; height: 34px; font-size: 16px; border-radius: 8px; }
  .stat-label { font-size: 10px; letter-spacing: .3px; }
  .stat-value { font-size: clamp(15px, 4.6vw, 19px); }
  .stat-sub { font-size: 10px; }
  .page-title { font-size: 19px; overflow-wrap: anywhere; }
  .btn { white-space: normal; text-align: center; line-height: 1.2; }
  .modal-header { padding: 14px 16px; }
  .modal-title { font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); gap: 8px; }
  .modal-footer > .btn { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .modal { max-height: 92dvh; }
  .data-table th, .data-table td { padding: 10px 10px; }
  .data-table td { font-size: 12.5px; }
  .table-toolbar { flex-wrap: wrap; }
  .table-search { min-width: 0; width: 100%; }
  .table-pagination { flex-wrap: wrap; gap: 8px; }
  .detail-label { width: 42%; }
  .tabs { margin-left: -12px; margin-right: -12px; padding: 0 12px; }
  .action-buttons .btn { min-height: 44px; }
  .toast-container { left: 12px; right: 12px; top: calc(8px + env(safe-area-inset-top, 0px)); }
}

@media (max-width: 380px) {
  .stat-card { flex-direction: column; gap: 8px; }
  .stat-icon { width: 30px; height: 30px; font-size: 15px; }
  .modal-footer > .btn { flex-basis: 100%; }
}

/* Telas sem cabeçalho fixo (login) também respeitam o entalhe do iPhone */
.login-page { padding-top: max(16px, env(safe-area-inset-top, 0px)); padding-bottom: max(16px, env(safe-area-inset-bottom, 0px)); }
.landing-header { padding-top: env(safe-area-inset-top, 0px); }

/* Botão do WhatsApp some enquanto uma janela ou a caixa de avisos está aberta */
body:has(.modal-backdrop) #wa-float-btn,
body:has(#notification-dropdown[style*="block"]) #wa-float-btn,
body:has(#client-notif-dropdown[style*="block"]) #wa-float-btn,
body:has(#partner-notif-dropdown[style*="block"]) #wa-float-btn,
body:has(.adm-sidebar.open) #wa-float-btn { display: none !important; }

/* Grupo 50 (2026-10-12): menu lateral da equipe no iPhone/Android com tela
   infinita — a logo e o nome ficavam ATRÁS do relógio/entalhe. Agora o topo
   do menu desce o tamanho da área do sistema (no computador isso vale 0). */
.adm-sidebar-header {
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-left: calc(16px + env(safe-area-inset-left, 0px));
}
.adm-sidebar-footer { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
