/*
 * WrenchPress customer portal: STRUCTURAL styles only.
 *
 * Same locked approach as the visit-request form (assets/css/visit-form.css):
 * this stylesheet ships layout, spacing, shape, and exactly one guaranteed focus
 * indicator, and it declares NO colour and NO typography. The portal therefore
 * adopts the host builder/theme's palette, font, and button styling and looks
 * native inside DIVI, Elementor, or any theme instead of looking like a plugin.
 *
 * Anything the portal genuinely has to draw (dividers, the notice rule, the
 * focus ring) is drawn in currentColor, which is the element's own inherited
 * text colour and therefore carries the theme's own text-contrast ratio. A theme
 * whose body text is legible is already well over the 3:1 that WCAG 2.2 SC
 * 1.4.11 asks of a border or a focus ring, so the contrast is correct by
 * construction rather than by guessing a hex.
 *
 * The --egcrm-* custom-property NAMES are shared with the visit form on purpose:
 * a theme that already overrides them for the form styles the portal identically.
 * The wrapper class is .egcrm-portal (not .egcrm-form) so the two surfaces can
 * diverge structurally without cross-contamination.
 *
 * Selectors are low-specificity and scoped to .egcrm-portal. There is no bare
 * element selector and no !important anywhere in this file, so the host
 * builder/theme cascade wins.
 */
.egcrm-portal {
  /* Spacing and shape. */
  --egcrm-radius: 8px;
  --egcrm-field-radius: 6px;
  --egcrm-gap-x: 16px;
  --egcrm-gap-y: 16px;
  --egcrm-section-gap: 24px;
  --egcrm-region-gap: 32px;
  --egcrm-padding: 24px;

  /* Label / helper sizing, relative so it scales with the theme's font size. */
  --egcrm-label-size: 0.8125em;
  --egcrm-label-weight: 600;
  --egcrm-helper-size: 0.8125em;
  --egcrm-fine-size: 0.75em;

  /* Form fields. */
  --egcrm-field-padding-y: 8px;
  --egcrm-field-padding-x: 12px;
  --egcrm-field-height: 40px;

  /* Buttons: shape only. Colour belongs to the theme. */
  --egcrm-btn-radius: 6px;
  --egcrm-btn-padding-y: 12px;
  --egcrm-btn-padding-x: 16px;
  --egcrm-btn-font-weight: 600;

  /* Layout. No color, no background, no font: the portal inherits all three. */
  padding: var(--egcrm-padding);
  border-radius: var(--egcrm-radius);
  max-width: 880px;
  width: 100%;
  box-sizing: border-box;
}

.egcrm-portal *,
.egcrm-portal *::before,
.egcrm-portal *::after {
  box-sizing: border-box;
}

/*
 * THE FOCUS INDICATOR. The one visual guarantee the plugin makes on the front
 * end, non-negotiable (WCAG SC 2.4.7). outline (not box-shadow) re-declared at
 * (0,2,0) beats a theme's outline reset; :focus-visible so a mouse click paints
 * nothing but keyboard focus does; currentColor so it works on a white page, a
 * dark hero, and everything between; every focusable DESCENDANT, not just inputs.
 */
.egcrm-portal :focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 2px;
}

/* Visually hidden, for text only assistive tech should hear. */
.egcrm-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/*
 * Header: the portal title plus the sign-out control (dashboard) or just the
 * title/subtitle (request form). Softened currentColor rule so it reads as a
 * divider rather than a hard border.
 */
.egcrm-portal__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: var(--egcrm-section-gap);
  padding-bottom: 16px;
  border-bottom: 1px solid;
  border-bottom-color: var(--egcrm-divider, currentColor);
}

@supports (color: color-mix(in srgb, currentColor 20%, transparent)) {
  .egcrm-portal__header {
    border-bottom-color: var(--egcrm-divider, color-mix(in srgb, currentColor 20%, transparent));
  }

  .egcrm-portal__vehicle {
    border-color: var(--egcrm-section-border, color-mix(in srgb, currentColor 20%, transparent));
  }

  .egcrm-portal__workorder {
    border-top-color: var(--egcrm-divider, color-mix(in srgb, currentColor 20%, transparent));
  }
}

.egcrm-portal__title {
  margin: 0;
  line-height: 1.2;
}

.egcrm-portal__subtitle {
  margin: 4px 0 0;
  font-size: var(--egcrm-helper-size);
}

/*
 * Status notice. Mirrors the visit form's .egcrm-form__notice: a left rule in
 * currentColor, success and error told apart ONLY by a bold text prefix, never
 * by colour (SC 1.4.1 by subtraction).
 */
.egcrm-portal__notice {
  margin-bottom: var(--egcrm-section-gap);
  padding: 12px 16px;
  border-left: 4px solid currentColor;
  border-radius: var(--egcrm-field-radius);
}

/* Dashboard regions: Current visit, Your vehicles. */
.egcrm-portal__region {
  margin-bottom: var(--egcrm-region-gap);
}

