/* =============================================
   SHADOWPAY - RESPONSIVE GLOBAL CSS
   Este arquivo deve ser incluído em TODAS as páginas
   para garantir responsividade completa
   ============================================= */

/* ===== RESET E BASE RESPONSIVO ===== */
* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
video,
iframe {
  max-width: 100%;
  height: auto;
}

/* Previne zoom em inputs no iOS */
input,
select,
textarea {
  font-size: 16px !important;
}

@media (min-width: 769px) {
  input,
  select,
  textarea {
    font-size: inherit !important;
  }
}

/* ===== CONTAINERS RESPONSIVOS ===== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 12px;
  }
}

/* ===== GRID RESPONSIVO ===== */
.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -10px;
}

.col {
  flex: 1;
  padding: 0 10px;
}

@media (max-width: 768px) {
  .row {
    margin: 0 -8px;
  }

  .col {
    padding: 0 8px;
  }

  .col-mobile-full {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* ===== LAYOUTS RESPONSIVOS ===== */

/* Admin/Merchant Layout */
.admin-layout,
.merchant-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Responsivo */
.sidebar,
.merchant-sidebar {
  width: 280px;
  flex-shrink: 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 1000;
  transition: transform 0.3s ease;
}

.main-content,
.merchant-main {
  flex: 1;
  margin-left: 280px;
  min-height: 100vh;
  width: calc(100% - 280px);
}

@media (max-width: 1024px) {
  .sidebar,
  .merchant-sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
  }

  .sidebar.open,
  .merchant-sidebar.open {
    transform: translateX(0);
  }

  .main-content,
  .merchant-main {
    margin-left: 0;
    width: 100%;
  }
}

/* Overlay para menu mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
  display: block;
}

/* ===== TABELAS RESPONSIVAS ===== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 600px;
}

@media (max-width: 768px) {
  /* Card-style table for mobile */
  .table-mobile-cards thead {
    display: none;
  }

  .table-mobile-cards tbody tr {
    display: block;
    padding: 16px;
    margin-bottom: 12px;
    background: var(--sp-bg-card, #111);
    border-radius: 12px;
    border: 1px solid var(--sp-border, #1f1f1f);
  }

  .table-mobile-cards tbody td {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border: none;
  }

  .table-mobile-cards tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--sp-text-muted, #9ca3af);
  }
}

/* ===== CARDS RESPONSIVOS ===== */
.card {
  background: var(--sp-bg-card, #111);
  border: 1px solid var(--sp-border, #1f1f1f);
  border-radius: 16px;
  padding: 24px;
}

@media (max-width: 768px) {
  .card {
    padding: 16px;
    border-radius: 12px;
  }
}

@media (max-width: 480px) {
  .card {
    padding: 14px;
    border-radius: 10px;
  }
}

/* ===== GRIDS DE CARDS ===== */
.stats-grid,
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

@media (max-width: 1200px) {
  .stats-grid,
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .stats-grid,
  .cards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* ===== FORMULÁRIOS RESPONSIVOS ===== */
.form-row {
  display: flex;
  gap: 16px;
}

@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
    gap: 12px;
  }

  .form-row.keep-row {
    flex-direction: row;
  }
}

.form-group {
  margin-bottom: 16px;
}

@media (max-width: 768px) {
  .form-group {
    margin-bottom: 12px;
  }
}

/* ===== BOTÕES RESPONSIVOS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .btn {
    padding: 10px 18px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .btn {
    padding: 10px 16px;
    font-size: 12px;
  }

  .btn-full-mobile {
    width: 100%;
  }
}

/* Grupo de botões responsivo */
.btn-group {
  display: flex;
  gap: 12px;
}

@media (max-width: 480px) {
  .btn-group {
    flex-direction: column;
    gap: 8px;
  }

  .btn-group .btn {
    width: 100%;
  }

  .btn-group.keep-row {
    flex-direction: row;
  }
}

/* ===== MODAL RESPONSIVO ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--sp-bg-card, #111);
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

@media (max-width: 768px) {
  .modal {
    padding: 16px;
    align-items: flex-end;
  }

  .modal-content {
    border-radius: 16px 16px 0 0;
    max-height: 85vh;
  }
}

@media (max-width: 480px) {
  .modal {
    padding: 0;
  }

  .modal-content {
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
  }
}

/* ===== HEADER RESPONSIVO ===== */
.header,
.merchant-header,
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--sp-bg-card, #111);
  border-bottom: 1px solid var(--sp-border, #1f1f1f);
}

@media (max-width: 768px) {
  .header,
  .merchant-header,
  .admin-header {
    padding: 12px 16px;
  }

  .header-search {
    display: none;
  }

  .header-title {
    font-size: 1.125rem;
  }
}

/* ===== BOTÃO MENU MOBILE ===== */
.mobile-menu-btn {
  display: none;
  width: 44px;
  height: 44px;
  border: none;
  background: var(--sp-border, #1f1f1f);
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

@media (max-width: 1024px) {
  .mobile-menu-btn {
    display: flex;
  }
}

/* ===== TEXTOS RESPONSIVOS ===== */
h1 {
  font-size: clamp(1.75rem, 5vw, 3rem);
}

h2 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
}

h3 {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
}

p {
  font-size: clamp(0.875rem, 2vw, 1rem);
}

/* ===== UTILITÁRIOS RESPONSIVOS ===== */

/* Esconder em diferentes tamanhos */
@media (max-width: 1024px) {
  .hide-tablet {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .hide-small {
    display: none !important;
  }
}

/* Mostrar apenas em mobile */
.show-mobile {
  display: none !important;
}

@media (max-width: 768px) {
  .show-mobile {
    display: flex !important;
  }
}

/* Texto truncado */
.text-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== NAVEGAÇÃO RESPONSIVA ===== */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 16px 0;
  transition: all 0.3s;
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.nav-links {
  display: flex;
  gap: 32px;
}

.nav-actions {
  display: flex;
  gap: 12px;
}

@media (max-width: 1024px) {
  .nav-links {
    display: none;
  }
}

@media (max-width: 768px) {
  .nav-actions .btn-nav-secondary {
    display: none;
  }
}

/* Menu mobile dropdown */
.mobile-menu {
  display: none;
  position: fixed;
  top: 80px;
  left: 0;
  right: 0;
  background: var(--sp-bg-card, #111);
  border-bottom: 1px solid var(--sp-border, #1f1f1f);
  padding: 20px;
  z-index: 999;
}

.mobile-menu.active {
  display: block;
}

.mobile-menu a {
  display: block;
  padding: 12px 0;
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid var(--sp-border, #1f1f1f);
}

/* ===== DASHBOARD CONTENT ===== */
.dashboard-content,
.page-content {
  padding: 24px;
}

@media (max-width: 768px) {
  .dashboard-content,
  .page-content {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .dashboard-content,
  .page-content {
    padding: 12px;
  }
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 16px;
  }

  .page-header .btn {
    width: 100%;
  }
}

/* ===== TABS RESPONSIVOS ===== */
.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== FILTROS RESPONSIVOS ===== */
.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .filters {
    flex-direction: column;
  }

  .filters select,
  .filters input {
    width: 100%;
  }
}

/* ===== PAGINAÇÃO RESPONSIVA ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  .pagination {
    gap: 4px;
  }

  .pagination .page-numbers {
    display: none;
  }

  .pagination .page-prev,
  .pagination .page-next,
  .pagination .page-current {
    display: flex;
  }
}

/* ===== SAFE AREAS (iPhone notch) ===== */
@supports (padding-top: env(safe-area-inset-top)) {
  .nav {
    padding-top: calc(16px + env(safe-area-inset-top));
  }

  .sidebar,
  .merchant-sidebar {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .dashboard-content,
  .page-content {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .sidebar,
  .merchant-sidebar,
  .nav,
  .mobile-menu-btn,
  .btn {
    display: none !important;
  }

  .main-content,
  .merchant-main {
    margin-left: 0 !important;
    width: 100% !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
  }
}
