/* =========================================================
  MOBILE.CSS
  Mobile layout, visibility, stacking, and touch sizing only.

  Visual theme rules live in:
  - 00-theme-tokens.css
  - surfaces.css
  - page theme files
========================================================= */

/* =========================================================
  1. MOBILE BASE HARDENING
========================================================= */
@media (max-width: 767.98px) {
  html,
  body,
  .workorder-shell,
  body > main.container-fluid {
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  body > main.container,
  body > main.container-fluid {
    margin-top: 0.75rem !important;
    max-width: none;
    padding-left: 0;
    padding-right: 0;
  }
}

/* =========================================================
  2. MOBILE NAVBAR
========================================================= */
@media (max-width: 991.98px) {
  .navbar {
    height: auto !important;
    max-height: none !important;
    min-height: 56px !important;
    overflow: visible !important;
    position: sticky;
    top: 0;
    z-index: 2000;
  }

  .navbar .container-fluid {
    align-items: center;
    flex-wrap: wrap;
    position: relative;
  }

  .navbar-brand {
    max-width: calc(100% - 72px);
  }

  .navbar-brand-logo {
    height: auto !important;
    max-height: 36px;
    width: auto !important;
  }

  .navbar-toggler {
    margin-left: auto;
    position: relative;
    z-index: 2001;
  }

  .navbar-collapse {
    background: var(--app-surface);
    border: 1px solid color-mix(in srgb, var(--app-border), transparent 16%);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    left: 0.75rem;
    margin-top: 0.65rem;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    padding: 0.75rem;
    position: absolute;
    right: 0.75rem;
    top: calc(100% + 0.5rem);
    width: auto;
  }

  .navbar-nav {
    display: grid;
    gap: 0.35rem;
    padding-top: 0.35rem;
    width: 100%;
  }

  .navbar-nav .nav-link {
    border-radius: var(--radius-md);
    display: block;
    padding: 0.65rem 0.75rem;
    text-align: center;
  }

  .navbar-collapse > .d-flex {
    align-items: stretch !important;
    border-top: 1px solid color-mix(in srgb, var(--app-border), transparent 18%);
    flex-direction: column;
    gap: 0.65rem !important;
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    width: 100%;
  }

  .navbar-collapse .btn,
  .navbar-collapse form,
  .navbar-collapse form button {
    min-height: 38px;
    width: 100%;
  }

  .navbar-collapse .text-muted.small,
  .navbar .text-muted {
    display: none !important;
  }

  body:has(.navbar-collapse.show) main {
    padding-top: 0 !important;
  }
}

@media (max-width: 767.98px) {
  .navbar {
    align-items: center !important;
    gap: 0.5rem;
    padding: 0 0.75rem !important;
  }

  .navbar .btn {
    min-height: 34px;
    padding: 0.35rem 0.55rem;
  }
}

/* =========================================================
  3. MOBILE WORKORDER LIST / DETAIL FLOW
========================================================= */
@media (max-width: 767.98px) {
  .workorder-shell {
    margin: 0;
    overflow-x: hidden;
    width: 100%;
  }

  .workorder-layout {
    display: block !important;
    flex-wrap: nowrap;
    min-height: 0;
    transform: none !important;
    width: 100% !important;
  }

  .workorder-layout.showing-detail {
    transform: none !important;
  }

  .workorder-sidebar,
  .workorder-detail {
    flex: none !important;
    height: auto !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    width: 100% !important;
  }

  .workorder-detail {
    display: none;
    padding-bottom: 6.5rem !important;
  }

  .workorder-layout.showing-detail .workorder-sidebar {
    display: none;
  }

  .workorder-layout.showing-detail .workorder-detail {
    display: block;
  }

  #workOrderList,
  #quoteList {
    display: grid !important;
    gap: 0.7rem;
    overflow-x: hidden !important;
    padding-bottom: 0.75rem;
    scroll-snap-type: none !important;
  }

  .workorder-list-item,
  #quoteList .list-group-item {
    flex: none !important;
    width: 100% !important;
  }

  .workorder-list-item:hover,
  #quoteList .list-group-item:hover {
    transform: none;
  }
}

/* =========================================================
  4. MOBILE FORMS / SECTIONS
========================================================= */
@media (max-width: 767.98px) {
  .workorder-form {
    max-width: none;
    min-width: 0;
    width: 100%;
  }

  .workorder-form fieldset {
    gap: 0.75rem;
    min-width: 0;
  }

  .workorder-form .row {
    --bs-gutter-x: 0;
    margin-left: 0;
    margin-right: 0;
  }

  .workorder-form .row > *,
  .workorder-section,
  .workorder-picker-panel,
  .workorder-form,
  .workorder-form fieldset {
    max-width: 100% !important;
    min-width: 0;
    overflow-x: hidden !important;
  }

  .workorder-section {
    padding: 0.85rem;
  }

  .workorder-section-title {
    margin-bottom: 0.7rem;
  }

  .workorder-section-title h3 {
    font-size: 0.92rem;
  }

  .workorder-picker-panel,
  .workorder-materials-panel {
    padding: 0.7rem;
  }

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

  .workorder-eta-group {
    display: grid !important;
    gap: 0.5rem;
    grid-template-columns: 1fr !important;
  }

  .workorder-eta-group input[type="date"],
  .workorder-eta-group .form-select {
    flex: none !important;
    min-width: 0 !important;
    width: 100% !important;
  }
}

