/* Street Monitoring DEV v3.0.20 — mobile usability overrides.
   Only layout changes; no change to API endpoints, authentication or device processing. */
html { max-width: 100%; }
body { max-width: 100%; overflow-x: clip; }
/* Respect visual viewport, keyboard and safe areas. */
#pilotActionDialog {
  box-sizing: border-box;
  position: fixed;
  width: min(680px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: min(90dvh, 800px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border-radius: 18px;
  box-shadow: 0 18px 60px #0004;
}
#pilotActionDialog[open] { display: block; }
#pilotActionDialog .op-modal {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  min-width: 0;
  max-height: min(90dvh, 800px);
  overflow: hidden;
}
.op-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
}
.op-modal-header h2 { margin: 0; line-height: 1.25; font-size: 18px; min-width: 0; }
.op-modal-close {
  flex: 0 0 44px; width: 44px; height: 44px;
  border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); background: var(--surface);
  font-size: 26px; cursor: pointer;
}
.op-modal-scroll {
  min-height: 0;
  min-width: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px 20px;
}
#pilotActionDialog .op-modal-scroll > label {
  display: grid;
  gap: 5px;
  margin-bottom: 13px;
}
#pilotActionDialog .op-modal-scroll :is(input, select, textarea) {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 16px; /* prevents iOS focus-zoom */
  padding: 11px;
}
#pilotActionDialog .op-modal-scroll :is(input, select) { min-height: 44px; }
#pilotActionDialog .op-modal-scroll textarea { resize: vertical; min-height: 84px; }
#pilotActionDialog .op-modal-scroll input[type="file"] {
  display: block;
  padding: 8px;
  font-size: 13px;
  overflow: hidden;
}
#pilotActionDialog .op-modal-scroll input[type="file"]::file-selector-button {
  background: var(--surface); color: var(--primary); border: 0;
  border-radius: 9px; padding: 11px 10px; margin-right: 8px;
  font-weight: 700; cursor: pointer;
}
#pilotActionDialog .op-photo-picker {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px; margin-bottom: 12px;
}
#pilotActionDialog .op-photo-picker label { min-width: 0; }
#pilotActionDialog .op-modal-scroll .op-gps-consent {
  display: flex !important; align-items: flex-start; gap: 12px;
  line-height: 1.5; margin: 12px 0;
}
#pilotActionDialog .op-modal-scroll .op-gps-consent input {
  width: 22px; height: 22px; min-height: 22px; flex: 0 0 22px;
  margin: 0; padding: 0; accent-color: var(--primary);
}
#pilotActionDialog .op-modal-scroll .op-gps-consent span { flex: 1; }
#pilotActionDialog .op-modal-note {
  margin: 0 0 12px; overflow-wrap: anywhere;
}
#pilotActionDialog #opPhotoStatus,
#pilotActionDialog #opDialogResult { overflow-wrap: anywhere; }
.op-modal-actions {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px max(12px,env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel); flex: 0 0 auto;
}
.op-modal-actions button { min-height: 48px; flex: 1 1 0; }
body.sm-action-dialog-open { overflow: hidden; }

@media (max-width: 730px) {
  body:not(.authenticated) { height: 100%; overflow: hidden; }
  .login-screen {
    position: fixed; inset: 0; z-index: 50;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
    overflow-y: auto; overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    align-items: center;
    justify-items: center;
  }
  .login-screen #localLoginPanel {
    width: min(100%, 420px);
    max-width: 100%;
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    min-width: 0;
    padding: clamp(16px,4vw,24px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border-radius: 18px;
  }
  .login-screen #localLoginPanel .panelheader { margin-bottom: 12px; }
  .login-screen #localLoginPanel .panelheader h2 { font-size: clamp(17px,4.5vw,21px); line-height: 1.3; }
  .login-screen #localLoginPanel .fields { gap: 12px; }
  .login-screen #localLoginPanel .fields label { min-width: 0; }
  .login-screen #localLoginPanel input {
    font-size: 16px; min-height: 48px; width: 100%;
  }
  .login-screen #localLoginButton { min-height: 50px; font-size: 16px; }
  .login-screen #loginError { overflow-wrap: anywhere; }
  /* Header and navigation remain usable at phone widths. */
  .sidebar.open { max-height: 100dvh; overflow-y: auto; overscroll-behavior: contain; }
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; padding-top: 12px; }
  .topbar > div:first-child { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; }
  .topbar > div:first-child p { flex-basis: 100%; margin-top: 0; }
  .topactions { flex-wrap: wrap; justify-content: flex-start; gap: 8px; min-width: 0; }
  .topactions button, #mobileMenu { min-height: 44px; }
  .preview-control { flex: 1 1 120px; min-width: 0; }
  .preview-control select { max-width: 100%; width: 100%; min-height: 44px; font-size: 16px; }
  .panel, .metric, .ops-sensor, .op-entry { overflow-wrap: anywhere; }
  .pilot-actions button { min-height: 48px; }
  #pilotActionDialog {
    inset: auto 0 0 0;
    margin: 0;
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - env(safe-area-inset-top) - 8px);
    border-radius: 20px 20px 0 0;
    border-left: 0; border-right: 0; border-bottom: 0;
  }
  #pilotActionDialog .op-modal {
    max-height: calc(100dvh - env(safe-area-inset-top) - 8px);
  }
  .op-modal-header { padding: 10px 16px; }
  .op-modal-scroll { padding: 12px 16px; }
  .op-modal-actions { padding: 10px 16px max(12px,env(safe-area-inset-bottom)); }
  #pilotActionDialog .op-photo-picker { grid-template-columns: minmax(0,1fr); gap: 12px; }
  .op-modal-actions button { padding: 11px 6px; }
}
@media (max-width: 350px) {
  #pilotActionDialog .op-photo-picker { gap: 9px; }
  .op-modal-actions { gap: 7px; }
  .op-modal-actions button { font-size: 12px; }
  .pilot-actions { padding-left: 4px; padding-right: 4px; }
  .pilot-actions button { font-size: 10px; padding: 8px 2px; }
}
@media (max-width: 730px) and (orientation: landscape) {
  .login-screen #localLoginPanel { max-height: calc(100dvh - 12px); }
  #pilotActionDialog { max-height: calc(100dvh - 4px); }
  #pilotActionDialog .op-modal { max-height: calc(100dvh - 4px); }
  .op-modal-header { padding-top: 5px; padding-bottom: 5px; }
}
