/* Responsive Mobile UX Styles for SysJardel ERP */

@media (max-width: 1024px) {
  .sidebar {
    width: 210px;
  }

  .kanban-col {
    min-width: 270px;
    max-width: 270px;
  }
}

@media (max-width: 768px) {
  /* Layout Base */
  body {
    flex-direction: column;
    overflow-x: hidden;
  }

  #app {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }

  /* Mobile Top Navigation Sidebar */
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #1e293b;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  }

  .sidebar-header {
    padding: 10px 14px;
    justify-content: space-between;
  }

  .nav-menu {
    display: flex;
    overflow-x: auto;
    padding: 6px 10px;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
  }

  .nav-menu::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
  }

  .nav-group-title {
    display: none;
  }

  .nav-item {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 6px;
    border-left: none !important;
  }

  .nav-item.active {
    background-color: rgba(59, 130, 246, 0.25);
    color: #60a5fa;
    font-weight: 700;
  }

  /* Top Header & Search Actions */
  .top-header {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 14px;
    gap: 10px;
    background: #0f172a;
  }

  .header-actions {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .header-actions::-webkit-scrollbar {
    display: none;
  }

  .header-actions .btn {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 12px;
    flex-shrink: 0;
  }

  .header-search {
    width: 100%;
  }

  .header-search input {
    font-size: 14px; /* Prevents auto-zoom on iOS */
    padding: 10px 12px 10px 36px;
  }

  /* Main View Container */
  .content-area {
    padding: 12px;
    overflow-y: visible;
  }

  .section-title-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }

  .section-title-bar h2 {
    font-size: 18px;
  }

  /* Data Tables Mobile Optimization */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
  }

  .data-table th, .data-table td {
    padding: 8px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* Modals Mobile Touch Experience */
  .modal-content {
    width: 95vw !important;
    max-width: 100% !important;
    max-height: 90vh !important;
    margin: 12px auto;
    padding: 16px !important;
    border-radius: 12px !important;
    overflow-y: auto;
  }

  /* MODAL TABS HORIZONTAL SCROLL FOR MOBILE */
  .modal-tabs {
    display: flex !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    gap: 6px !important;
    padding-bottom: 10px !important;
    margin-bottom: 16px !important;
    border-bottom: 2px solid var(--border-color) !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .modal-tabs::-webkit-scrollbar {
    display: none;
  }

  .modal-tabs .tab-btn {
    flex-shrink: 0 !important;
    padding: 8px 14px !important;
    font-size: 13px !important;
    border-radius: 6px !important;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .form-grid > div {
    grid-column: span 1 !important;
  }

  .form-group input, 
  .form-group select, 
  .form-group textarea {
    font-size: 14px !important; /* Prevents auto-zoom on mobile */
    padding: 10px 12px !important;
    min-height: 42px;
  }

  .modal-footer {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .modal-footer .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 14px;
  }

  /* AUTOMAÇÃO WHATSAPP VIEW MOBILE OPTIMIZATION */
  #view-whatsapp div[style*="display:grid"],
  #view-whatsapp div[style*="display: grid"] {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  #view-whatsapp div[style*="grid-template-columns: 1fr 120px 120px"],
  #view-whatsapp div[style*="grid-template-columns:1fr 120px 120px"] {
    grid-template-columns: 1fr !important;
  }

  /* Kanban Mobile Touch Swipe */
  .kanban-board {
    height: auto;
    min-height: 480px;
    padding-bottom: 24px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .kanban-col {
    min-width: 82vw;
    max-width: 85vw;
    scroll-snap-align: start;
  }
}

/* Mobile Small Devices (Phones < 576px) */
@media (max-width: 576px) {
  /* Pagination Controls Stacking */
  #clients-pagination,
  #finance-pagination {
    flex-direction: column !important;
    align-items: center !important;
    gap: 10px !important;
    text-align: center !important;
    padding: 12px !important;
  }

  #clients-pagination > div,
  #finance-pagination > div {
    width: 100%;
    justify-content: space-between;
  }

  #clients-prev-btn, #clients-next-btn,
  #finance-prev-btn, #finance-next-btn {
    flex: 1;
    padding: 8px 12px !important;
    font-size: 13px !important;
  }
}
