/* ============================================================
   BH-V3-MOBILE.CSS
   Corrections mobile pour le redesign v3
   À inclure APRÈS style.css et bh-shared.css
   ============================================================ */

@media (max-width: 1366px) {

  /* ── 1. CACHER LA DARK BAR v3 ── */
  html[data-theme-v3="1"] .v3-dark-bar,
  html[data-theme-v3="1"] [class*="dark-bar"] {
    display: none !important;
  }

  /* ── 2. CACHER LE MAIN-HEADER v3 (kicker/title/back) ── */
  html[data-theme-v3="1"] .main-header {
    display: none !important;
  }

  /* ── 3. MOBILE HEADER FIXE EN HAUT — style natif restauré ── */
  html[data-theme-v3="1"] .mobile-header {
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 60px !important;
    z-index: 1100 !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(245, 242, 236, 0.97) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-bottom: 1px solid rgba(200, 184, 154, 0.4) !important;
    padding: 0 16px !important;
    box-shadow: 0 1px 8px rgba(13, 17, 23, 0.06) !important;
  }

  /* Logo mobile — harmonisation v3 */
  html[data-theme-v3="1"] .mobile-logo {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    text-decoration: none !important;
  }

  html[data-theme-v3="1"] .mobile-logo img,
  html[data-theme-v3="1"] .mobile-header .bh-logo {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    display: block !important;
  }

  html[data-theme-v3="1"] .mobile-logo-text,
  html[data-theme-v3="1"] .mobile-logo-title {
    font-family: 'DM Sans', sans-serif !important;
    font-size: 17px !important;
    font-weight: 700 !important;
    color: #0D1117 !important;
    display: inline-flex !important;
    align-items: baseline !important;
  }

  html[data-theme-v3="1"] .mobile-logo-text .brand-boosting,
  html[data-theme-v3="1"] .mobile-logo-title .brand-boosting {
    color: #1A7A5E !important;
  }

  html[data-theme-v3="1"] .mobile-logo-subtitle {
    font-family: 'DM Sans', sans-serif !important;
    font-size: 10px !important;
    color: #7A8695 !important;
    font-weight: 500 !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
  }

  /* ── 4. SIDEBAR MASQUÉE SUR MOBILE ── */
  html[data-theme-v3="1"] .sidebar,
  html[data-theme-v3="1"] .sidebar-overlay {
    display: none !important;
  }

  /* ── 5. CONTENU PRINCIPAL — padding correct ── */
  html[data-theme-v3="1"] .main-content,
  html[data-theme-v3="1"] .app-container > main,
  html[data-theme-v3="1"] .app-content {
    margin-left: 0 !important;
    padding-left: 0 !important;
    padding-top: 60px !important;  /* Compense mobile-header fixe */
    padding-bottom: 80px !important; /* Compense bottom bar */
  }

  /* page-content — padding interne */
  html[data-theme-v3="1"] .page-content {
    padding: 0 12px !important;
    padding-top: calc(60px + env(safe-area-inset-top, 0px) + 16px) !important;
    padding-bottom: 90px !important;
  }

  /* ── 6. BOTTOM BAR — harmonisation v3 ── */
  html[data-theme-v3="1"] .mobile-tabs {
    background: rgba(245, 242, 236, 0.97) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border-top: 1px solid rgba(200, 184, 154, 0.4) !important;
    box-shadow: 0 -2px 12px rgba(13, 17, 23, 0.06) !important;
  }

  /* Onglets inactifs */
  html[data-theme-v3="1"] .mobile-tabs .tab-btn {
    font-family: 'DM Sans', sans-serif !important;
    color: #A0AABA !important;
  }

  html[data-theme-v3="1"] .mobile-tabs .tab-btn span {
    font-family: 'DM Sans', sans-serif !important;
  }

  /* Onglet actif */
  html[data-theme-v3="1"] .mobile-tabs .tab-btn.active {
    color: #1A7A5E !important;
  }

  /* Indicateur point actif */
  html[data-theme-v3="1"] .mobile-tabs .tab-btn.active::before {
    background: #1A7A5E !important;
  }

  /* Ripple */
  html[data-theme-v3="1"] .mobile-tabs .tab-btn::after {
    background: rgba(26, 122, 94, 0.15) !important;
  }

  /* Badge notification */
  html[data-theme-v3="1"] .mobile-tabs .tab-btn .badge {
    background: #DC2626 !important;
    border-color: rgba(245, 242, 236, 0.97) !important;
  }

  /* ── 7. FOND APP MOBILE ── */
  html[data-theme-v3="1"] body,
  html[data-theme-v3="1"] .app-container {
    background: #F5F2EC !important;
  }

  /* ── 8. CARDS MOBILE ── */
  html[data-theme-v3="1"] .card,
  html[data-theme-v3="1"] section.card {
    border-radius: 14px !important;
    margin-bottom: 12px !important;
  }

  /* ── 9. MENU BOTTOM SHEET "PLUS" — harmonisation v3 ── */
  html[data-theme-v3="1"] #moreMenuSheet {
    background: #F5F0E8 !important;
    border-top: 1px solid rgba(200, 184, 154, 0.4) !important;
  }

  html[data-theme-v3="1"] #moreMenuSheet h3 {
    font-family: 'DM Sans', sans-serif !important;
    font-weight: 700 !important;
    color: #0D1117 !important;
  }

  html[data-theme-v3="1"] #moreMenuSheet .btn-secondary {
    background: rgba(255, 255, 255, 0.7) !important;
    border: 1.5px solid rgba(13, 17, 23, 0.1) !important;
    color: #374151 !important;
    font-family: 'DM Sans', sans-serif !important;
    border-radius: 12px !important;
  }

  html[data-theme-v3="1"] #moreMenuSheet .btn-danger {
    background: rgba(220, 38, 38, 0.08) !important;
    color: #DC2626 !important;
    border: 1.5px solid rgba(220, 38, 38, 0.2) !important;
    font-family: 'DM Sans', sans-serif !important;
    border-radius: 12px !important;
  }

  html[data-theme-v3="1"] #moreMenuOverlay {
    background: rgba(13, 17, 23, 0.4) !important;
  }

  /* ── 10. TABS INTERNES (onglets de page) ── */
  html[data-theme-v3="1"] .settings-tabs,
  html[data-theme-v3="1"] .page-tabs {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    white-space: nowrap !important;
    scrollbar-width: none !important;
  }

  html[data-theme-v3="1"] .settings-tabs::-webkit-scrollbar {
    display: none !important;
  }

  /* ── 11. TABLEAUX — scroll horizontal ── */
  html[data-theme-v3="1"] .table-wrapper,
  html[data-theme-v3="1"] .card-body:has(table) {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* ── 12. FORMULAIRES MOBILE ── */
  html[data-theme-v3="1"] .form-row,
  html[data-theme-v3="1"] .form-row-two {
    flex-direction: column !important;
    gap: 12px !important;
  }

  html[data-theme-v3="1"] .form-row > *,
  html[data-theme-v3="1"] .form-row-two > * {
    width: 100% !important;
  }

  /* ── 13. BOUTON FAB (+ flottant) ── */
  html[data-theme-v3="1"] .fab-btn,
  html[data-theme-v3="1"] .btn-fab {
    background: #1A7A5E !important;
    box-shadow: 0 4px 16px rgba(26, 122, 94, 0.35) !important;
    bottom: calc(80px + env(safe-area-inset-bottom)) !important;
  }

  /* ── 14. SAFE AREA iPhone ── */
  html[data-theme-v3="1"] .mobile-header {
    padding-top: env(safe-area-inset-top, 0px) !important;
    height: calc(60px + env(safe-area-inset-top, 0px)) !important;
  }

  html[data-theme-v3="1"] .main-content,
  html[data-theme-v3="1"] .app-content {
    padding-top: calc(60px + env(safe-area-inset-top, 0px)) !important;
  }
}

