/* =========================================================================
   LORDS — Responsive / Mobile Styles
   Include AFTER all other CSS files in every page.
   RULE: Only @media queries — desktop appearance MUST NOT change.
   ========================================================================= */

/* ─── MOBILE HEADER BAR ─────────────────────────────────────────────────── */
/* Created dynamically by mobile-menu.js for CRM & admin pages.            */

.mobile-header {
  display: none;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.visible {
  display: block;
  opacity: 1;
}

/* Landing page: login link cloned into mobile nav (created by mobile-menu.js) */
.mobile-nav-login {
  display: none !important;
}

/* ─── 768px — TABLET / MOBILE ────────────────────────────────────────────── */

@media screen and (max-width: 768px) {

  /* ── Mobile header bar ── */
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: #0D1117;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 0;
    z-index: 50;
  }

  .mobile-hamburger {
    background: none;
    border: none;
    color: #FFFFFF;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-logo {
    height: 32px;
    width: auto;
    object-fit: contain;
  }

  .mobile-header-spacer {
    flex: 1;
  }

  /* ── Portal sidebar: override display:none → use transform slide-in ── */
  .portal-sidebar {
    display: flex !important;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    width: 280px;
  }

  .portal-sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Force expanded state on mobile (ignore collapsed class) */
  .portal-sidebar.collapsed {
    width: 280px;
  }

  .portal-sidebar.collapsed .ps-nav-label {
    opacity: 1;
    height: auto;
    padding: 0.75rem 1rem 0.25rem;
    overflow: visible;
  }

  .portal-sidebar.collapsed .ps-nav-item span {
    opacity: 1;
    pointer-events: auto;
  }

  .portal-sidebar.collapsed .ps-user-email {
    opacity: 1;
    height: auto;
    margin-bottom: 0.5rem;
    overflow: hidden;
  }

  .portal-sidebar.collapsed .ps-logout-btn span {
    opacity: 1;
  }

  .portal-sidebar.collapsed .ps-logout-btn {
    justify-content: flex-start;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .portal-sidebar.collapsed .ps-brand img {
    height: 44px;
  }

  .portal-sidebar.collapsed .ps-badge {
    position: static;
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    font-size: 0.625rem;
    padding: 0 5px;
  }

  .portal-sidebar.collapsed .ps-toggle i {
    transform: none;
  }

  /* Hide desktop toggle on mobile */
  .ps-toggle {
    display: none;
  }

  /* ── Admin sidebar: boost z-index, ensure slide works ── */
  .admin-sidebar {
    z-index: 1000;
    width: 280px;
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

  /* ── Main content: ensure full width ── */
  .portal-main,
  body.ps-collapsed .portal-main,
  body.ps-expanded .portal-main,
  body.ps-collapsed #app,
  body.ps-expanded #app {
    margin-left: 0 !important;
  }

  .admin-main {
    margin-left: 0;
  }

  /* ── Page headers ── */
  .admin-page-header {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
  }

  .admin-page-title {
    font-size: 1rem;
  }

  .admin-page-body {
    padding: 1rem;
  }

  /* ── Dashboard header (CRM) ── */
  .dash-header {
    padding: 0 1rem;
    height: 52px;
  }

  .dash-page {
    padding: 1.5rem 1rem;
  }

  .dash-title {
    font-size: 1.5rem;
  }

  /* ── Info / user cards ── */
  .admin-info-card {
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }

  .admin-info-card .info-left {
    flex-direction: column;
    align-items: center;
  }

  .user-card {
    flex-direction: column;
    align-items: flex-start;
  }

  /* ── Stats / metrics grids ── */
  .admin-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .metrics-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  /* ── Health / status grids ── */
  .health-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .status-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* ── Tables: horizontal scroll ── */
  .admin-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table.admin-table {
    min-width: 580px;
  }

  .admin-table th,
  .admin-table td {
    padding: 0.625rem 0.75rem;
    font-size: 0.75rem;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table {
    min-width: 580px;
  }

  /* ── Forms: single column ── */
  .fg-row {
    flex-direction: column;
  }

  .fg-row .fg {
    min-width: 100% !important;
  }

  /* ── Modals: fullscreen ── */
  .modal-overlay {
    padding: 0 !important;
    align-items: stretch !important;
  }

  .modal-overlay .modal-container {
    max-width: 100% !important;
    width: 100% !important;
    min-height: 100vh;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
  }

  /* Modal tabs: horizontal scroll */
  .tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .tab-bar::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 0.6875rem;
    padding: 0.5rem 0.75rem;
  }

  .tab-pane {
    padding: 1rem;
  }

  /* Disparos small modal */
  .modal-bg {
    padding: 0.5rem !important;
  }

  .modal-bg .modal {
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 12px !important;
  }

  /* ── Wizard (disparos): compact stepper ── */
  .wizard-overlay {
    padding: 0 !important;
  }

  .wizard-container {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 100vh !important;
    height: 100vh;
    border-radius: 0 !important;
  }

  .wizard-stepper {
    gap: 0.25rem;
    padding: 0 0.5rem;
  }

  /* Hide step label text, show only number circles */
  .wz-step > span:last-child {
    display: none;
  }

  .wz-line {
    width: 16px;
  }

  .wizard-body {
    padding: 1rem;
  }

  .wizard-footer {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
  }

  .wizard-footer button {
    width: 100%;
  }

  /* WhatsApp preview: center and size */
  .whatsapp-preview,
  .wa-preview {
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
  }

  /* ── Top bar (disparos/pipelines) ── */
  .topbar {
    flex-wrap: wrap;
    gap: 0.375rem;
    padding: 0.5rem;
  }

  .topbar h2 {
    width: 100%;
    margin-right: 0;
    font-size: 0.875rem;
  }

  .search-box {
    flex: 1 1 120px;
    min-width: 0;
  }

  .filter-sel {
    flex: 0 0 auto;
  }

  .topbar-btn {
    flex: 0 0 auto;
  }

  /* ── Action buttons ── */
  .action-row {
    flex-wrap: wrap;
    gap: 0.375rem;
  }

  /* ── Prevent iOS zoom on input focus ── */
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  /* ── Ensure touch targets ≥ 44px ── */
  .btn,
  button,
  .ps-nav-item,
  .nav-item,
  .ps-logout-btn,
  .sidebar-logout-btn {
    min-height: 44px;
  }

  /* ── Pagination ── */
  .pagination {
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  /* ── Pipeline kanban ── */
  .kanban-board {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Empty state spacing ── */
  .admin-unauthorized,
  .admin-placeholder,
  .admin-empty-state {
    padding: 3rem 1rem;
  }

  /* ── CSV dropzone ── */
  .csv-dropzone {
    padding: 1rem !important;
  }

  /* ── Variable mapping grid ── */
  .var-mapping,
  .var-row {
    grid-template-columns: 1fr !important;
  }
}

/* ─── 992px — LANDING PAGE SPECIFICS ─────────────────────────────────────── */

@media screen and (max-width: 992px) {

  /* Show login link inside mobile nav dropdown */
  .mobile-nav-login {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #20E6E6 !important;
    padding: 0.875rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 0.5rem;
    text-decoration: none;
  }

  .mobile-nav-login i {
    font-size: 1.125rem;
  }

  /* Reduce hero logo on small screens */
  .header-container .logo img {
    height: 80px !important;
  }

  /* Footer logo */
  .footer-grid-custom .logo img {
    height: 80px !important;
  }
}

/* ─── 480px — SMALL MOBILE ───────────────────────────────────────────────── */

@media screen and (max-width: 480px) {

  /* Stats grids: 1 column */
  .admin-stats-grid {
    grid-template-columns: 1fr;
  }

  .metrics-bar {
    grid-template-columns: 1fr;
  }

  .health-grid {
    grid-template-columns: 1fr;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  /* Login card */
  .login-card {
    padding: 1.5rem 1.25rem;
  }

  .login-brand img {
    height: 72px;
  }

  /* Stat card values */
  .admin-stat-card .stat-value {
    font-size: 1.5rem;
  }

  .metric-card .mc-value {
    font-size: 1rem;
  }

  /* Table min-width narrower */
  table.admin-table,
  .table-wrap table {
    min-width: 480px;
  }
}

/* ─── 360px — VERY SMALL MOBILE ──────────────────────────────────────────── */

@media screen and (max-width: 360px) {

  .mobile-header {
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }

  .mobile-logo {
    height: 28px;
  }

  .dash-title {
    font-size: 1.25rem;
  }

  .admin-page-title {
    font-size: 0.875rem;
  }

  /* Buttons: full width */
  .btn-admin-primary,
  .btn-admin-secondary {
    width: 100%;
    justify-content: center;
  }

  /* Login */
  .login-card {
    padding: 1.25rem 1rem;
  }

  .login-card h1 {
    font-size: 1.25rem;
  }

  /* Sidebar slightly narrower */
  .portal-sidebar,
  .portal-sidebar.collapsed,
  .admin-sidebar {
    width: 260px;
  }
}

/* ─── BODY SCROLL LOCK WHEN SIDEBAR IS OPEN ──────────────────────────────── */

@media screen and (max-width: 768px) {
  body.mobile-sidebar-open {
    overflow: hidden;
  }
}
