/**
 * Shelby ERP - Mobile High Density & Native Mobile Patterns
 * Resolução alvo: 390px (iPhone / Android) até 768px (Tablets / Coletores)
 * Camada: Astryx High Density Mobile Utilities
 */

/* 1. Barra de Busca Unificada Mobile */
.search-bar-unified {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: var(--color-background-surface, #ffffff);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 8px;
  padding: 4px 8px;
  min-height: 38px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.search-bar-unified:focus-within {
  border-color: #25D366;
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.16);
}

.search-bar-unified .search-icon {
  width: 16px;
  height: 16px;
  stroke: #94a3b8;
  flex-shrink: 0;
}

.search-bar-unified input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 4px 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text-primary, #0f172a);
  outline: none;
  min-width: 0;
}

.search-bar-unified input::placeholder {
  color: #94a3b8;
}

.search-bar-unified .btn-scan,
.search-bar-unified .btn-clear {
  background: transparent;
  border: none;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  cursor: pointer;
  border-radius: 4px;
  min-width: 28px;
  min-height: 28px;
  transition: all 0.15s ease;
}

.search-bar-unified .btn-scan:hover,
.search-bar-unified .btn-clear:hover {
  background: #f1f5f9;
  color: #0f172a;
}

/* 2. Chips / Tags de Filtros Ativos */
.filter-chips-container {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.filter-chips-container::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 3px 8px;
  border-radius: 14px;
  font-size: 11.5px;
  font-weight: 500;
  color: #334155;
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-chip-remove {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  border-radius: 50%;
  padding: 1px;
}

.filter-chip-remove:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* 3. Bottom Sheet / Gaveta Deslizante de Filtros & Ações */
.bottom-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.bottom-sheet-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-background-surface, #ffffff);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  z-index: 1060;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
  box-sizing: border-box;
}

.bottom-sheet.show {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  background: #cbd5e1;
  border-radius: 2px;
  margin: 8px auto 4px auto;
  flex-shrink: 0;
}

.bottom-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 10px 16px;
  border-bottom: 1px solid var(--color-border, #e2e8f0);
}

.bottom-sheet-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-primary, #0f172a);
}

.bottom-sheet-body {
  padding: 14px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bottom-sheet-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--color-border, #e2e8f0);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* 4. Cards Verticais Densos de Dados (Mobile Data Card) */
.mobile-cards-list {
  display: none;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.mobile-data-card {
  background: var(--color-background-surface, #ffffff);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: transform 0.1s ease, border-color 0.15s ease;
  box-sizing: border-box;
}

.mobile-data-card:active {
  background-color: #f8fafc;
  transform: scale(0.99);
}

.mobile-data-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.mobile-data-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary, #0f172a);
  line-height: 1.3;
}

.mobile-data-card-sub {
  font-size: 11.5px;
  color: var(--color-text-secondary, #64748b);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.mobile-data-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #f1f5f9;
  padding-top: 6px;
  margin-top: 2px;
}

.mobile-data-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 5. Sticky Bottom Action Bar */
.sticky-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-background-surface, #ffffff);
  border-top: 1px solid var(--color-border, #e2e8f0);
  padding: 8px 16px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 990;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

/* 6. Media Queries para Alternância Desktop vs Mobile */
@media (max-width: 768px) {
  /* Ocultar tabela tradicional quando houver cards mobile disponíveis */
  .table-responsive-desktop {
    display: none !important;
  }
  .mobile-cards-list {
    display: flex !important;
  }
  
  /* Filtros horizontais do desktop colapsam para o botão de bottom sheet */
  .desktop-filter-row {
    display: none !important;
  }
  .mobile-filter-trigger {
    display: flex !important;
  }
  
  /* Ajuste de padding de containers no mobile */
  .content-body, .main-content {
    padding: 10px 8px !important;
    padding-bottom: 72px !important; /* Espaço para barra inferior */
  }

  /* Botões com área de toque mínima de 36px no celular */
  .btn, .btn-primary, .btn-secondary, .btn-ghost {
    min-height: 36px !important;
    font-size: 12.5px !important;
  }
}

@media (min-width: 769px) {
  .mobile-filter-trigger {
    display: none !important;
  }
  .mobile-cards-list {
    display: none !important;
  }
}

.table-container { padding-bottom: 24px !important; margin-bottom: 24px !important; }