/* =========================================================
  5. MOBILE TECHNICIAN / MATERIALS
========================================================= */
@media (max-width: 767.98px) {
  .technician-picker {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: 1fr;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0;
  }

  .technician-picker-option {
    font-size: 0.9rem;
    min-height: 44px;
    padding: 0.55rem 0.65rem;
  }

  #selectedTechnicians {
    gap: 0.35rem !important;
  }

  .technician-chip {
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    line-height: 1.15;
    min-height: 30px;
    padding: 0.35rem 0.55rem;
  }

  #technician {
    min-height: 150px;
  }

  .technician-hours-row {
    margin-bottom: 0.55rem !important;
    padding: 0.6rem !important;
  }

  .technician-hours-row:last-child {
    margin-bottom: 0 !important;
  }

  .technician-hours-row .input-group {
    max-width: none;
  }

  .workorder-hours-panel,
  .workorder-materials-panel,
  .material-entry-scroll {
    min-height: 0;
  }

  .material-entry-table {
    min-width: 0;
    width: 100%;
  }

  .material-entry-table .material-remove-column {
    width: 64px;
  }

  .material-remove-button {
    font-size: 0;
    min-height: 32px;
    width: 100%;
  }

  .material-remove-button::after {
    content: "Remove";
    font-size: 0.78rem;
  }
}

/* =========================================================
  6. MOBILE ADMIN MODALS
========================================================= */
@media (max-width: 767.98px) {
  .workorder-admin-modal-content,
  .workorder-admin-modal-content .modal-body,
  .workorder-admin-modal-content .row,
  .admin-technician-editor {
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  .workorder-admin-modal-content .modal-body {
    padding: 0.85rem;
  }

  .workorder-admin-modal-content .row {
    --bs-gutter-x: 0;
    margin-left: 0;
    margin-right: 0;
  }

  .workorder-admin-modal-content .row > * {
    min-width: 0;
  }

  .workorder-admin-modal-content .btn-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .workorder-admin-modal-content .btn-group .btn {
    min-width: 0;
    white-space: normal;
  }

  .admin-technician-editor-header {
    align-items: stretch !important;
    flex-direction: column;
  }

  .admin-technician-actions {
    display: grid !important;
    gap: 0.5rem !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .admin-technician-actions .btn {
    min-height: 38px;
    min-width: 0;
    white-space: normal;
  }
}

/* =========================================================
  7. MOBILE REVISIONS
========================================================= */
@media (max-width: 767.98px) {
  .revision-group-toggle,
  .revision-detail-toggle {
    min-height: 38px;
    min-width: 38px;
  }

  .revision-group-toggle {
    align-items: center;
    display: flex;
    font-size: 0.8rem;
    font-weight: var(--brand-weight-bold);
    justify-content: center;
    margin-top: 0.55rem;
    padding: 0.45rem 0.75rem;
    width: 100%;
  }

  .workorder-revision-children {
    margin-left: 0.55rem;
    padding-left: 0.55rem;
  }

  .revision-compact-row {
    gap: 0.5rem;
    padding: 0.7rem;
  }

  .revision-compact-main {
    align-items: start;
    gap: 0.25rem;
    grid-template-columns: 1fr;
  }

  .revision-compact-date {
    display: block;
  }

  .revision-detail-toggle {
    font-size: 1rem;
    font-weight: var(--brand-weight-bold);
    height: 34px;
    min-height: 34px;
    min-width: 34px;
    width: 34px;
  }

  .revision-compact-number {
    font-size: 0.95rem;
  }

  .revision-expanded-details {
    font-size: 0.78rem;
    padding: 0.6rem;
  }
}

/* =========================================================
  8. MOBILE TABS
========================================================= */
@media (max-width: 767.98px) {
  .mobile-tabs {
    display: flex;
    gap: 0.4rem;
    padding: 0.35rem;
  }

  .mobile-tab-btn {
    background: transparent;
    border: 0;
    border-radius: var(--radius-md);
    flex: 1;
    font-size: 0.82rem;
    font-weight: var(--brand-weight-semibold);
    min-height: 38px;
  }
}

/* =========================================================
  9. MOBILE ACTION DOCK
========================================================= */
@media (max-width: 767.98px) {
  .workorder-actions {
    align-items: stretch;
    bottom: 0.35rem !important;
    display: grid !important;
    gap: 0.75rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    left: 0.5rem !important;
    max-width: none !important;
    padding: 0.45rem !important;
    right: 0.5rem !important;
    transform: none !important;
    width: auto !important;
  }

  .workorder-layout.showing-detail .workorder-actions {
    left: 0.5rem !important;
    transform: none !important;
  }

  .workorder-actions .btn {
    align-items: center;
    display: inline-flex;
    font-size: 0.7rem !important;
    justify-content: center;
    line-height: 1.05 !important;
    min-height: 44px;
    padding: 0.35rem 0.2rem !important;
    text-align: center;
    white-space: normal !important;
    word-break: normal;
  }
}

/* =========================================================
  10. SETTINGS MOBILE SAVE BAR
========================================================= */
@media (max-width: 767.98px) {
  .settings-save-bar {
    justify-content: stretch;
  }

  .settings-save-bar .btn {
    min-width: 0;
    width: 100%;
  }
}
