/**
 * NIR360 — shared mobile / small-screen polish for dashboard + landing.
 * Loaded after gentelella.css and nir360-dashboard-ui.css.
 */

/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
  body[data-shell="admin"] .main > .footer.nir360-app-footer {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }
}

/* ── Dashboard shell (≤768) ── */
@media (max-width: 768px) {
  /*
   * Mobile drawer layout (critical):
   * Keep the rail off-canvas when closed and never reserve desktop sidebar width,
   * otherwise main content is pushed off-screen / clipped by overflow-x:hidden.
   */
  body[data-shell],
  body[data-shell="admin"] {
    --sidebar-w: 0px;
  }

  body[data-shell] .sidebar,
  body[data-shell="admin"] #sidebar.sidebar,
  body[data-user-role] .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: min(288px, calc(100vw - 56px)) !important;
    max-width: 85vw !important;
    height: 100% !important;
    max-height: 100dvh !important;
    transform: translate3d(-105%, 0, 0) !important;
    visibility: visible;
    z-index: 1400 !important;
    pointer-events: none;
  }

  body[data-shell] .sidebar.open,
  body[data-shell="admin"] #sidebar.sidebar.open,
  body[data-user-role] .sidebar.open,
  body.sidebar-open .sidebar.open {
    transform: translate3d(0, 0, 0) !important;
    pointer-events: auto !important;
    z-index: 1400 !important;
  }

  body.sidebar-open .sidebar.open a,
  body.sidebar-open .sidebar.open button,
  body.sidebar-open .sidebar.open .nav-link,
  body.sidebar-open .sidebar.open .nav-link-parent,
  body.sidebar-open .sidebar.open .nav-submenu a {
    pointer-events: auto !important;
    touch-action: manipulation;
    position: relative;
    z-index: 2;
  }

  body[data-shell] .main,
  body[data-shell] #main-content.main,
  body[data-shell="admin"] .main {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    position: relative;
    z-index: 1;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 100vh;
    min-height: 100dvh;
  }

  body[data-shell] .topbar,
  body[data-shell] header.topbar {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  body[data-shell] .main > .footer.nir360-app-footer,
  body[data-shell] footer.footer {
    left: 0 !important;
    right: 0 !important;
    margin-left: 0 !important;
    width: auto !important;
  }

  body[data-shell] .page-wrapper,
  body[data-shell] .dash-content {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .sidebar-toggle {
    width: 44px;
    height: 44px;
  }

  .topbar {
    min-height: 56px;
    padding: 0 10px 0 12px;
    gap: 0.5rem;
  }

  .topbar-left {
    gap: 0.5rem;
    min-width: 0;
  }

  .topbar-right {
    gap: 0.35rem;
    flex-wrap: nowrap;
    min-width: 0;
    margin-left: auto;
  }

  .tb-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
  }

  .tb-btn-logout {
    width: auto;
    min-width: 40px;
    padding: 0 0.55rem;
  }

  .tb-btn-logout span {
    display: none;
  }

  .topbar-user-label {
    max-width: 6.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
    padding: 0.28rem 0.55rem;
  }

  .nir360-connection-indicator {
    padding: 0.28rem 0.45rem;
  }

  .nir360-connection-label {
    display: none;
  }

  .page-wrapper {
    padding: 16px 12px calc(32px + env(safe-area-inset-bottom, 0px));
  }

  .page-header {
    margin-bottom: 1rem;
  }

  .page-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .page-header-actions {
    width: 100%;
    margin-left: 0;
    display: flex;
    flex-wrap: wrap;
  }

  .page-header-actions > * {
    flex: 1 1 auto;
  }

  .page-header-actions .btn,
  .page-header-actions .btn-outline,
  .page-header-actions .btn-create-action,
  .page-header-actions .btn-header-export,
  .page-header-actions a.btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .page-subtitle {
    font-size: 0.88rem;
    line-height: 1.45;
  }

  .card,
  .nir360-dt-panel,
  .nir360-panel,
  .admin-users-datatable-panel,
  .staff-panel,
  .teams-panel,
  .util-panel,
  .pcr-admin-panel,
  .pcr-panel,
  .positions-panel,
  .hotline-panel,
  .inc-type-panel {
    border-radius: 0;
  }

  .card-body,
  .nir360-dt-panel-body {
    padding: 0.95rem 0.9rem 1rem;
  }

  .nir360-dt-panel-header {
    padding: 0.85rem 0.9rem;
    gap: 0.65rem;
  }

  .nir360-dt-wrap {
    margin: 0;
    padding-bottom: 0.15rem;
    max-width: 100%;
    min-width: 0;
    overflow-x: visible;
    -webkit-overflow-scrolling: touch;
  }

  .nir360-dt-wrap table.nir360-dt tbody td .btn,
  .nir360-dt-wrap table.dataTable tbody td .btn,
  .hotline-actions .btn,
  .inc-type-actions .btn,
  .user-action-btn {
    min-height: 36px;
  }

  .hotline-actions,
  .inc-type-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hotline-actions .btn,
  .inc-type-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Forms */
  .form-group input,
  .form-group select,
  .form-group textarea,
  .dash-content input[type="text"],
  .dash-content input[type="tel"],
  .dash-content input[type="email"],
  .dash-content input[type="number"],
  .dash-content input[type="password"],
  .dash-content input[type="datetime-local"],
  .dash-content input[type="date"],
  .dash-content select,
  .dash-content textarea {
    font-size: 16px; /* avoid iOS zoom on focus */
    min-height: 44px;
  }

  .dash-content textarea {
    min-height: 6rem;
  }

  /* Modals */
  .hotline-modal,
  .inc-type-modal,
  .ann-modal,
  .admin-report-modal,
  .admin-staff-modal,
  .user-report-modal,
  .nir360-dialog-root,
  .main .modal {
    padding: 0.5rem;
    align-items: flex-end;
  }

  .hotline-modal-dialog,
  .inc-type-modal-dialog,
  .ann-modal-dialog,
  .admin-report-modal .modal-box,
  .admin-staff-modal .modal-dialog,
  .main .modal-box,
  .nir360-dialog-panel {
    width: 100% !important;
    max-width: 100% !important;
    max-height: min(92vh, 100%);
    border-radius: 16px 16px 0 0;
    margin: 0;
  }

  .hotline-modal-footer,
  .inc-type-modal-footer,
  .ann-modal-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .hotline-modal-footer .btn,
  .inc-type-modal-footer .btn,
  .ann-modal-footer .btn,
  .hotline-modal-footer .btn-create-action,
  .inc-type-modal-footer .btn-create-action {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  /* Stats / grids */
  .nir360-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.65rem;
  }

  .nir360-map-frame,
  #map,
  .leaflet-container {
    min-height: 240px;
    border-radius: 12px;
  }

  /* TTS / alert banners */
  .nir360-voice-banner,
  .nir360-tts-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .nir360-voice-banner .btn,
  .nir360-tts-banner .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .topbar-user-label {
    display: none;
  }

  .nir360-stat-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .page-title {
    font-size: 1.2rem;
  }

  .page-wrapper {
    padding-left: 10px;
    padding-right: 10px;
  }
}

