/* =========================================================
   WORKFLOW-COMPONENTS.CSS
   Shared work order and quote component structure.

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

/* =========================================================
   1. WORKORDER LIST ITEM STRUCTURE
========================================================= */
.workorder-list-item {
  cursor: pointer;
  margin-bottom: 0.65rem;
  overflow: hidden;
  padding: 1rem 1rem 1rem 1.5rem;
  position: relative;
  transition:
    background-color var(--transition-normal),
    box-shadow var(--transition-normal),
    transform var(--transition-normal);
  z-index: 1;
}

.workorder-list-item::before {
  bottom: 0;
  content: "";
  left: 0;
  position: absolute;
  top: 0;
  transition: width var(--transition-normal);
  width: 6px;
}

.workorder-list-item:hover {
  transform: translateY(-1px);
}

.workorder-list-item.active,
.workorder-list-item.active:hover,
.workorder-list-item.active:focus {
  outline: none;
  transform: none;
  z-index: 2;
}

.workorder-list-item.active::before {
  width: 8px;
}

.workorder-list-item.active *,
.workorder-list-item.active:hover *,
.workorder-list-item.active:focus * {
  color: inherit;
}

/* =========================================================
   2. STATUS PILLS
========================================================= */
.status-pill {
  border-radius: var(--radius-pill);
  display: inline-flex;
  font-size: var(--brand-font-small);
  font-weight: var(--brand-weight-semibold);
  line-height: 1;
  margin-left: 0.5rem;
  padding: 0.35rem 0.65rem;
  white-space: nowrap;
}

/* =========================================================
   3. WORKORDER / QUOTE FORM STRUCTURE
========================================================= */
.workorder-form {
  max-width: 1600px;
}

.workorder-form fieldset {
  display: grid;
  gap: 1rem;
}

.workorder-form label,
.workorder-form .form-label {
  font-size: var(--brand-font-label);
  font-weight: var(--brand-weight-semibold);
  margin-bottom: 0.28rem;
}

.workorder-form textarea.form-control {
  min-height: 112px;
}

.workorder-search,
.workorder-form .form-control,
.workorder-form .form-select {
  border-radius: var(--radius-md);
}

.workorder-section {
  padding: 0.95rem 1rem;
}

.workorder-section-title {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.workorder-section-title h3 {
  font-size: var(--brand-font-section-title);
  font-weight: var(--brand-weight-bold);
  line-height: 1.15;
  margin: 0;
}

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

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

.section-kicker {
  font-size: var(--brand-font-small);
  font-weight: var(--brand-weight-bold);
  letter-spacing: 0;
  text-transform: uppercase;
}

.workorder-header-note {
  font-size: var(--brand-font-label);
  line-height: 1.35;
  max-width: 240px;
  text-align: right;
}

.workorder-new-button {
  align-items: center;
  border: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  font-weight: var(--brand-weight-semibold);
  gap: 0.5rem;
  justify-content: center;
  padding: 0.7rem 0.9rem;
}

.workorder-new-button span {
  font-size: 1.25rem;
  line-height: 1;
}

/* =========================================================
   4. FORM FOCUS / STATUS SELECT STRUCTURE
========================================================= */
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
  border-color: var(--app-primary) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--app-primary), transparent 82%);
}

select.dynamic-styled-select {
  border-width: 1px;
  font-weight: 600;
}

select.dynamic-styled-select:hover,
select.dynamic-styled-select:focus {
  border-color: var(--status-color, var(--app-primary)) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-color, var(--app-primary)), transparent 82%) !important;
}

/* =========================================================
   5. JOB STATUS / ETA LAYOUT
========================================================= */
.workorder-job-status-row {
  align-items: end;
}

@media (min-width: 768px) {
  .workorder-job-status-row > .col-md-2 { width: 14%; }
  .workorder-job-status-row > .col-md-3 { width: 22%; }
  .workorder-job-status-row > .col-md-4 { width: 42%; }
}

.workorder-eta-group {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
}

.workorder-eta-group input[type="date"] {
  flex: 1 1 0;
  min-width: 135px;
  padding-right: 2.2rem !important;
}

.workorder-eta-group .form-select {
  flex: 0 0 130px;
  min-width: 130px;
}


/* =========================================================
   6. QUOTE DENSITY / PRICING TABLE STRUCTURE
========================================================= */
.quote-line-table {
  margin-bottom: 0 !important;
  table-layout: fixed;
}

.quote-line-table th,
.quote-line-table td {
  padding: 0.48rem 0.5rem !important;
  vertical-align: middle !important;
}

.quote-line-table thead th {
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
}

.quote-line-table .form-control,
.quote-line-table .form-control-sm {
  font-size: 0.84rem;
  min-height: 34px;
  padding: 0.32rem 0.5rem !important;
}

.quote-line-description {
  width: 100%;
}

.quote-line-qty,
.quote-line-rate {
  text-align: right;
}

