/* =========================================================
   LAYOUT.CSS
   Application shell, navbar, sidebar, and page structure.

   This file owns layout and spacing only.
   Visual surfaces/colors live in surfaces.css and page theme files.
========================================================= */

/* =========================================================
   1. BASE DOCUMENT LAYOUT
========================================================= */
html {
  font-size: 14px;
  min-height: 100%;
  position: relative;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  background: var(--app-page-bg);
  color: var(--app-text);
  margin-bottom: 0;
}

body > main.container-fluid {
  padding-left: 1.25rem !important;
  padding-right: 1.25rem !important;
}

/* =========================================================
   2. NAVBAR LAYOUT
========================================================= */
.navbar {
  height: 52px !important;
  max-height: 52px !important;
  min-height: 52px !important;
  overflow: visible !important;
  padding: 0 !important;
}

.navbar .container-fluid,
.navbar .container-xxl {
  align-items: center !important;
  display: flex !important;
  height: 100% !important;
}




.navbar-brand {
  align-items: center !important;
  display: flex !important;
  height: 100% !important;
  margin: 0 1.5rem 0 0 !important;
  padding: 0 !important;
}


.app-navbar-main {
  align-items: center;
  display: flex;
  gap: 2rem;
  justify-content: space-between;
  width: 100%;
}

.app-navbar-nav {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: 1.25rem;
  min-width: 0;
  white-space: nowrap;
}

.app-navbar-auth {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 0.75rem;
  margin-left: auto;
  white-space: nowrap;
}

.navbar-brand-logo {
  display: block !important;
  height: 32px !important;
  max-height: 32px !important;
  object-fit: contain !important;
  width: auto !important;
}






.navbar-auth-actions {
  align-items: center;
  display: flex;
}

.navbar-auth-actions .btn,
.navbar-auth-actions form {
  margin: 0;
}

.navbar-auth-actions .btn {
  min-height: 36px;
}


/* =========================================================
   3. WORK ORDER / QUOTE SHELL LAYOUT
========================================================= */
.workorder-shell {
  border: 0;
  margin: 0;
  overflow: visible;
  padding: 0;
  width: 100%;
}

.workorder-layout {
  --workorder-nav-height: 52px;
  min-height: calc(100vh - var(--workorder-nav-height));
  padding-top: 0.75rem;
}

.workorder-sidebar,
.workorder-detail {
  height: calc(100vh - 52px);
  overflow-y: auto;
}

.workorder-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem !important;
  padding: 0 0.9rem 1rem;
}

.workorder-detail {
  padding: 0 0.9rem 6rem;
  position: relative;
}

/* =========================================================
   4. SIDEBAR PANELS
========================================================= */
.workorder-sidebar-header,
.workorder-sidebar-controls,
.workorder-sidebar-list {
  margin: 0 !important;
}

.workorder-sidebar-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 48px;
  padding: 0.65rem 0.85rem;
}

.workorder-sidebar-header h1,
.workorder-sidebar-header h2,
.workorder-sidebar-header h3 {
  font-size: 1rem;
  line-height: 1.1;
  margin: 0;
}

.workorder-sidebar-controls {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.75rem;
}

.workorder-sidebar-list {
  padding: 0.6rem;
}

.workorder-sidebar .workorder-new-button,
.workorder-sidebar .workorder-search {
  margin: 0 !important;
}

#workOrderList,
#quoteList {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

/* =========================================================
   5. DETAIL HEADER / FORM FLOW
========================================================= */
.workorder-detail-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 0 0.75rem 0 !important;
  min-height: 48px;
  padding: 0.65rem 0.85rem;
}

.workorder-detail-header h1,
.workorder-detail-header h2,
.workorder-detail-header h3 {
  font-size: 1rem;
  line-height: 1.1;
  margin: 0;
}

.workorder-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-width: 1600px;
}

.workorder-form fieldset {
  display: contents;
}

.workorder-tab-layout,
#tab-info.workorder-tab-content.active,
.workorder-tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.workorder-section {
  margin: 0 !important;
  padding: 0.9rem 1rem;
}

.workorder-section .mb-3 {
  margin-bottom: 1rem !important;
}

.workorder-section .row.g-3 {
  --bs-gutter-y: 0.75rem;
}

/* =========================================================
   6. PAGE MICROCOPY
========================================================= */
.page-mini-subtitle {
  font-size: 0.72rem !important;
  line-height: 1.2;
  margin-top: 0.15rem;
}

/* =========================================================
   7. MOBILE RHYTHM
========================================================= */
@media (max-width: 767.98px) {
  body > main.container-fluid {
    padding-left: 0.85rem !important;
    padding-right: 0.85rem !important;
  }

  .workorder-shell {
    width: 100%;
  }

  .workorder-sidebar,
  .workorder-detail {
    height: auto;
    padding-top: 1rem;
  }

  .workorder-sidebar {
    border-right: 0;
    padding-left: 0;
    padding-right: 0;
  }

  .workorder-detail {
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 6.5rem;
  }

  .workorder-detail-header {
    margin-bottom: 1rem !important;
    min-height: auto;
    padding: 0.85rem;
  }

  .workorder-sidebar-header {
    min-height: auto;
  }

  .workorder-form {
    gap: 0.85rem;
  }
}