/* ── 15. MODAL PLEIN ÉCRAN MOBILE ── */
@media (max-width: 1366px) {

  /* Le modal overlay couvre tout */
  html[data-theme-v3="1"] .modal {
    padding: 0 !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    z-index: 1099 !important; /* juste sous le mobile-header (1100) */
  }

  /* Le contenu du modal commence sous le mobile-header fixe */
  html[data-theme-v3="1"] .modal-content {
    position: fixed !important;
    top: calc(60px + env(safe-area-inset-top, 0px)) !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
  }

  html[data-theme-v3="1"] .modal-header {
    flex-shrink: 0 !important;
    padding: 14px 16px !important;
    background: var(--cream-warm, #F5F2EC) !important;
    border-bottom: 1px solid var(--border-v3, #e5e7eb) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
  }

  html[data-theme-v3="1"] .modal-header h2 {
    font-size: 17px !important;
    margin: 0 !important;
  }

  html[data-theme-v3="1"] .modal-body {
    flex: 1 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 16px !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
  }

  html[data-theme-v3="1"] .modal-actions {
    flex-shrink: 0 !important;
    position: static !important;
    padding: 12px 16px !important;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 70px) !important; /* 70px = bottom tab bar */
    margin: 0 !important;
    border-top: 1px solid var(--border-v3, #e5e7eb) !important;
    background: var(--cream-warm, #F5F2EC) !important;
    display: flex !important;
    gap: 8px !important;
    justify-content: flex-end !important;
  }

  html[data-theme-v3="1"] .form-grid-2 {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  html[data-theme-v3="1"] input[type="time"],
  html[data-theme-v3="1"] input[type="number"] {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  html[data-theme-v3="1"] .input-with-suffix {
    width: 100% !important;
    box-sizing: border-box !important;
  }
}

/* ── DESKTOP : mobile-header toujours masqué ── */
@media (min-width: 1367px) {
  html[data-theme-v3="1"] .mobile-header {
    display: none !important;
  }
  html[data-theme-v3="1"] .mobile-tabs {
    display: none !important;
  }
}
