/* ═══════════════════════════════════════════════════════════════════════════
   Modulo Service Orders — estilos compartilhados
   Doc: backend/docs/OS_INTEGRADA_DESIGN.md
   Convencao de prefixo: .so-* (Service Orders)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Container/seção de itens ─────────────────────────────────────────────── */
.so-itens-section {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fafbfc;
  margin: 8px 0;
}

.so-itens-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.so-itens-header strong {
  font-size: 13px;
  color: #1a237e;
}

.so-itens-help {
  font-size: 11px;
  color: #888;
  font-style: italic;
}

/* ── Barra de filtro de categoria (vem do tipo_servico) ─────────────────── */
.so-itens-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  margin: 0 0 8px 0;
  background: #e3f2fd;
  border: 1px solid #90caf9;
  border-radius: 4px;
  font-size: 12px;
}

.so-itens-filter-label {
  color: #0d47a1;
  font-weight: 600;
}

.so-itens-filter-clear {
  background: transparent;
  border: 1px solid #90caf9;
  color: #0d47a1;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}

.so-itens-filter-clear:hover {
  background: #bbdefb;
}

/* ── Linha de busca + dropdown ────────────────────────────────────────────── */
.so-itens-add-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 8px;
}

.so-itens-search-wrap {
  position: relative;
  flex: 1;
}

.so-itens-search {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #c5c5c5;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
  box-sizing: border-box;
}

.so-itens-search:focus {
  outline: none;
  border-color: #1565c0;
  box-shadow: 0 0 0 2px rgba(21, 101, 192, 0.15);
}

.so-itens-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 999;
  background: #fff;
  border: 1px solid #c5c5c5;
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.so-dropdown-item {
  padding: 7px 10px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  user-select: none;
}

.so-dropdown-item:hover { background: #e3f2fd; }
.so-dropdown-item:last-child { border-bottom: none; }

.so-dropdown-nome {
  font-size: 13px;
  font-weight: 600;
  color: #1a237e;
  pointer-events: none;
}

.so-dropdown-meta {
  font-size: 11px;
  color: #666;
  pointer-events: none;
}

.so-dropdown-empty {
  padding: 10px 12px;
  color: #888;
  font-size: 12px;
  font-style: italic;
}

/* ── Linhas de itens selecionados ─────────────────────────────────────────── */
.so-itens-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.so-iten-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid #d8d8d8;
  border-radius: 4px;
}

.so-iten-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.so-iten-nome {
  font-size: 13px;
  font-weight: 600;
  color: #1a237e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.so-iten-tag-ok,
.so-iten-tag-warn {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
  display: inline-block;
  width: fit-content;
}

.so-iten-tag-ok {
  background: #c8e6c9;
  color: #1b5e20;
}

.so-iten-tag-warn {
  background: #ffcdd2;
  color: #b71c1c;
}

.so-iten-qtd-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

.so-iten-qtd-wrap label {
  color: #555;
}

.so-iten-qtd {
  width: 56px;
  padding: 4px 6px;
  border: 1px solid #c5c5c5;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
}

.so-iten-unidade {
  font-size: 11px;
  color: #777;
  min-width: 18px;
}

.so-iten-remove {
  background: transparent;
  border: 1px solid #d8d8d8;
  color: #888;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.so-iten-remove:hover {
  background: #ffebee;
  color: #c62828;
  border-color: #ef9a9a;
}

/* ── Rodape ───────────────────────────────────────────────────────────────── */
.so-itens-footer {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed #ddd;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.so-itens-count {
  font-size: 11px;
  color: #666;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Modal "Confirmar Consumo" (Fase A.5)
   Reusa .ip-modal-overlay/.ip-modal-content para alinhar com o resto do app
   ═══════════════════════════════════════════════════════════════════════════ */
.so-confirm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.so-confirm-table thead th {
  background: #f5f7fa;
  text-align: left;
  padding: 8px 10px;
  font-size: 12px;
  color: #555;
  font-weight: 600;
  border-bottom: 1px solid #d8d8d8;
}

.so-confirm-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #efefef;
}

.so-confirm-table tbody tr:last-child td {
  border-bottom: none;
}

.so-confirm-nome {
  font-weight: 600;
  color: #1a237e;
  display: block;
}

.so-confirm-meta {
  font-size: 11px;
  color: #777;
  display: block;
  margin-top: 1px;
}

.so-confirm-num {
  text-align: center;
  font-weight: 600;
  color: #555;
}

.so-confirm-qtd {
  width: 64px;
  padding: 4px 8px;
  border: 1px solid #c5c5c5;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
}

.so-confirm-saldo-preview {
  text-align: center;
  font-weight: 600;
  color: #2e7d32;
}

.so-confirm-saldo-warn {
  color: #c62828 !important;
  background: #ffebee;
  border-radius: 4px;
}

#soConfirmConsumoObsWrap {
  margin-top: 12px;
}

#soConfirmConsumoObs {
  width: 100%;
  min-height: 50px;
  padding: 6px 8px;
  border: 1px solid #c5c5c5;
  border-radius: 4px;
  font-size: 13px;
  resize: vertical;
  box-sizing: border-box;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Timeline de Historico (Fase B.3)
   ═══════════════════════════════════════════════════════════════════════════ */
.so-hist-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.so-hist-item {
  border-left: 3px solid #ccc;
  padding: 8px 12px;
  margin-left: 8px;
  margin-bottom: 8px;
  background: #fafbfc;
  border-radius: 0 4px 4px 0;
}