/* Touch-friendly controls */
@media (pointer: coarse) {
  .sidebar .nav-link,
  .sidebar .nav-link-parent,
  .sidebar .nav-submenu a {
    min-height: 44px;
  }

  .tb-btn,
  .sidebar-toggle {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Profile page */
@media (max-width: 768px) {
  .profile-page {
    max-width: 100%;
  }

  .profile-hero {
    grid-template-columns: 1fr !important;
    text-align: center;
    justify-items: center;
  }

  .profile-hero-actions,
  .profile-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .profile-hero-actions .btn,
  .profile-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }
}
/* ── Landing page (community + responder Android) ── */
@media (max-width: 768px) {
  body.landing-page {
    padding-bottom: 0;
    overflow-x: hidden;
  }

  body.landing-page .header {
    padding: 0.65rem 0;
    padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
  }

  body.landing-page .header .container,
  body.landing-page .header .container--wide {
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
  }

  body.landing-page .logo {
    font-size: 1.25rem;
    letter-spacing: -0.02em;
  }

  body.landing-page .header-toolbar {
    gap: 0.5rem;
  }

  body.landing-page .header-toolbar-login {
    min-height: 44px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 999px;
  }

  body.landing-page .nav-toggle {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 44px;
    min-height: 44px;
  }

  body.landing-page .main .container,
  body.landing-page .main .container--wide,
  body.landing-page .main .container--hero {
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
  }

  body.landing-page .hero {
    min-height: auto;
    padding: 0.85rem 0 1.25rem;
  }

  body.landing-page .hero-brand-title {
    font-size: clamp(2.25rem, 10.5vw, 3.25rem);
    line-height: 1.05;
  }

  body.landing-page .hero-brand-tagline {
    font-size: clamp(0.82rem, 3.4vw, 0.95rem);
    max-width: 100%;
  }

  body.landing-page .hero-brand-lead {
    font-size: 0.95rem;
    line-height: 1.55;
    max-width: 36rem;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
  }

  body.landing-page .hero-brand-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 22rem;
    margin-left: auto;
    margin-right: auto;
    gap: 0.65rem;
  }

  body.landing-page .hero .btn-lg,
  body.landing-page .hero-cta-primary,
  body.landing-page .hero-cta-login,
  body.landing-page .btn-download-apk,
  body.landing-page .hero-cta-apk {
    width: 100%;
    max-width: none;
    min-height: 48px;
    justify-content: center;
  }

  body.landing-page .btn-download-apk,
  body.landing-page .hero-cta-apk {
    justify-content: flex-start;
    min-height: 52px;
  }

  /* Keep map readable; reduce pin clutter on phones */
  body.landing-page .hero-map-pin:nth-child(n+8) {
    display: none;
  }

  body.landing-page .hero-map-pin {
    width: clamp(16px, 4.2vw, 24px);
  }

  body.landing-page .hero-mockups {
    width: min(94vw, 340px);
    min-height: 300px;
    margin-top: -1.25rem;
  }

  body.landing-page .landing-section,
  body.landing-page .about-nir360,
  body.landing-page .landing-cta-band,
  body.landing-page .landing-contact {
    padding-left: 0;
    padding-right: 0;
  }

  body.landing-page .about-step-card,
  body.landing-page .about-feature-card,
  body.landing-page .landing-highlight,
  body.landing-page .landing-contact-card {
    padding: 1rem;
  }

  body.landing-page .landing-cta-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 22rem;
    margin-left: auto;
    margin-right: auto;
    gap: 0.65rem;
  }

  body.landing-page .landing-cta-actions .btn,
  body.landing-page .landing-cta-download {
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }

  body.landing-page .landing-contact-card a[href^="tel:"] {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 1.05rem;
    font-weight: 600;
  }

  /* Auth + privacy: bottom sheets for one-handed Android use */
  body.landing-page .main .modal {
    padding: 0;
    align-items: flex-end;
    justify-content: stretch;
  }

  body.landing-page .main .modal-box,
  body.landing-page .main .modal-box--login,
  body.landing-page .main .modal-box--register,
  body.landing-page .main .modal-box--privacy {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 94vh;
    max-height: 94dvh;
    margin: 0;
    border-radius: 18px 18px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  body.landing-page .main .modal--login {
    padding: 0;
    align-items: flex-end;
  }

  body.landing-page .main .modal-box--login,
  body.landing-page .main .modal-box--register {
    max-height: 96vh;
    max-height: 96dvh;
    border-radius: 18px 18px 0 0;
    animation: landing-sheet-up 0.28s ease;
  }
}

