/* ============================================================
   CBET PORTAL MOBILE-FIRST RESPONSIVE ENGINE
   ============================================================ */

/* 1. Global Viewport & Reset */
html, body {
  width: 100% !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  -webkit-text-size-adjust: 100% !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

*, *::before, *::after {
  box-sizing: border-box !important;
}

/* 2. Top Account Header Bar */
header {
  width: 100% !important;
  max-width: 100vw !important;
  position: relative !important;
}

header > div[class*="flex"],
header div[class*="top-"] {
  flex-wrap: wrap !important;
  width: 100% !important;
}

/* User identity badge on mobile */
.user-account-header,
header div:has(> a[href*="logout"]),
header div:has(> button:contains("Logout")) {
  display: flex !important;
  flex-direction: row !important;
  justify-content: space-between !important;
  align-items: center !important;
  width: 100% !important;
  background: #0f172a !important;
  color: #ffffff !important;
  padding: 8px 14px !important;
  font-size: 13px !important;
}

/* 3. Horizontal Scrollable Navigation Bar on Mobile */
nav, .nav-container, div[class*="nav-tabs"], div:has(> a[href*="/portal/"]) {
  width: 100% !important;
  overflow-x: auto !important;
  white-space: nowrap !important;
  -webkit-overflow-scrolling: touch !important;
  display: flex !important;
  flex-direction: row !important;
  scrollbar-width: none !important;
  background: #0369a1 !important;
}

nav::-webkit-scrollbar {
  display: none !important;
}

nav a, nav button, div:has(> a[href*="/portal/"]) > a {
  flex: 0 0 auto !important;
  padding: 10px 14px !important;
  font-size: 13px !important;
  color: #ffffff !important;
  border-bottom: 2px solid transparent !important;
}

nav a.active, nav a:hover {
  background: rgba(255, 255, 255, 0.15) !important;
  border-bottom: 2px solid #f59e0b !important;
}

/* 4. Mobile Main Grid & Split Panes (Chat, Dashboard, Tables) */
@media (max-width: 900px) {
  /* Break two-column layouts into clean single-column cards */
  div[class*="grid"], 
  div[class*="flex-row"],
  main > div,
  .main-content,
  .dashboard-grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 16px !important;
    padding: 10px !important;
  }

  /* Left Sidebar converts to full-width card */
  aside, 
  div[class*="w-64"], 
  div[class*="w-1/4"],
  div[class*="w-1/3"],
  div[class*="w-80"],
  .sidebar {
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 12px !important;
  }

  /* Main Workspace / Content Column */
  div[class*="flex-1"],
  div[class*="w-3/4"],
  div[class*="w-2/3"],
  .content-area {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Chat & Institution Connect Split Screen on Mobile */
  div[class*="chat"],
  div:has(> div:contains("Institution Connect")) {
    width: 100% !important;
    max-width: 100% !important;
  }

  div:has(> input[placeholder*="Search or start new chat"]) {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Stat Cards */
  .grid-cols-4, .grid-cols-3, .grid-cols-2 {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  /* Form & Inputs */
  input, select, textarea {
    font-size: 16px !important; /* Prevents auto-zoom on iOS/Android */
    width: 100% !important;
  }

  /* Responsive Tables */
  table {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
}

@media (max-width: 480px) {
  .grid-cols-4, .grid-cols-3, .grid-cols-2 {
    grid-template-columns: 1fr !important;
  }
  
  .cbet-hub-selector {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