.so-hist-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}

.so-hist-icone { font-size: 16px; }

.so-hist-user {
  color: #555;
  font-style: italic;
  font-size: 12px;
}

.so-hist-data {
  margin-left: auto;
  color: #888;
  font-size: 11px;
}

.so-hist-diff {
  margin-top: 4px;
  font-size: 12px;
  color: #444;
}

.so-hist-de {
  background: #ffebee;
  color: #b71c1c;
  padding: 1px 6px;
  border-radius: 3px;
  text-decoration: line-through;
}

.so-hist-para {
  background: #e8f5e9;
  color: #1b5e20;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
}

.so-hist-obs {
  margin-top: 4px;
  font-size: 12px;
  color: #555;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Popups flutuantes (Fase B.3 — sempre on por padrao para modais de OS)
   ═══════════════════════════════════════════════════════════════════════════
   .so-no-backdrop: remove backdrop escuro, mantem o conteudo na sua posicao.
                    Permite multiplos popups + interacao com o mapa.
   .so-floating   : posiciona no canto superior direito (modo compacto), util
                    para uso "ao lado do mapa" pelo botao Mostrar no Mapa.
*/
.ip-modal-overlay.so-no-backdrop {
  background: transparent;
  pointer-events: none;
}
.ip-modal-overlay.so-no-backdrop > .ip-modal-box {
  pointer-events: all;
  box-shadow: 0 14px 40px rgba(0,0,0,.35);
  /* Resize nativo do browser. min/max evitam o user perder o modal. */
  resize: both;
  overflow: hidden;
  min-width: 320px;
  min-height: 200px;
  max-width: 96vw;
  max-height: 92vh;
}
/* Header serve como dica visual de "arrastavel" (cursor) — quem clica no
   header tambem dispara o bring-to-front + pode arrastar via ModalDrag. */
.ip-modal-overlay.so-no-backdrop > .ip-modal-box > .ip-modal-header {
  cursor: move;
}

.ip-modal-overlay.so-floating {
  background: transparent;
  pointer-events: none;
  justify-content: flex-end;
  align-items: flex-start;
  padding: 80px 16px 16px 0;
}
.ip-modal-overlay.so-floating > .ip-modal-box {
  pointer-events: all;
  box-shadow: 0 12px 36px rgba(0,0,0,.35);
  width: 560px;
  max-height: 70vh;
}

.so-floating-toggle {
  background: transparent;
  border: 1px solid rgba(255,255,255,.4);
  color: #fff;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  margin-right: 6px;
}
.so-floating-toggle:hover { background: rgba(255,255,255,.15); }

/* ═══════════════════════════════════════════════════════════════════════════
   Inbox de OS (Fase B.1)
   ═══════════════════════════════════════════════════════════════════════════ */
.so-inbox-badge {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  background: #c62828;
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  vertical-align: middle;
}

.so-inbox-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.so-inbox-table thead th {
  background: #f5f7fa;
  color: #555;
  font-size: 11px;
  font-weight: 700;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 2px solid #d8d8d8;
}

.so-inbox-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

.so-inbox-table tbody tr:hover {
  background: #f8fbff;
}

.so-inbox-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.so-inbox-acoes {
  display: flex;
  flex-direction: row;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
}

.so-inbox-btn {
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.so-inbox-btn-mapa    { background: #1565c0; color: #fff; }
.so-inbox-btn-mapa:hover    { background: #0d47a1; }

.so-inbox-btn-editar  { background: #f57c00; color: #fff; }
.so-inbox-btn-editar:hover  { background: #e65100; }

.so-inbox-concluir,
.so-inbox-btn-concluir {
  background: #2e7d32;
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.so-inbox-concluir:hover,
.so-inbox-btn-concluir:hover { background: #1b5e20; }

.so-inbox-btn-cancelar {
  background: #c62828;
  color: #fff;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.so-inbox-btn-cancelar:hover { background: #8e1f1f; }

.so-inbox-btn-excluir {
  background: #424242;
  color: #fff;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.so-inbox-btn-excluir:hover { background: #b71c1c; }

.so-iposx-btn-cancelar,
.so-iposx-btn-reabrir {
  background: transparent;
  border: 1px solid rgba(255,255,255,.4);
  color: #fff;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}
.so-iposx-btn-cancelar:hover { background: #c62828; border-color: #c62828; }
.so-iposx-btn-reabrir:hover  { background: #2e7d32; border-color: #2e7d32; }

/* Badge "itens" e botao Concluir na lista de OS */
.ip-os-itens-badge {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: #fff3e0;
  color: #e65100;
  font-weight: 700;
  vertical-align: middle;
}

.ip-os-btn-concluir {
  background: #2e7d32;
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.ip-os-btn-concluir:hover {
  background: #1b5e20;
}

.ip-os-btn-concluir:disabled {
  background: #aaa;
  cursor: not-allowed;
}

/* Botao Excluir (admin only) na lista IP de OS */
.ip-os-btn-excluir-row {
  background: #424242;
  color: #fff;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-left: 2px;
}
.ip-os-btn-excluir-row:hover { background: #b71c1c; }

.ip-os-btn-mapa-row {
  background: #1565c0;
  color: #fff;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-right: 2px;
}
.ip-os-btn-mapa-row:hover { background: #0d47a1; }
