/* ============================================================
   CBET PORTAL MOBILE APP STYLING SYSTEM
   ============================================================ */

:root {
  --app-primary: #0284c7;
  --app-dark: #0f172a;
  --app-surface: #ffffff;
  --app-bg: #f8fafc;
  --app-border: #e2e8f0;
  --app-text-main: #0f172a;
  --app-text-muted: #64748b;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

@media (max-width: 900px) {
  /* Viewport and Page Layout */
  html, body {
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    background-color: var(--app-bg) !important;
    margin: 0 !important;
    padding: 0 !important;
    padding-bottom: calc(75px + var(--safe-bottom)) !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  /* Global Container Full Width */
  #root, #app, main, .main-container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Mobile Top App Header Bar */
  .cbet-mobile-topbar {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 60px;
    background: #ffffff;
    border-bottom: 1px solid var(--app-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  }

  .cbet-mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 15px;
    color: var(--app-dark);
  }

  .cbet-mobile-brand img {
    height: 34px;
    width: 34px;
    border-radius: 6px;
  }

  .cbet-user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--app-dark);
  }

  .cbet-user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--app-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
  }

  /* Hide Desktop Top Banner & Navigation Header on Phones */
  header, 
  header > div,
  nav[class*="nav"],
  div[class*="nav-tabs"] {
    display: none !important;
  }

  /* Responsive Workspaces: Cards and Layouts */
  main, .dashboard-container, div[class*="space-y-"] {
    padding: 12px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
  }

  /* Stat Cards Matrix */
  div[class*="grid-cols-4"], 
  div[class*="grid-cols-3"], 
  div[class*="grid-cols-2"],
  div:has(> div:contains("Trainees")) {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    width: 100% !important;
  }

  /* Card Element Polish */
  div[class*="rounded"], .card, div:has(> h2), div:has(> h3) {
    border-radius: 14px !important;
    border: 1px solid var(--app-border) !important;
    background: #ffffff !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02) !important;
  }

  /* Sidebar Adaptation */
  aside, .sidebar, div[class*="w-64"], div[class*="w-80"] {
    width: 100% !important;
    position: static !important;
    box-shadow: none !important;
    border-radius: 12px !important;
    margin-bottom: 8px !important;
  }

  /* Chat & Institution Connect Split Pane */
  div[class*="chat"],
  div:has(> input[placeholder*="Search or start new chat"]) {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Native Mobile Bottom Navigation Bar */
  .cbet-mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(60px + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: #ffffff;
    border-top: 1px solid var(--app-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 9999;
    box-shadow: 0 -3px 12px rgba(0,0,0,0.06);
  }

  .cbet-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    color: var(--app-text-muted);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 0;
  }

  .cbet-nav-item.active {
    color: var(--app-primary);
  }

  .cbet-nav-icon {
    font-size: 18px;
    line-height: 1;
  }

  /* Inputs & Form Controls */
  input, select, textarea {
    font-size: 16px !important;
    border-radius: 10px !important;
    padding: 12px !important;
  }

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