.egcrm-portal__region-title {
  margin: 0 0 var(--egcrm-gap-y);
  font-size: var(--egcrm-label-size);
  font-weight: var(--egcrm-label-weight);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Empty-state blocks. */
.egcrm-portal__empty-title {
  margin: 0 0 4px;
  font-size: 1em;
  font-weight: var(--egcrm-label-weight);
}

.egcrm-portal__empty-body {
  margin: 0;
  font-size: var(--egcrm-helper-size);
}

/* Vehicle card. */
.egcrm-portal__vehicle {
  border: 1px solid;
  border-radius: var(--egcrm-radius);
  padding: 20px;
  margin-bottom: var(--egcrm-section-gap);
}

.egcrm-portal__vehicle-title {
  margin: 0 0 4px;
  line-height: 1.2;
}

.egcrm-portal__vehicle-meta {
  margin: 0 0 var(--egcrm-section-gap);
  font-size: var(--egcrm-helper-size);
}

.egcrm-portal__history-title {
  margin: 0 0 var(--egcrm-gap-y);
  font-size: var(--egcrm-label-size);
  font-weight: var(--egcrm-label-weight);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* One work order inside a vehicle's service history. */
.egcrm-portal__workorder {
  padding-top: var(--egcrm-gap-y);
  margin-top: var(--egcrm-gap-y);
  border-top: 1px solid;
  border-top-color: var(--egcrm-divider, currentColor);
}

.egcrm-portal__workorder:first-child {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
}

.egcrm-portal__wo-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: var(--egcrm-gap-y);
}

.egcrm-portal__wo-title {
  margin: 0;
  font-size: 1em;
  font-weight: var(--egcrm-label-weight);
}

.egcrm-portal__wo-date {
  font-size: var(--egcrm-helper-size);
}

/* Status shown as a bold text label (colour-free fallback per the UI-SPEC). */
.egcrm-portal__status {
  font-weight: var(--egcrm-label-weight);
}

/* Read-only line-items mirror. */
.egcrm-portal__items {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--egcrm-gap-y);
}

.egcrm-portal__items th,
.egcrm-portal__items td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid;
  border-bottom-color: var(--egcrm-divider, currentColor);
  vertical-align: top;
}

.egcrm-portal__items th {
  font-size: var(--egcrm-label-size);
  font-weight: var(--egcrm-label-weight);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.egcrm-portal__items .egcrm-portal__num {
  text-align: right;
  white-space: nowrap;
}

@supports (color: color-mix(in srgb, currentColor 20%, transparent)) {
  .egcrm-portal__items th,
  .egcrm-portal__items td {
    border-bottom-color: var(--egcrm-divider, color-mix(in srgb, currentColor 20%, transparent));
  }
}

/* Totals block under the items table. */
.egcrm-portal__totals {
  width: 100%;
  border-collapse: collapse;
  margin-left: auto;
}

.egcrm-portal__totals th,
.egcrm-portal__totals td {
  padding: 4px 12px;
  text-align: right;
}

.egcrm-portal__totals th {
  font-weight: 400;
  font-size: var(--egcrm-helper-size);
}

.egcrm-portal__totals .egcrm-portal__grand th,
.egcrm-portal__totals .egcrm-portal__grand td {
  font-weight: var(--egcrm-label-weight);
}

/* Fields (request form). Reuse the visit-form field shape. */
.egcrm-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.egcrm-field--full {
  width: 100%;
}

.egcrm-field__label {
  font-size: var(--egcrm-label-size);
  font-weight: var(--egcrm-label-weight);
}

.egcrm-field__input {
  width: 100%;
  height: var(--egcrm-field-height);
  background-color: var(--egcrm-field-bg, transparent);
  border-radius: var(--egcrm-field-radius);
  padding: var(--egcrm-field-padding-y) var(--egcrm-field-padding-x);
  font: inherit;
  appearance: none;
}

.egcrm-portal .egcrm-field__input {
  border: 1px solid var(--egcrm-field-border, currentColor);
}

.egcrm-field__input:focus {
  box-shadow: 0 0 0 3px var(--egcrm-field-ring, currentColor);
}

@supports (color: color-mix(in srgb, currentColor 20%, transparent)) {
  .egcrm-field__input:focus {
    box-shadow: 0 0 0 3px var(--egcrm-field-ring, color-mix(in srgb, currentColor 20%, transparent));
  }
}

/* Form actions row. */
.egcrm-portal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: var(--egcrm-section-gap);
}

.egcrm-portal__signout {
  margin: 0;
}

/*
 * Buttons: shape only, no colour. Real <button> elements, so the theme's own
 * button rules apply with zero plugin competition. 44px min touch target
 * (SC 2.5.8) on every interactive control.
 */
.egcrm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--egcrm-btn-radius);
  padding: var(--egcrm-btn-padding-y) var(--egcrm-btn-padding-x);
  min-height: 44px;
  font: inherit;
  font-weight: var(--egcrm-btn-font-weight);
  cursor: pointer;
}

/* Visually hidden honeypot: off-screen rather than display:none. */
.egcrm-portal__hp {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@media (max-width: 640px) {
  .egcrm-portal__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .egcrm-portal__totals {
    width: 100%;
  }
}