.quote-qty-column,
.quote-rate-column {
  width: 110px;
}

.quote-amount-column,
.quote-line-amount {
  text-align: right;
  width: 130px;
}

.quote-line-amount {
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.quote-remove-column,
.quote-line-table th:last-child,
.quote-line-table td:last-child {
  text-align: right;
  width: 108px;
}

.quote-line-table td:last-child .btn,
.quote-line-table .btn-outline-danger {
  align-items: center;
  display: inline-flex;
  font-size: 0.76rem;
  justify-content: center;
  min-height: 34px;
  padding: 0.26rem 0.55rem !important;
  white-space: nowrap;
}

.quote-total-panel {
  align-items: start;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(180px, 260px) minmax(240px, 320px);
  justify-content: space-between;
  margin-top: 0.9rem;
}

.quote-total-panel .form-label {
  margin-bottom: 0.28rem;
}

.quote-total-lines {
  display: grid;
  gap: 0.32rem;
}

.quote-total-lines > div {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  line-height: 1.25;
}

.quote-total-lines span {
  color: var(--app-text-muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.quote-total-lines strong {
  font-size: 0.92rem;
  white-space: nowrap;
}

.quote-grand-total {
  border-top: 1px solid var(--app-border);
  font-size: 1.05rem;
  margin-top: 0.32rem;
  padding-top: 0.48rem;
}

.quote-grand-total strong {
  font-size: 1.08rem;
}

@media (max-width: 767.98px) {
  .quote-line-table {
    min-width: 720px;
  }

  .quote-total-panel {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   8. FLOATING ACTION BUTTONS / DOCK STRUCTURE
========================================================= */
.workorder-actions {
  align-items: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  bottom: 0.25rem;
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  left: 50%;
  max-width: calc(100vw - 2rem);
  padding: 0.5rem 1rem;
  position: fixed;
  transform: translateX(-50%);
  width: max-content;
  z-index: 1000;
}

.workorder-actions .btn {
  border-radius: var(--radius-lg);
  font-weight: var(--brand-weight-semibold);
  height: 40px;
}

/* =========================================================
   9. WORK ORDER REVISIONS STRUCTURE
========================================================= */
.workorder-revision-group {
  margin-bottom: 0.65rem;
}

.workorder-revision-group > .workorder-list-item {
  margin-bottom: 0.35rem;
}

.revision-group-toggle {
  background: transparent;
  border: 0;
  display: inline-flex;
  font-size: var(--brand-font-small);
  font-weight: var(--brand-weight-semibold);
  margin-top: 0.45rem;
  padding: 0;
}

.workorder-revision-children {
  border-left: 2px solid var(--app-border);
  display: grid;
  gap: 0.4rem;
  margin-left: 1rem;
  padding-left: 0.75rem;
}

.revision-compact-row {
  border-radius: var(--radius-md);
  display: grid;
  gap: 0.35rem;
  padding: 0.5rem;
}

.revision-detail-toggle {
  align-items: center;
  border-radius: var(--radius-pill);
  display: inline-flex;
  font-weight: var(--brand-weight-bold);
  height: 24px;
  justify-content: center;
  line-height: 1;
  width: 24px;
}

.revision-compact-main {
  align-items: center;
  background: transparent;
  border: 0;
  display: grid;
  gap: 0.35rem;
  grid-template-columns: 1fr auto auto;
  padding: 0;
  text-align: left;
  width: 100%;
}

.revision-compact-number {
  font-weight: var(--brand-weight-bold);
}

.revision-compact-date {
  font-size: var(--brand-font-small);
  white-space: nowrap;
}

.revision-expanded-details {
  border-top: 1px solid var(--app-border);
  display: grid;
  font-size: var(--brand-font-small);
  gap: 0.25rem;
  line-height: 1.35;
  margin-top: 0.35rem;
  padding-top: 0.45rem;
}

/* =========================================================
   WORKORDER NOTES LAYOUT
   Separates notes fields from technician picker/hours row.
========================================================= */
.workorder-notes-layout {
  margin-top: 0.65rem;
}

/* =========================================================
   WORKORDER SECTION HEADERS
   Shared alignment/rhythm for paired workorder panels.
========================================================= */
.workorder-section-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
  min-height: 24px;
}

/* =========================================================
   WORKORDER FIELD HEADERS
   Shared row for labels with optional field actions.
========================================================= */
.workorder-field-header {
  align-items: center;
  column-gap: 0.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  height: 1.7rem;
  margin-bottom: 0.28rem;
}

.workorder-form .workorder-field-header label,
.quote-form .workorder-field-header label {
  align-items: center;
  display: flex;
  height: 100%;
  line-height: 1.2;
  margin: 0 !important;
  min-height: 0;
}

.workorder-field-header .btn {
  align-items: center;
  display: inline-flex;
  height: 100%;
  line-height: 1.2;
  min-height: 0;
  padding-bottom: 0 !important;
  padding-top: 0 !important;
}
