/**
 * OddsLock — mobile.css
 *
 * Regles universelles anti-overflow et responsive pour les pages connectees
 * (dashboard, tracker, kelly, guide, profil, admin, contact).
 *
 * Inclut avec <link rel="stylesheet" href="/css/mobile.css"> APRES les styles
 * inline de la page pour que les !important prennent le dessus.
 */

/* ============================================================
   ANTI-OVERFLOW GLOBAL — tres important
   ============================================================ */
html, body {
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

/* Root container (body > div ou body direct) */
body > div,
body > main,
body > aside,
body > section {
  max-width: 100vw;
}

/* ============================================================
   MOBILE MENU BUTTON (hamburger) — base visible
   ============================================================ */
.mobile-menu-btn {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--surface, #18181B);
  border: 1px solid var(--border, #27272A);
  color: var(--text-2, #D4D4D8);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  margin-right: 8px;
  position: relative;
  z-index: 110;
}
.mobile-menu-btn svg { width: 18px; height: 18px; }
.mobile-menu-btn:hover {
  color: var(--text-1, #FAFAFA);
  border-color: var(--border-2, #3F3F46);
}

/* ============================================================
   SIDEBAR BACKDROP — overlay quand menu mobile ouvert
   ============================================================ */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 90;
}
.sidebar-backdrop.show { display: block; }

/* ============================================================
   MOBILE BREAKPOINT < 768px
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px !important; }

  /* Body en bloc pour ne pas reserver d'espace pour la sidebar */
  body {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Sidebar: slide depuis la gauche */
  .sidebar {
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 260px !important;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    z-index: 100 !important;
    background: var(--surface, #18181B) !important;
    border-right: 1px solid var(--border, #27272A) !important;
  }
  .sidebar.open { transform: translateX(0) !important; }

  /* Main content: pas de marge gauche */
  .main {
    margin: 0 !important;
    margin-left: 0 !important;
    padding: 0 !important;
    max-width: 100vw !important;
    width: 100% !important;
    flex: none !important;
    display: block !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  /* Topbar au dessus du backdrop pour que le hamburger reste clickable */
  .topbar {
    position: sticky !important;
    z-index: 95 !important;
  }

  /* Tous les descendants directs de main ne debordent pas */
  .main > *,
  .main > * > * {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Grid container du dashboard */
  .dashboard-container,
  .container {
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  /* Hamburger visible */
  .mobile-menu-btn { display: flex !important; }

  /* Topbar compacte */
  .topbar {
    padding: 0 12px !important;
    gap: 6px !important;
  }
  .topbar-title, .breadcrumb {
    font-size: .82rem !important;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-right { gap: 6px !important; }
  .topbar-period { display: none !important; }
  /* Cacher les boutons texte de la topbar (ils sont souvent trop longs) */
  .topbar-right > button:not(.icon-only),
  .topbar-right > a.btn-sm:not(.icon-only) {
    display: none !important;
  }

  /* Content: padding reduit */
  .content {
    padding: 14px !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  /* Panels: ne debordent jamais */
  .panel, .kpi, .card {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* KPI grid: 2 colonnes sur mobile */
  .kpi-row, .kpi-strip {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  .kpi { padding: 14px 12px !important; }

  /* Main grid: 1 colonne */
  .main-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 14px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  .main-grid > * {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Tables: wrapper scrollable */
  .table-scroll {
    overflow-x: auto !important;
    max-width: 100% !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Canvas (graphiques Chart.js) */
  canvas {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Mini calc: layout compact */
  .mc-row {
    grid-template-columns: 1fr 56px 56px !important;
    gap: 6px !important;
  }

  /* Trial banner: pas de min-width fige */
  #trial-banner {
    flex-wrap: wrap !important;
  }
  #trial-banner > div {
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }

  /* Promo cards (tracker) */
  .promo-grid {
    grid-template-columns: 1fr !important;
  }
  .promo-row {
    grid-template-columns: 40px 1fr auto !important;
    gap: 10px !important;
  }
  .promo-row > .row-desc,
  .promo-row > .row-profit,
  .promo-row > .row-roi,
  .promo-row > .row-countdown {
    display: none !important;
  }

  /* Guide bookmaker grid */
  #bk-grid {
    grid-template-columns: 1fr !important;
  }

  /* Inputs: pas de zoom iOS sur focus */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* User card dans sidebar: plus compact */
  .user-card {
    padding: 12px !important;
  }

  /* Pages sans sidebar (profil, auth, pricing) */
  nav {
    padding: 12px 16px !important;
    gap: 10px !important;
    flex-wrap: wrap !important;
  }
  .wrap {
    padding: 16px !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }
  .wrap h1 { font-size: 1.4rem !important; }
  .section {
    padding: 16px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  /* Grids dans les sections du profil */
  .section > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   VERY SMALL (< 480px)
   ============================================================ */
@media (max-width: 480px) {
  .kpi-row, .kpi-strip {
    grid-template-columns: 1fr !important;
  }
  .topbar-title, .breadcrumb { font-size: .78rem !important; }
  .content { padding: 12px !important; }
  .sidebar { width: 240px !important; }

  /* Rappel ANJ plus compact */
  .anj-alert {
    font-size: .72rem !important;
    padding: 10px !important;
  }
}
