/* ─── HIGIENIZA360 — PUBLIC CSS v3.1 ────────────────────────── */

/* ═══════════════════════════════════════════════════════════════
   NEUTRALIZAR TEMA WORDPRESS — ISSO É O QUE FAZIA O PAINEL
   ENCOLHER NO MOBILE. Força tela cheia em qualquer tema.
═══════════════════════════════════════════════════════════════ */

/* Remove padding/margin do tema nas páginas do sistema */
body:has(.crmh-wrap),
body:has(.crmh-login-wrap) {
  margin: 0 !important;
  padding: 0 !important;
  background: #071523 !important;
  overflow-x: hidden !important;
}

/* Neutraliza containers do tema (funciona em 99% dos temas WP) */
body:has(.crmh-wrap) .site,
body:has(.crmh-wrap) .site-content,
body:has(.crmh-wrap) #content,
body:has(.crmh-wrap) #primary,
body:has(.crmh-wrap) .entry-content,
body:has(.crmh-wrap) .post-content,
body:has(.crmh-wrap) article,
body:has(.crmh-wrap) .container,
body:has(.crmh-wrap) .wp-block-group,
body:has(.crmh-wrap) main,
body:has(.crmh-login-wrap) .site,
body:has(.crmh-login-wrap) .site-content,
body:has(.crmh-login-wrap) #content,
body:has(.crmh-login-wrap) #primary,
body:has(.crmh-login-wrap) .entry-content,
body:has(.crmh-login-wrap) article,
body:has(.crmh-login-wrap) .container,
body:has(.crmh-login-wrap) main {
  max-width: none !important;
  width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Esconde header/footer do tema nas páginas do sistema */
body:has(.crmh-wrap) .site-header,
body:has(.crmh-wrap) .site-footer,
body:has(.crmh-wrap) header.site-header,
body:has(.crmh-wrap) footer.site-footer,
body:has(.crmh-wrap) #masthead,
body:has(.crmh-wrap) #colophon,
body:has(.crmh-wrap) .wp-admin-bar,
body:has(.crmh-login-wrap) .site-header,
body:has(.crmh-login-wrap) .site-footer,
body:has(.crmh-login-wrap) #masthead,
body:has(.crmh-login-wrap) #colophon {
  display: none !important;
}

/* Barra admin do WordPress no topo */
#wpadminbar { display: none !important; }
html { margin-top: 0 !important; }

/* ═══════════════════════════════════════════════════════════════
   VARIÁVEIS
═══════════════════════════════════════════════════════════════ */
:root {
  --crmh-primary:   #185FA5;
  --crmh-primary2:  #0C447C;
  --crmh-teal:      #1D9E75;
  --crmh-amber:     #EF9F27;
  --crmh-red:       #E24B4A;
  --crmh-surface:   #071523;
  --crmh-surface2:  #0C1929;
  --crmh-surface3:  #0f2338;
  --crmh-surface4:  #162d47;
  --crmh-text:      #E6F1FB;
  --crmh-text2:     #85B7EB;
  --crmh-border:    rgba(55,138,221,0.18);
  --crmh-radius:    10px;
  --crmh-nav-h:     60px; /* altura da nav bottom no mobile */
}

/* ═══════════════════════════════════════════════════════════════
   RESET INTERNO
═══════════════════════════════════════════════════════════════ */
.crmh-wrap *, .crmh-login-wrap * {
  box-sizing: border-box;
}

/* Trava o painel contra scroll lateral acidental, mesmo se algum
   elemento interno calcular largura errada (proteção geral, todas as telas) */
.crmh-wrap, .crmh-login-wrap {
  overflow-x: hidden;
  max-width: 100%;
}

/* ═══════════════════════════════════════════════════════════════
   LAYOUT DESKTOP (≥ 769px)
═══════════════════════════════════════════════════════════════ */
.crmh-wrap {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background: var(--crmh-surface);
  color: var(--crmh-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  font-size: 14px;
  position: relative;
}

/* Sidebar */
.crmh-sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--crmh-surface2);
  border-right: 1px solid var(--crmh-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.crmh-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--crmh-border);
  font-weight: 600;
  font-size: 14px;
  min-height: 64px;
  overflow: hidden;
}
.crmh-logo span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.crmh-logo-text {
  width: 36px; height: 36px;
  background: var(--crmh-primary);
  color: #fff;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}
.crmh-logo img { width: 36px; height: 36px; border-radius: 9px; object-fit: cover; flex-shrink: 0; }

.crmh-nav { padding: 10px 8px; flex: 1; }
.crmh-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--crmh-text2);
  text-decoration: none;
  margin-bottom: 2px;
  transition: all 0.15s;
  font-size: 13.5px;
}
.crmh-nav-item:hover { background: var(--crmh-surface4); color: var(--crmh-text); }
.crmh-nav-item.active {
  background: var(--crmh-surface4);
  color: var(--crmh-text);
  border-left: 3px solid var(--crmh-primary);
  padding-left: 9px;
}

