/* ============================================================
   ProFin — Mobile UI Enhancements
   Breakpoint: max-width 1023px (Tailwind max-lg)
   Filosofia: apenas adiciona estilos mobile sem sobrescrever desktop.
   ============================================================ */

@media (max-width: 1023px) {

  /* ----------------------------------------------------------
     TRANSAÇÕES: ocultar a tabela (não o wrapper), exibir cards
     A paginação permanece visível pois fica dentro do wrapper.
  ---------------------------------------------------------- */
  #txn-table-wrapper > .overflow-x-auto {
    display: none !important;
  }

  #txn-mobile-cards {
    display: flex !important;
    flex-direction: column;
    gap: 8px;
  }

  /* ----------------------------------------------------------
     CARD de transação
  ---------------------------------------------------------- */
  .txn-mc {
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    border: 1px solid rgb(226 232 240);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  }

  .txn-mc-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
  }

  .txn-mc-badge-wrap {
    flex: 1;
    min-width: 0;
  }

  .txn-mc-amount {
    font-weight: 600;
    font-size: 0.9375rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .txn-mc-body {
    margin-left: 24px;
    margin-bottom: 8px;
  }

  .txn-mc-desc {
    font-size: 0.875rem;
    font-weight: 500;
    color: rgb(51 65 85);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    margin: 0;
  }

  .txn-mc-meta {
    font-size: 0.75rem;
    color: rgb(100 116 139);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 0;
  }

  .txn-mc-date {
    font-size: 0.75rem;
    color: rgb(148 163 184);
    margin-top: 2px;
    margin-bottom: 0;
  }

  .txn-mc-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgb(241 245 249);
  }

  .txn-mc-btn-edit,
  .txn-mc-btn-del {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: rgb(241 245 249);
    color: rgb(71 85 105);
    transition: background-color 0.15s, color 0.15s;
  }

  .txn-mc-btn-edit:hover,
  .txn-mc-btn-edit:active {
    background: rgb(219 234 254);
    color: rgb(37 99 235);
  }

  .txn-mc-btn-del:hover,
  .txn-mc-btn-del:active {
    background: rgb(254 226 226);
    color: rgb(220 38 38);
  }

  /* ----------------------------------------------------------
     TOOLBAR: quebra em linha se necessário
  ---------------------------------------------------------- */
  #txn-toolbar {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  /* ----------------------------------------------------------
     BATCH TOOLBAR: quebra em linha se necessário
  ---------------------------------------------------------- */
  #txn-batch-toolbar {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  /* ----------------------------------------------------------
     PAGINAÇÃO: centraliza e quebra em linha
  ---------------------------------------------------------- */
  #txn-pagination {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }

  #txn-pagination > span {
    width: 100%;
    text-align: center;
  }

  /* ----------------------------------------------------------
     HEADER TRANSAÇÕES: oculta subtítulo em mobile
     (igual ao que o Dashboard já faz com max-lg:hidden)
  ---------------------------------------------------------- */
  #page-transacoes header p,
  #page-faturas header p {
    display: none !important;
  }

  /* ----------------------------------------------------------
     SCROLL: evita que o conteúdo scrollado fique atrás do header
  ---------------------------------------------------------- */
  #page-transacoes .overflow-y-auto {
    scroll-padding-top: 3.5rem;
  }

  /* ----------------------------------------------------------
     CONTEÚDO: padding-bottom para não ficar atrás da bottom nav
     A bottom nav tem ~56px + safe-area-inset-bottom.
     Aplicado com ID específico para garantir especificidade.
  ---------------------------------------------------------- */
  #page-transacoes .flex-1.overflow-y-auto,
  #page-dashboard .flex-1.overflow-y-auto,
  #page-contas .flex-1.overflow-y-auto,
  #page-faturas .flex-1.overflow-y-auto,
  #page-categorias .flex-1.overflow-y-auto,
  #page-configuracoes .flex-1.overflow-y-auto {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* ----------------------------------------------------------
     DROPDOWNS DE FILTRO E COLUNAS: position fixed para não ser
     cortado pelo container overflow-y-auto do conteúdo.
  ---------------------------------------------------------- */
  #txn-filters-dropdown,
  #txn-columns-dropdown {
    position: fixed !important;
    top: 4rem !important;
    right: 1rem !important;
    left: 1rem !important;
    width: auto !important;
    max-width: none !important;
    max-height: 80vh !important;
    overflow-y: auto !important;
    z-index: 200 !important;
  }

}

/* ----------------------------------------------------------
   Dark mode — cards
---------------------------------------------------------- */
@media (max-width: 1023px) {
  html.dark .txn-mc {
    background: rgba(30, 41, 59, 0.85);
    border-color: rgb(51 65 85);
  }

  html.dark .txn-mc-desc {
    color: rgb(203 213 225);
  }

  html.dark .txn-mc-meta {
    color: rgb(148 163 184);
  }

  html.dark .txn-mc-date {
    color: rgb(100 116 139);
  }

  html.dark .txn-mc-actions {
    border-color: rgb(30 41 59);
  }

  html.dark .txn-mc-btn-edit,
  html.dark .txn-mc-btn-del {
    background: rgb(30 41 59);
    color: rgb(148 163 184);
  }

  html.dark .txn-mc-btn-edit:hover,
  html.dark .txn-mc-btn-edit:active {
    background: rgba(59, 130, 246, 0.1);
    color: rgb(96 165 250);
  }

  html.dark .txn-mc-btn-del:hover,
  html.dark .txn-mc-btn-del:active {
    background: rgba(239, 68, 68, 0.1);
    color: rgb(248 113 113);
  }
}
