/**
 * RC-1.7 — Mobile / responsive stabilization (UX only).
 * Complements vozo-theme.css; does not redesign the shell.
 */

/* ——— Page overflow guard (not the only fix) ——— */
html.light-style,
html.light-style body {
  max-width: 100%;
  overflow-x: hidden;
}

body.vozo-mobile-drawer-open {
  overflow: hidden !important;
  touch-action: none;
}

/* ——— Mobile drawer width + close button ——— */
@media (max-width: 1199.98px) {
  .vozo-sidebar-premium.layout-menu,
  .layout-menu.vozo-sidebar-premium {
    width: min(86vw, 320px) !important;
    max-width: min(86vw, 320px) !important;
  }

  .vozo-sidebar-premium .app-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 64px;
    padding: 12px 12px 10px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  .vozo-sidebar-premium .app-brand-link {
    min-width: 0;
    flex: 1;
  }

  /* Override Sneat theme-default oversized block toggle */
  .app-brand .layout-menu-toggle.vozo-sidebar-close,
  .layout-menu-expanded .app-brand .layout-menu-toggle.vozo-sidebar-close,
  .vozo-sidebar-close {
    display: inline-grid !important;
    place-items: center;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    padding: 8px !important;
    margin: 0 0 0 auto !important;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0 !important;
    flex-shrink: 0;
    line-height: 1;
    text-decoration: none;
  }

  .vozo-sidebar-close i,
  .vozo-sidebar-close .bx {
    font-size: 20px !important;
    line-height: 1;
    width: auto;
    height: auto;
  }

  .vozo-sidebar-close:hover,
  .vozo-sidebar-close:focus {
    background: rgba(14, 173, 105, 0.22);
    color: #4adeb8 !important;
  }

  .layout-menu-expanded .layout-overlay {
    z-index: 1099;
    opacity: 1;
    visibility: visible;
    display: block;
  }

  .layout-menu.vozo-sidebar-premium {
    z-index: 1100;
  }

  .layout-navbar {
    min-height: 56px;
    padding-top: env(safe-area-inset-top, 0px);
  }

  .navbar-detached {
    margin: 0.75rem 0.75rem 0 !important;
  }

  .container-p-y {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  /* Forms: 44px hit target + 16px to avoid iOS zoom */
  .layout-page .form-control,
  .layout-page .form-select,
  .layout-page input[type="text"],
  .layout-page input[type="email"],
  .layout-page input[type="password"],
  .layout-page input[type="search"],
  .layout-page input[type="tel"],
  .layout-page input[type="url"],
  .layout-page input[type="number"],
  .layout-page textarea,
  .layout-page select {
    min-height: 44px;
    font-size: 16px !important;
  }

  .layout-page .btn,
  .layout-page .vozo-btn,
  .layout-page .ui-action-btn {
    min-height: 44px;
  }

  .layout-page .btn-group,
  .layout-page .d-flex.gap-2 {
    flex-wrap: wrap;
  }

  /* Tables: scroll locally, not the whole page */
  .table-responsive,
  .vozo-table-scroll {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .dropdown-menu {
    max-width: calc(100vw - 24px);
  }

  .dropdown-menu-end {
    right: 0;
    left: auto !important;
  }

  .modal-dialog {
    margin: 12px auto;
    max-width: calc(100vw - 24px);
  }

  .modal-content {
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }

  .ui-confirm-modal__panel,
  .ui-loading-overlay__panel {
    width: min(360px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }

  .mobile-bottom-actions {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

/* Loading overlay: never intercept when hidden */
.ui-loading-overlay:not(.is-visible) {
  pointer-events: none !important;
  display: none !important;
}

.ui-loading-overlay.is-visible {
  pointer-events: all;
  z-index: 1200;
}

/* Fallback white-screen recovery */
#vozo-ui-fallback {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(248, 250, 252, 0.96);
}

#vozo-ui-fallback[hidden] {
  display: none !important;
}

#vozo-ui-fallback .vozo-ui-fallback__card {
  width: min(420px, calc(100vw - 24px));
  text-align: center;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  padding: 1.5rem 1.25rem;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

#vozo-ui-fallback h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
}

#vozo-ui-fallback p {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  color: #64748b;
}

#vozo-ui-fallback .vozo-ui-fallback__actions {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

#vozo-ui-fallback .vozo-ui-fallback__actions a,
#vozo-ui-fallback .vozo-ui-fallback__actions button {
  min-height: 44px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
}

#vozo-ui-fallback .vozo-ui-fallback__primary {
  background: #0b3a53;
  color: #fff;
  border: 0;
}

#vozo-ui-fallback .vozo-ui-fallback__secondary {
  background: #eef2f6;
  color: #0b3a53;
}