/* Content */
.crmh-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  min-width: 0;
}

.crmh-page-title {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 20px;
  color: var(--crmh-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.crmh-page-h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.crmh-page-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--crmh-text2);
  background: var(--crmh-surface4);
  border-radius: 20px;
  padding: 2px 9px;
}

/* ═══════════════════════════════════════════════════════════════
   CARDS DE ITEM (lista mobile — alternativa à tabela)
═══════════════════════════════════════════════════════════════ */
.crmh-cards-mobile { display: none; }
.crmh-item-card {
  padding: 14px;
  border-bottom: 1px solid var(--crmh-border);
}
.crmh-item-card:last-child { border-bottom: none; }
.crmh-item-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.crmh-item-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--crmh-text);
  text-decoration: none;
}
.crmh-item-card-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.crmh-item-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  gap: 10px;
}
.crmh-item-card-row > span:first-child { color: var(--crmh-text2); flex-shrink: 0; }
.crmh-item-card-row > span:last-child { text-align: right; }
.crmh-item-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.crmh-item-card-actions .crmh-btn { flex: 1; min-width: 0; }

/* ═══════════════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════════════ */
.crmh-card {
  background: var(--crmh-surface3);
  border: 1px solid var(--crmh-border);
  border-radius: var(--crmh-radius);
  padding: 16px;
  margin-bottom: 16px;
}
.crmh-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-weight: 500;
  gap: 10px;
  flex-wrap: wrap;
}

