/* TradeAnalyzer v3 - ajustes de responsividade compartilhados (todas as páginas ta-*).
 * Camada por cima do tema NexLink: nada aqui muda o desktop, só protege telas menores/maiores. */

/* nunca deixar a PÁGINA rolar na horizontal (tabelas/gráficos rolam dentro do próprio card) */
html, body { max-width: 100%; overflow-x: clip; }
.app-wrapper, .container-fluid { min-width: 0; }
.row > [class*="col-"] { min-width: 0; }
.card, .card-body { min-width: 0; }
img, svg, video, canvas { max-width: 100%; }
.card-title, .card-header h5, .card-header h6, .app-page-head .breadcrumb-item { overflow-wrap: anywhere; }
.card-header { flex-wrap: wrap; row-gap: .5rem; }
.app-page-head { row-gap: .75rem; }
.app-page-head > * { min-width: 0; }

/* tabelas: DataTables e <table> soltas rolam dentro do card em vez de estourar a página */
.card-body:has(> table), .card-body:has(> .dt-container), .card-body:has(> .dataTables_wrapper) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dt-container .dt-layout-row:has(table), .dataTables_wrapper .dt-layout-row:has(table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive { -webkit-overflow-scrolling: touch; }
.table th, .table td { vertical-align: middle; }
.table-responsive > .table:not(.w-100) { min-width: 520px; }
#coMap, #wiHeat, #mcTbl { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }

/* gráficos: ApexCharts/Chart.js sempre dentro do card; legenda quebra linha */
.apexcharts-canvas, .apexcharts-svg { max-width: 100%; }
.apexcharts-legend { max-height: 90px; overflow-y: auto; }
.apexcharts-legend-text { font-size: 12px !important; }

/* favoritos da barra lateral: nunca colapsar a 0 em telas baixas (celular deitado) */
#taFavs > div { max-height: max(120px, calc(100dvh - 470px)) !important; }
.app-menubar-tabs, .app-menubar-tabs .app-tab-content { height: 100dvh; }

/* modais e avisos */
.modal-body { overflow-x: auto; }
.modal-footer { flex-wrap: wrap; gap: .5rem; }
#taToasts { max-width: min(360px, calc(100vw - 24px)); }

/* tela grande (>= 1920): limita a largura útil para o conteúdo não esticar demais */
@media (min-width: 2200px) {
  .app-wrapper > .container-fluid { max-width: 2000px; margin-inline: auto; }
}

/* tablet e abaixo */
@media (max-width: 991.98px) {
  .app-page-head { flex-direction: column; align-items: flex-start !important; }
  .app-page-head .btn, .app-page-head .dropdown { max-width: 100%; }
}

/* celular */
@media (max-width: 575.98px) {
  .modal-dialog { margin: .5rem; max-width: calc(100vw - 1rem); }
  .modal-dialog-centered { min-height: calc(100% - 1rem); }
  .modal-footer > .btn { flex: 1 1 auto; }
  #taToasts { left: 12px !important; right: 12px !important; top: 64px !important; max-width: none; }
  .app-wrapper .card-body { padding-left: .75rem; padding-right: .75rem; }
  .app-header .app-header-end { gap: 0; }
  .dropdown-menu.w-300px, .dropdown-menu[class*="w-3"] { width: min(300px, calc(100vw - 24px)) !important; }
  .dropdown-menu { max-width: calc(100vw - 16px); }
  .dt-container .dt-search, .dt-container .dt-length { width: 100%; }
  .dt-container .dt-search input { width: 100% !important; margin-left: 0 !important; }
  .dt-paging { display: flex; flex-wrap: wrap; justify-content: center; }
  .dt-info { text-align: center; width: 100%; }
  .text-3xs, .text-4xs { font-size: 11px !important; }
  /* iOS dá zoom em campos < 16px */
  .form-control, .form-select, .bootstrap-select > .dropdown-toggle { font-size: 16px; }
  h1, .h1 { font-size: 1.6rem; } h2, .h2 { font-size: 1.4rem; }
}

/* celular pequeno (360px) */
@media (max-width: 389.98px) {
  .app-wrapper { padding-left: 8px !important; padding-right: 8px !important; }
  .btn:not(.btn-icon) { padding-left: .75rem; padding-right: .75rem; }
}

/* toque (celular/tablet): alvos >= 44px */
@media (pointer: coarse) {
  .btn, .form-control, .form-select, .bootstrap-select > .dropdown-toggle { min-height: 44px; }
  .btn-icon { min-width: 44px; min-height: 44px; }
  .dropdown-item { padding-top: .6rem; padding-bottom: .6rem; }
  .page-link { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .form-check-input { width: 1.4em; height: 1.4em; }
  .nav-link, .menu-link { min-height: 44px; }
  .app-toggler { min-width: 44px; min-height: 44px; }
  .table td .btn, .table td .btn-icon { min-height: 36px; min-width: 36px; }
}

/* celular deitado (altura curta) */
@media (max-height: 480px) and (orientation: landscape) {
  .modal-dialog-scrollable .modal-content { max-height: calc(100dvh - 1rem); }
  .app-menubar-tabs .app-navbar-tabs { overflow-y: auto; }
}

/* modo app instalado (PWA): sem barra do navegador */
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
}