@keyframes landing-sheet-up {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  body.landing-page .main .modal-box--login,
  body.landing-page .main .modal-box--register {
    animation: none;
  }
}

@media (max-width: 768px) {
  body.landing-page .main .modal-body input,
  body.landing-page .main .modal-body select,
  body.landing-page .main .modal-body textarea,
  body.landing-page .login-input-wrap input,
  body.landing-page .reg-input-wrap input,
  body.landing-page .reg-input-wrap select,
  body.landing-page .reg-form .form-group input,
  body.landing-page .reg-form .form-group select,
  body.landing-page .reg-form .form-group textarea {
    font-size: 16px !important; /* prevent mobile browser zoom on focus */
    min-height: 48px;
  }

  body.landing-page .main .modal-body .btn,
  body.landing-page .main .modal-body .btn-primary,
  body.landing-page .main .modal-body .btn-outline,
  body.landing-page .main .modal-body .btn-block,
  body.landing-page .btn-login-submit,
  body.landing-page #reg-submit-btn,
  body.landing-page .reg-wizard-nav .btn {
    min-height: 48px;
    width: 100%;
    justify-content: center;
  }

  body.landing-page .reg-wizard-nav {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  body.landing-page .reg-wizard-nav .btn {
    flex: 1 1 auto;
  }

  body.landing-page .reg-form-grid,
  body.landing-page .reg-form-grid--3,
  body.landing-page .reg-form-grid--4 {
    grid-template-columns: 1fr !important;
  }

  body.landing-page .login-modal-close,
  body.landing-page .privacy-modal-close,
  body.landing-page .reg-modal-close,
  body.landing-page .main .modal-close {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 44px;
    min-height: 44px;
  }

  body.landing-page .privacy-consent-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  body.landing-page .privacy-btn {
    width: 100%;
    min-height: 48px;
  }
}

@media (max-width: 480px) {
  body.landing-page .header-toolbar-login {
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
  }

  body.landing-page .nav-toggle {
    width: 2.6rem;
    height: 2.6rem;
  }

  body.landing-page .hero-brand-title {
    font-size: clamp(2.1rem, 11vw, 2.75rem);
  }

  body.landing-page .hero-brand-lead {
    font-size: 0.9rem;
  }

  body.landing-page .hero-map-pin:nth-child(n+5) {
    display: none;
  }

  body.landing-page .hero-mockups {
    min-height: 260px;
    margin-top: -0.75rem;
  }

  body.landing-page .hero-phone--feed {
    width: min(62vw, 220px);
  }

  body.landing-page .hero-gps-card {
    width: min(34vw, 108px);
  }

  body.landing-page .hero-phone-map-wrap {
    width: min(40vw, 155px);
  }

  body.landing-page .about-intro,
  body.landing-page .landing-cta-band__inner {
    text-align: left;
  }

  body.landing-page .landing-cta-title,
  body.landing-page .about-title {
    font-size: clamp(1.35rem, 6.5vw, 1.75rem);
  }

  body.landing-page .landing-site-bottom,
  body.landing-page .nir360-landing-footer .nir360-app-footer__text {
    text-align: center;
    font-size: 0.78rem;
  }
}

/* Very small Android widths (≈360px) */
@media (max-width: 380px) {
  body.landing-page .header-toolbar-login {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
  }

  body.landing-page .hero-brand-actions,
  body.landing-page .landing-cta-actions {
    max-width: 100%;
  }

  body.landing-page .nav {
    width: min(100vw, 100%);
  }
}

@media (pointer: coarse) {
  body.landing-page .header-nav-link,
  body.landing-page .header-nav-link-btn,
  body.landing-page .btn-nav-cta,
  body.landing-page .header-toolbar-login,
  body.landing-page .nav-toggle {
    min-height: 48px;
  }
}

/* Cross-browser dashboard + shared shell */
html {
  -moz-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
}

.page-wrapper,
.card,
.nir360-dt-panel,
.nir360-dt-wrap,
.topbar-left,
.topbar-right {
  min-width: 0;
}

.nir360-dt-wrap {
  overflow-x: visible;
  max-width: 100%;
  min-width: 0;
}

.nir360-dt-wrap .dt-layout-full,
.nir360-dt-wrap .dt-layout-row:has(table.dataTable) {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  min-width: 0;
}

.nir360-dt-wrap:not(:has(.dt-container)) {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .page-wrapper,
  .main_container,
  .right_col {
    max-width: 100%;
    overflow-x: hidden;
  }

  table.dataTable,
  table.nir360-dt {
    width: 100% !important;
  }

  .form-control,
  .form-select,
  input,
  select,
  textarea {
    max-width: 100%;
  }

  /* Shared modal viewport guards (dashboard + landing) */
  .modal,
  .main .modal,
  .pcr-modal,
  .pcr-stack-modal,
  .hotline-modal,
  .inc-type-modal,
  .ann-modal,
  .admin-report-modal,
  .admin-staff-modal,
  .user-report-modal {
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  .modal-box,
  .main .modal-box,
  .pcr-modal-box,
  .pcr-stack-modal__box,
  .hotline-modal-dialog,
  .inc-type-modal-dialog,
  .ann-modal-dialog {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .sidebar .side-menu a,
  .sidebar .nav.side-menu li a,
  body[data-shell] .sidebar.open a {
    pointer-events: auto !important;
    touch-action: manipulation;
    position: relative;
    z-index: 2;
  }

  body.sidebar-open .sidebar.open {
    z-index: 1400 !important;
    pointer-events: auto !important;
  }

  body.sidebar-open .sidebar-backdrop:not([hidden]) {
    /* Never sit on top of the drawer — only dim the page to the right. */
    left: min(288px, calc(100vw - 56px)) !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: auto !important;
    z-index: 1350 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    filter: none !important;
    background: rgba(15, 23, 42, 0.45) !important;
    pointer-events: auto !important;
  }
}