/* KPIs */
.crmh-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.crmh-kpi {
  background: var(--crmh-surface3);
  border: 1px solid var(--crmh-border);
  border-radius: var(--crmh-radius);
  padding: 14px 16px;
}
.crmh-kpi-label { font-size: 11px; color: var(--crmh-text2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.crmh-kpi-value { font-size: 22px; font-weight: 600; line-height: 1.2; }
.crmh-kpi-value.green  { color: #5DCAA5; }
.crmh-kpi-value.blue   { color: #378ADD; }
.crmh-kpi-value.amber  { color: var(--crmh-amber); }
.crmh-kpi-value.red    { color: var(--crmh-red); }

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════════ */
.crmh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  min-height: 42px;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.crmh-btn-primary { background: var(--crmh-primary); color: #E6F1FB; }
.crmh-btn-primary:hover, .crmh-btn-primary:active { background: var(--crmh-primary2); }
.crmh-btn-ghost { background: transparent; border: 1px solid var(--crmh-border); color: var(--crmh-text2); }
.crmh-btn-ghost:hover { background: var(--crmh-surface4); color: var(--crmh-text); }
.crmh-btn-green { background: #085041; color: #9FE1CB; }
.crmh-btn-green:hover { background: #0F6E56; }
.crmh-btn-red { background: #7a1f1f; color: #f5c2c2; }
.crmh-btn-sm { padding: 6px 12px; font-size: 12px; min-height: 32px; }

/* ═══════════════════════════════════════════════════════════════
   INPUTS
═══════════════════════════════════════════════════════════════ */
.crmh-input, .crmh-select, .crmh-textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--crmh-surface4);
  border: 1px solid var(--crmh-border);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--crmh-text);
  font-size: 16px; /* 16px previne zoom automático no iOS */
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.crmh-input:focus, .crmh-select:focus, .crmh-textarea:focus {
  border-color: var(--crmh-primary);
  box-shadow: 0 0 0 3px rgba(24,95,165,0.2);
}
.crmh-input::placeholder { color: var(--crmh-text2); }
.crmh-label { display: block; font-size: 12px; color: var(--crmh-text2); margin-bottom: 5px; font-weight: 500; }
.crmh-field { margin-bottom: 16px; }
.crmh-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.crmh-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.crmh-grid-2 > *, .crmh-grid-3 > * { min-width: 0; }

/* Inputs nativos de data/hora têm renderização própria do sistema
   operacional que às vezes ignora width:100%, causando overflow.
   Forçamos a largura real do container em todos os navegadores. */
.crmh-input[type="date"], .crmh-input[type="time"] {
  width: 100%;
  min-width: 0;
}

/* ═══════════════════════════════════════════════════════════════
   DROPDOWN DE BUSCA DE CLIENTE (substitui select nativo)
═══════════════════════════════════════════════════════════════ */
.crmh-cliente-dropdown {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 4px);
  z-index: 50;
  background: var(--crmh-surface3);
  border: 1px solid var(--crmh-border);
  border-radius: 10px;
  max-height: 260px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.crmh-cliente-opcao {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--crmh-border);
}
.crmh-cliente-opcao:last-child { border-bottom: none; }
.crmh-cliente-opcao:nth-child(even) { background: var(--crmh-surface4); }
.crmh-cliente-opcao:hover, .crmh-cliente-opcao.crmh-ativo {
  background: var(--crmh-primary);
}
.crmh-cliente-opcao:hover .crmh-cliente-opcao-nome,
.crmh-cliente-opcao:hover .crmh-cliente-opcao-tel,
.crmh-cliente-opcao.crmh-ativo .crmh-cliente-opcao-nome,
.crmh-cliente-opcao.crmh-ativo .crmh-cliente-opcao-tel {
  color: #E6F1FB;
}
.crmh-cliente-opcao-nome { color: var(--crmh-text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crmh-cliente-opcao-tel { color: var(--crmh-text2); font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.crmh-cliente-vazio { padding: 14px 12px; text-align: center; font-size: 13px; color: var(--crmh-text2); }

/* ═══════════════════════════════════════════════════════════════
   TABELAS
═══════════════════════════════════════════════════════════════ */
.crmh-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
/* alias usado nas views antigas */
.crmh-table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.crmh-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 540px; }
.crmh-table th { text-align: left; padding: 11px 12px; color: var(--crmh-text2); font-weight: 500; border-bottom: 1px solid var(--crmh-border); font-size: 12px; white-space: nowrap; }
.crmh-table td { padding: 11px 12px; border-bottom: 1px solid var(--crmh-border); }
.crmh-table tr:last-child td { border-bottom: none; }
.crmh-table tr:hover td { background: var(--crmh-surface4); }
.crmh-table a { color: var(--crmh-text); text-decoration: none; }
.crmh-table a:hover { color: #378ADD; }

/* ═══════════════════════════════════════════════════════════════
   BADGES
═══════════════════════════════════════════════════════════════ */
.crmh-badge { display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.crmh-badge-blue   { background: #0C447C; color: #B5D4F4; }
.crmh-badge-green  { background: #085041; color: #9FE1CB; }
.crmh-badge-amber  { background: #412402; color: #FAC775; }
.crmh-badge-red    { background: #791F1F; color: #f5c2c2; }
.crmh-badge-purple { background: #3C3489; color: #CECBF6; }

/* ═══════════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════════ */
.crmh-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 99999;
  display: flex !important;   /* sempre flex — o jQuery não pode mudar isso */
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  overflow-x: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.crmh-modal-overlay.crmh-modal-aberto {
  opacity: 1;
  pointer-events: auto;
}
.crmh-modal {
  background: var(--crmh-surface2);
  border: 1px solid var(--crmh-border);
  border-radius: 18px 18px 0 0; /* mobile: sheet de baixo */
  padding: 20px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  max-height: 92vh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.crmh-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  font-size: 17px;
  font-weight: 600;
}
.crmh-modal-close {
  background: var(--crmh-surface4);
  border: none;
  color: var(--crmh-text2);
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
/* Handle de arrasto (decorativo) */
.crmh-modal::before {
  content: '';
  display: block;
  width: 40px; height: 4px;
  background: var(--crmh-border);
  border-radius: 2px;
  margin: -8px auto 18px;
}
.crmh-modal-footer {
  display: flex;
  gap: 10px;
}
.crmh-modal-footer .crmh-btn-ghost { flex: 1; }
.crmh-modal-footer .crmh-btn-primary { flex: 2; }

/* ═══════════════════════════════════════════════════════════════
   ALERTS
═══════════════════════════════════════════════════════════════ */
.crmh-alert { padding: 14px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; line-height: 1.5; }
.crmh-alert-success { background: rgba(29,158,117,0.15); border: 1px solid #0F6E56; color: #5DCAA5; }
.crmh-alert-error   { background: rgba(226,75,74,0.12); border: 1px solid #791F1F; color: #f5a5a5; }
.crmh-alert-info    { background: rgba(55,138,221,0.12); border: 1px solid #0C447C; color: #85B7EB; }

/* ═══════════════════════════════════════════════════════════════
   LOGIN
═══════════════════════════════════════════════════════════════ */
.crmh-login-wrap {
  position: fixed;
  inset: 0;
  background: var(--crmh-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9999;
}
.crmh-login-card {
  background: var(--crmh-surface2);
  border: 1px solid var(--crmh-border);
  border-radius: 20px;
  padding: 32px 28px;
  width: 100%;
  max-width: 400px;
}

/* Orçamento público */
.crmh-orc-public {
  max-width: 720px;
  margin: 20px auto;
  padding: 16px;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE — ≤ 768px
   Navegação como barra inferior (estilo app nativo)
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Tela cheia — sem espaço desperdiçado */
  .crmh-wrap {
    flex-direction: column;
    width: 100vw;
    min-height: 100dvh; /* dvh = altura real da viewport no mobile */
    overflow-x: hidden;
  }

  /* Sidebar vira barra no topo (só logo + nome) */
  .crmh-sidebar {
    width: 100%;
    min-width: unset;
    height: auto;
    min-height: auto;
    position: sticky;
    top: 0;
    border-right: none;
    border-bottom: 1px solid var(--crmh-border);
    flex-direction: row;
    align-items: center;
    z-index: 200;
    overflow: visible;
  }
  .crmh-logo {
    padding: 12px 16px;
    border-bottom: none;
    flex: 1;
    min-height: unset;
  }

  /* Nav vira barra fixada na base da tela (estilo app) */
  .crmh-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: var(--crmh-surface2);
    border-top: 1px solid var(--crmh-border);
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-around;
    padding: 0;
    margin: 0;
    z-index: 9000;
    height: var(--crmh-nav-h);
    /* Safe area para iPhone com notch */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .crmh-nav-item {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 4px;
    margin: 0;
    border-radius: 0;
    font-size: 10px;
    text-align: center;
    min-width: 0;
    border-left: none !important;
  }
  .crmh-nav-item span:first-child { font-size: 20px; line-height: 1; }
  .crmh-nav-item.active {
    background: transparent;
    color: var(--crmh-primary);
    border-top: 2px solid var(--crmh-primary);
    padding-left: 4px;
  }
  .crmh-nav-item:hover { background: var(--crmh-surface4); }

  /* Conteúdo — padding no fundo para não ficar atrás da nav */
  .crmh-content {
    padding: 16px 14px;
    padding-bottom: calc(var(--crmh-nav-h) + env(safe-area-inset-bottom, 0px) + 16px);
    overflow-y: auto;
    flex: 1;
  }

  /* Grids ficam coluna única */
  .crmh-grid-2, .crmh-grid-3 { grid-template-columns: 1fr; gap: 10px; }

  /* KPIs 2 colunas no mobile */
  .crmh-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .crmh-kpi { padding: 12px; }
  .crmh-kpi-value { font-size: 18px; }

  .crmh-page-title { font-size: 17px; margin-bottom: 14px; }
  .crmh-page-h1 { font-size: 16px; }

  /* Botões de ação — largura total exceto sm */
  .crmh-btn:not(.crmh-btn-sm) { width: 100%; margin-bottom: 8px; }
  .crmh-page-title .crmh-btn { width: auto; margin-bottom: 0; }

  /* Rodapés de formulário/modal (Cancelar + Confirmar) empilham no
     mobile em vez de ficar lado a lado, para o texto nunca cortar. */
  .crmh-modal-footer { flex-direction: column !important; }
  .crmh-modal-footer .crmh-btn { flex: none !important; width: 100%; }

  /* Modal vira sheet bottom */
  .crmh-modal-overlay { align-items: flex-end; padding: 0; }
  .crmh-modal { border-radius: 20px 20px 0 0; max-height: 92dvh; }

  /* Listas: troca tabela com scroll lateral por cards empilhados */
  .crmh-card { padding: 12px; margin: 0 -14px 12px; border-radius: 0; border-left: none; border-right: none; }
  .crmh-table-container { display: none; }
  .crmh-table-wrap { display: none; }
  .crmh-cards-mobile { display: block; }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE PEQUENO — ≤ 390px (iPhone SE, Galaxy A)
═══════════════════════════════════════════════════════════════ */
@media (max-width: 390px) {
  .crmh-kpis { grid-template-columns: 1fr; }
  .crmh-kpi-value { font-size: 20px; }
  .crmh-nav-item span:last-child { display: none; } /* só ícone */
  .crmh-nav-item span:first-child { font-size: 22px; }
  .crmh-content { padding: 12px 10px calc(var(--crmh-nav-h) + 12px); }
}

/* ═══════════════════════════════════════════════════════════════
   DESKTOP MÉDIO — modal centralizado no centro da tela
═══════════════════════════════════════════════════════════════ */
@media (min-width: 769px) {
  .crmh-modal-overlay { align-items: center; padding: 20px; }
  .crmh-modal { border-radius: 16px; max-width: 560px; }
  .crmh-modal::before { display: none; }
}