/* 🔥 MIGRATED FROM FINAL-POLISH: 10. UNIFIED SPACING RHYTHM - LAYOUT */
/* =========================================================
  8. UNIFIED SPACING RHYTHM
  Shared spacing variables and layout-level rhythm.
========================================================= */
:root {
  --ui-gap-xs: 0.25rem;
  --ui-gap-sm: 0.5rem;
  --ui-gap-md: 0.75rem;
  --ui-gap-lg: 1rem;
  --ui-header-padding-y: 0.65rem;
  --ui-header-padding-x: 0.9rem;
  --ui-panel-padding-y: 0.85rem;
  --ui-panel-padding-x: 1rem;
  --ui-card-padding-y: 0.7rem;
  --ui-card-padding-x: 0.85rem;
  --ui-table-padding-y: 0.55rem;
  --ui-table-padding-x: 0.65rem;
  --ui-control-min-height: 36px;
}

.app-page,
.workorder-form,
.workorder-tab-layout,
#tab-info.workorder-tab-content.active,
.schedule-page,
.settings-page,
.quotes-page {
  gap: var(--ui-gap-md) !important;
}

.schedule-top-grid,
.schedule-dispatch-layout,
.app-page-grid,
.settings-layout,
.workorder-layout > .row,
.workorder-sidebar,
.workorder-detail {
  gap: var(--ui-gap-md) !important;
}

.app-page-header,
.workorder-detail-header,
.workorder-sidebar-header,
.schedule-title-card,
.schedule-controls-card,
.schedule-board-titlebar,
.settings-header,
.quotes-header,
.card-header,
.workorder-materials-panel .workorder-section-title,
.workorder-materials-panel > .d-flex:first-child,
.workorder-materials-panel > .d-flex.justify-content-between:first-child {
  align-items: center !important;
  display: flex !important;
  min-height: var(--app-header-height) !important;
  padding: var(--ui-header-padding-y) var(--ui-header-padding-x) !important;
}

.app-page-header h1,
.app-page-header h2,
.workorder-detail-header h1,
.workorder-detail-header h2,
.workorder-sidebar-header h1,
.workorder-sidebar-header h2,
.workorder-sidebar-header h3,
.schedule-page-title,
.schedule-board-titlebar h2,
.settings-header h1,
.settings-panel .card-header h5,
.quotes-header h1,
.workorder-materials-panel h3,
.workorder-materials-panel h4,
.workorder-materials-panel h5 {
  line-height: 1.15 !important;
  margin: 0 !important;
}

.app-section-card,
.app-panel,
.workorder-section,
.workorder-sidebar-controls,
.workorder-sidebar-list,
.settings-section,
.settings-card,
.quote-section,
.quote-card,
.card-body,
.settings-panel .card-body {
  padding: var(--ui-panel-padding-y) var(--ui-panel-padding-x) !important;
}

.app-toolbar,
.app-page-toolbar,
.schedule-header-actions,
.schedule-board-title-group,
.settings-save-bar,
.workorder-actions,
.dispatch-toolbar,
.card-header .d-flex,
.workorder-materials-panel .d-flex {
  align-items: center !important;
  gap: var(--ui-gap-sm) !important;
}

.schedule-header-actions .btn,
.schedule-header-actions .dropdown-toggle,
.settings-panel .btn,
.settings-save-bar .btn,
.workorder-actions .btn,
.workorder-materials-panel .btn {
  align-items: center !important;
  display: inline-flex !important;
  justify-content: center !important;
  min-height: var(--ui-control-min-height) !important;
}

.table th,
.table td,
.material-entry-table th,
.material-entry-table td {
  padding: var(--ui-table-padding-y) var(--ui-table-padding-x) !important;
  vertical-align: middle !important;
}

.material-entry-table input,
.material-entry-table textarea,
.material-entry-table .form-control,
.form-control,
.form-select,
.input-group-text {
  min-height: var(--ui-control-min-height) !important;
}

.dispatch-empty-cell,
.mobile-empty-jobs,
.mobile-no-work-today,
.empty-state,
.no-results,
.schedule-summary-pill,
.status-pill,
.badge,
.quote-total-badge,
.wo-status-badge,
.quote-status-badge {
  align-items: center !important;
  display: inline-flex !important;
  justify-content: center !important;
  text-align: center !important;
}

.dispatch-empty-cell,
.mobile-empty-jobs,
.mobile-no-work-today,
.empty-state,
.no-results {
  min-height: 42px !important;
  width: 100%;
}

.dispatch-empty-cell {
  opacity: 0.58 !important;
}

.dispatch-day-cell:hover .dispatch-empty-cell,
.dispatch-day-cell.drag-over .dispatch-empty-cell,
.dispatch-empty-cell:hover {
  opacity: 0.82 !important;
}
/* 🔥 END MIGRATED FROM FINAL-POLISH: 10. UNIFIED SPACING RHYTHM - LAYOUT */
