/* Logaid - Main Stylesheet */

:root {
  /* =====================================================
   * LOGAID TYPOGRAPHY SCALE
   * Central location for all text sizing
   * Uses rem units to respect user accessibility settings
   * ===================================================== */

  /* Font Sizes */
  --logaid-text-xs: 0.8125rem;  /* 13px - tags, chips, badges, activity excerpts */
  --logaid-text-sm: 0.85rem;    /* 13.6px - secondary info, metadata */
  --logaid-text-base: 0.95rem;  /* 15.2px - body text, paragraphs */
  --logaid-text-lg: 1.05rem;    /* 16.8px - item titles, emphasized text */
  --logaid-text-xl: 1.2rem;     /* 19.2px - section headers */
  --logaid-text-2xl: 1.5rem;    /* 24px - page titles */
  --logaid-text-3xl: 2rem;      /* 32px - large stats, hero text */

  /* Font Weights */
  --logaid-weight-normal: 400;
  --logaid-weight-medium: 500;
  --logaid-weight-semibold: 600;
  --logaid-weight-bold: 700;

  /* Line Heights */
  --logaid-leading-tight: 1.2;
  --logaid-leading-normal: 1.5;
  --logaid-leading-relaxed: 1.75;

  /* =====================================================
   * LOGAID COLOR PALETTE
   * Central location for all app colors
   * ===================================================== */

  /* Primary Brand Color - Cyan
   *
   * #0e7490 (Tailwind cyan 700) is THE brand colour: the same value as the
   * logo, the icon set, the email header and the PWA theme colour. One colour,
   * everywhere. Change it here and in the four non-CSS carriers that cannot
   * read a CSS variable — see the sweep list in the retheme task.
   *
   * Contrast, measured. White on primary is 5.36:1 — AA for normal text, not
   * AAA. That is one step lighter than the #155e75 it replaced (7.27:1) and is
   * a deliberate trade for the brighter read; the margin over AA is 0.86, so
   * the rule is: do not put white text on a *reduced-opacity* primary, and do
   * not shrink it below normal body size. Derived pairings all clear AA —
   * white on dark 10.08:1, white on darker 13.69:1, text on primary-light
   * 13.43:1. The thinnest is primary-coloured text on a primary-light ground
   * at 4.67:1: passing, but it has no room left, so nothing may be layered on
   * top of that pairing.
   *
   * Sits far from every severity colour — nearest is `info` at dE 34, and
   * those two never share a role: info is a passive callout, primary is
   * buttons and links. Everything else is dE 80+. */
  --logaid-primary: #0e7490;
  --logaid-primary-rgb: 14, 116, 144;
  --logaid-primary-light: #e7f1f4;      /* Very light cyan for backgrounds */
  --logaid-primary-lighter: #f4f8fa;    /* Even lighter for subtle highlights */
  --logaid-primary-dark: #094859;       /* Darker for hover states */
  --logaid-primary-darker: #06323e;     /* Deeper still — :active, since dark is now hover */

  /* The auth / onboarding page ground. One definition: six views each carried
   * their own copy of the same gradient before this. */
  --logaid-brand-gradient: linear-gradient(135deg, var(--logaid-primary) 0%, var(--logaid-primary-dark) 100%);

  /* Secondary Colors */
  --logaid-secondary: #5260ff;
  --logaid-secondary-light: #eef0ff;

  /* Neutral Colors */
  --logaid-gray-50: #f8f9fa;
  --logaid-gray-100: #f1f3f5;
  --logaid-gray-200: #e9ecef;
  --logaid-gray-300: #dee2e6;
  --logaid-gray-400: #ced4da;
  --logaid-gray-500: #adb5bd;
  --logaid-gray-600: #6c757d;
  --logaid-gray-700: #495057;
  --logaid-gray-800: #343a40;
  --logaid-gray-900: #212529;

  /* Semantic Colors */
  --logaid-success: #2dd36f;
  --logaid-success-light: #e8faf0;
  --logaid-warning: #ffc409;
  --logaid-warning-light: #fff9e6;
  --logaid-warning-strong: #b45309;     /* amber for text/outlines — the fill yellow is unreadable there */
  --logaid-danger: #eb445a;
  --logaid-danger-light: #fdecef;
  --logaid-info: #3dc2ff;
  --logaid-info-light: #e6f7ff;

  /* Priority Colors - yellow to red gradient */
  /* Priority palette — larger perceptual steps between levels so the
   * left-side mobile bar reads at a glance. Hue moves red → amber → gray,
   * not red → orange → amber (which all blur together). */
  --logaid-priority-none: #9ca3af;      /* gray — same as low for "not urgent" */
  --logaid-priority-low: #9ca3af;       /* gray (gray-400) */
  --logaid-priority-medium: #f59e0b;    /* amber (amber-500) */
  --logaid-priority-high: #dc2626;      /* red (red-600) */
  --logaid-priority-none-contrast: white;
  --logaid-priority-low-contrast: white;
  --logaid-priority-medium-contrast: #000000;
  --logaid-priority-high-contrast: white;

  /* Text Colors */
  --logaid-text-primary: var(--logaid-gray-900);
  --logaid-text-secondary: var(--logaid-gray-600);
  --logaid-text-muted: var(--logaid-gray-500);
  --logaid-text-on-primary: #ffffff;

  /* Border Colors */
  --logaid-border: var(--logaid-gray-200);
  --logaid-border-focus: var(--logaid-primary);

  /* Background Colors */
  --logaid-bg-page: #ffffff;
  --logaid-bg-surface: var(--logaid-gray-50);
  --logaid-bg-surface-hover: var(--logaid-gray-100);
  --logaid-bg-selected: var(--logaid-primary-light);
  --logaid-bg-selected-hover: #dcebef;  /* a step down from primary-light */

}

/* =====================================================
 * IONIC OVERRIDES
 * Map our palette to Ionic's CSS variables
 * =====================================================
 *
 * `:root:root`, not `:root`, and the doubling is load-bearing.
 *
 * Ionic's own core.css declares `:root { --ion-color-primary: #0054e9 }`, and
 * it lands AFTER this file in every target: under Laravel the @vite array puts
 * app.css first and app.ts's extracted CSS second; under `npm run dev` Ionic's
 * styles are injected as <style> tags at runtime, so they are always last; the
 * Cloudflare build links this file from index.html ahead of the entry chunk.
 * At equal specificity the later rule wins, so for a long time these overrides
 * silently did nothing and every `color="primary"` Ionic component — the app
 * header included — rendered Ionic's blue while this file claimed otherwise.
 *
 * Doubling the selector takes specificity to (0,2,0) and settles it wherever
 * the file is loaded. Do not "simplify" this back to a single `:root`, and do
 * not try to fix it by reordering imports — the dev server's runtime injection
 * cannot be ordered against. */
:root:root {
  --ion-color-primary: var(--logaid-primary);
  --ion-color-primary-rgb: var(--logaid-primary-rgb);
  --ion-color-primary-contrast: var(--logaid-text-on-primary);
  --ion-color-primary-contrast-rgb: 255, 255, 255;
  --ion-color-primary-shade: var(--logaid-primary-dark);
  --ion-color-primary-tint: var(--logaid-primary-light);
}

/* Global styles */
body {
  margin: 0;
  padding: 0;
}

/* iOS mode hardcodes 1.75rem/700 on :host, ignoring --ion-card-title-font-size.
 * External selector overrides Shadow DOM :host defaults in both modes. */
ion-card-title {
  font-size: 1.25rem;
  font-weight: 600;
}

/* =====================================================
 * DESKTOP LAYOUT - Constrain content width for readability
 * Applies max-width to the app container on large screens
 * ===================================================== */
@media (--bp-lg) {
  #app > * {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 2rem rgba(0, 0, 0, 0.1);
  }
}

/* Remove horizontal margins/padding on cards, lists, and items inside padded containers
   so they align with the container's edges */
.ion-padding ion-card,
.ion-padding ion-list {
  margin-left: 0;
  margin-right: 0;
}

/* Only remove item padding when explicitly requested via utility class */
.logaid-flush-items ion-item {
  --padding-start: 0;
  --padding-end: 0;
  --inner-padding-end: 0;
}


/* =====================================================
 * LOGAID SELECTION STATES
 * Consistent styling for selectable items (radio buttons,
 * list selections, etc.) Used across modals, settings, etc.
 * ===================================================== */

/* For IonItem selections - apply to ion-item */
ion-item.logaid-selectable {
  --background: var(--logaid-bg-surface);
  --border-radius: 12px;
  --border-width: 0;
  --inner-border-width: 0;
  border: 2px solid var(--logaid-border);
  border-radius: 12px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
}

ion-item.logaid-selectable:hover {
  --background: var(--logaid-bg-surface-hover);
  border-color: var(--logaid-gray-300);
}

ion-item.logaid-selectable.selected {
  --background: var(--logaid-bg-selected);
  border-color: var(--logaid-primary);
}

ion-item.logaid-selectable.selected:hover {
  --background: var(--logaid-bg-selected-hover);
}

/* =====================================================
 * MOBILE TYPOGRAPHY ADJUSTMENTS
 * Slightly smaller text on mobile to fit more content
 * ===================================================== */
@media (--bp-down-sm) {
  :root {
    --logaid-text-xs: 0.75rem;    /* 12px */
    --logaid-text-sm: 0.8rem;     /* 12.8px */
    --logaid-text-base: 0.875rem; /* 14px */
    --logaid-text-lg: 0.95rem;    /* 15.2px */
    --logaid-text-xl: 1.1rem;     /* 17.6px */
    --logaid-text-2xl: 1.35rem;   /* 21.6px */
    --logaid-text-3xl: 1.75rem;   /* 28px */
  }
}

/* =====================================================
 * LOGAID LIST PAGE STYLES
 * Consistent styling for list pages (People, Locations, etc.)
 * These only style custom wrapper elements, not Ionic components
 * ===================================================== */

/* Stats Grid - for displaying summary statistics at top of list pages */
.logaid-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  padding: 0 1rem 1rem;
}

.logaid-stats-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.logaid-stat-card {
  background: var(--ion-color-light);
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
}

.logaid-stat-value {
  font-size: var(--logaid-text-2xl);
  font-weight: var(--logaid-weight-bold);
  margin-bottom: 0.25rem;
}

.logaid-stat-label {
  font-size: var(--logaid-text-sm);
  color: var(--ion-color-medium);
}

/* Loading State */
.logaid-loading-container {
  text-align: center;
  padding: 3rem 1rem;
}

.logaid-loading-container p {
  color: var(--ion-color-medium);
  margin-top: 1rem;
}

/* Empty State */
.logaid-empty-state,
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
}

.logaid-empty-state p,
.empty-state p {
  color: var(--ion-color-medium);
  font-size: var(--logaid-text-base);
  margin-bottom: 1rem;
}

.logaid-empty-state h2,
.empty-state h2 {
  margin-bottom: 0.5rem;
}

.logaid-empty-state ion-icon[size="large"],
.empty-state ion-icon[size="large"] {
  font-size: 4rem;
  margin-bottom: 1rem;
}

/* Dashed empty panel — a bordered "nothing here yet" block used by settings
 * list pages (Inspection Forms, Integrations) when the collection is empty.
 * Distinct from `.list-empty-state` (a card): a lighter, dashed-border panel. */
.empty-panel {
  background: white;
  border: 1px dashed var(--ion-color-step-200);
  border-radius: 0.75rem;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--ion-color-medium);
}
.empty-panel ion-icon {
  font-size: 3rem;
  color: var(--ion-color-step-300);
  margin-bottom: 0.5rem;
}
.empty-panel h3 {
  margin: 0 0 0.4rem;
  color: var(--ion-color-step-700);
  font-size: 1.05rem;
}
.empty-panel p {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
}
.empty-panel__actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}
@media (--bp-down-md) {
  .empty-panel {
    padding: 2.5rem 1rem;
  }
}

/* =====================================================
 * LIST PAGE SHELL
 * Shared layout primitives used by every desktop list view (Asset, WR,
 * Location, Timesheet, Service plan). Names are prefixed `list-*` to
 * stay collision-safe; consumers should NOT redeclare these in their
 * scoped <style> blocks.
 * ===================================================== */

/* Page-level thin progress bar — sits flush above the table header,
 * sticky-pinned to ion-content so it stays in view as rows scroll past. */
.list-progress {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 2px;
  --background: transparent;
}

.list-page__header {
  margin-bottom: 1rem;
}

/* Search input + filter/display modal triggers row. Items align to the top
 * so when an inner component grows taller (e.g. FilterSearchInput rendering
 * its own filter chips below the searchbar), sibling buttons stay locked to
 * the search line instead of floating to the middle of the taller item. */
.list-search-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

/* IonSearchbar inside the search row — strips its default 8px outer padding
 * (all sides) so its height matches FilterSearchInput on lists that use that
 * component instead. Any list-shell consumer wrapping an IonSearchbar in
 * `.list-search-row` should add this class to align with the rest. */
.list-search-row__searchbar {
  flex: 1;
  min-width: 0;
  padding: 0;
}

/* Selected-filter chips bar — rendered BELOW the search row so the
 * searchbar position stays stable when filters are added/removed. */
.list-selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

.list-selected-chips ion-chip {
  margin: 0;
  cursor: pointer;
}

/* Tight icon spacing inside chips that carry a leading type-icon plus a
 * trailing close button (FilterSearchInput's pattern). Single-icon chips
 * are unaffected since the rules key off icon position. */
.list-selected-chips ion-chip ion-icon:first-child {
  margin-right: 0.25rem;
}

.list-selected-chips ion-chip ion-icon:last-child {
  margin-left: 0.25rem;
}

/* Status segment + any auxiliary controls below the search row. */
.list-filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-top: 0.5rem;
}

.list-filters-row ion-segment {
  flex: 1;
  min-width: 18rem;
}

/* Spinner-with-message fallback before the table renders. */
.list-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--ion-color-medium);
}

.list-loading ion-spinner {
  margin-bottom: 1rem;
}

/* Filter / display modal trigger button — used by ListFilterModal,
 * ListDisplayModal, and FilterSearchInput's inline filter button. The
 * label hides on mobile (icon-only); an optional badge sits inline. */
.list-filter-trigger {
  position: relative;
}

.list-filter-trigger__badge {
  margin-left: 0.5rem;
  font-variant-numeric: tabular-nums;
}

@media (--bp-down-xl) {
  .list-filter-trigger__label {
    display: none;
  }
  .list-filter-trigger__badge {
    margin-left: 0.35rem;
  }
}

/* Empty state buttons - prevent icons from expanding button size */
.logaid-empty-state ion-button,
.empty-state ion-button {
  --padding-start: 1em;
  --padding-end: 1em;
}

/* Remove icons from empty state buttons - they cause oversized buttons */
.logaid-empty-state ion-button ion-icon,
.empty-state ion-button ion-icon {
  display: none;
}

/* Error banners are components, not a utility class: ModalResponse.vue inside a
 * modal, ContentResponse.vue on a page. Both carry the icon and the danger-light
 * treatment. A `.logaid-error-message` class used to sit here unreferenced, with a
 * hardcoded text colour that drifted from those two — removed rather than left as a
 * third, worse option for the next person to find. */

@media (--bp-down-md) {
  .logaid-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .logaid-stats-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* =====================================================
 * ACTIVITY FEED STYLES
 * Centralized styling for activity feed component
 * Used across: Dashboard, Activity page, Location/Asset/Person tabs
 * ===================================================== */

.activity-feed {
  width: 100%;
}

.activity-feed .feed-warnings {
  padding: 0.5rem 1rem;
}

.activity-feed .warning-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: rgba(var(--ion-color-warning-rgb), 0.1);
  border-radius: 0.25rem;
  font-size: var(--logaid-text-sm);
  margin-bottom: 0.5rem;
}

.activity-feed .feed-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: var(--logaid-text-sm);
  color: var(--ion-color-medium);
  border-bottom: 1px solid var(--ion-color-light);
}

.activity-feed .feed-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  gap: 1rem;
  color: var(--ion-color-medium);
}

.activity-feed .feed-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  gap: 0.75rem;
  text-align: center;
}

.activity-feed .feed-error ion-icon:first-child {
  font-size: 2.5rem;
}

.activity-feed .retry-link {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  margin-top: 0.5rem;
}

.activity-feed .retry-link:hover {
  text-decoration: underline;
}

.activity-feed .feed-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  gap: 0.5rem;
  text-align: center;
  color: var(--ion-color-medium);
}

.activity-feed .feed-empty ion-icon {
  font-size: 3rem;
  opacity: 0.5;
}

.activity-feed .feed-empty ion-note {
  font-size: var(--logaid-text-sm);
  margin-top: 0.5rem;
}

.activity-feed .load-more-container {
  padding: 1rem;
}

/* =====================================================
 * ACTIVITY ITEM STYLES
 * Centralized styling for individual activity items
 * ===================================================== */

.activity-item {
  --padding-start: 0;
  --padding-end: 0;
  --inner-padding-end: 0;
}

.activity-item .activity-content {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0;
}

.activity-item .activity-details {
  position: relative;
  flex: 1;
  min-width: 0;
}

/* Avatar container with overlaid badge */
.activity-item .avatar-container {
  position: relative;
  flex-shrink: 0;
}

.activity-item .activity-type-badge {
  position: absolute;
  bottom: -0.125rem;
  right: -0.125rem;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5625rem;
  border: 1.5px solid var(--ion-background-color, #fff);
}

.activity-item .activity-text {
  font-size: var(--logaid-text-base);
  line-height: 1.4;
  word-wrap: break-word;
}

.activity-item .actor-name {
  font-weight: var(--logaid-weight-semibold);
  color: var(--ion-text-color);
}

.activity-item .actor-name.actor-clickable {
  cursor: pointer;
}

.activity-item .actor-name.actor-clickable:hover {
  text-decoration: underline;
}

.activity-item .action-text {
  color: var(--ion-color-medium);
}

.activity-item .subject-name {
  font-weight: var(--logaid-weight-medium);
  color: var(--ion-text-color);
}

.activity-item .time-details {
  color: var(--ion-color-medium);
  font-weight: normal;
}

/* Service log inline summary (on main text line) */
.activity-item .service-inline-count,
.activity-item .service-inline-reading {
  color: var(--ion-color-medium);
  font-weight: normal;
}

.activity-item .service-icon-inline {
  font-size: 0.875em;
  vertical-align: middle;
  margin-right: 0.125rem;
}

.activity-item .subject-clickable {
  color: var(--ion-color-primary);
  cursor: pointer;
}

.activity-item .subject-clickable:hover {
  text-decoration: underline;
}

.activity-item .activity-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  font-size: var(--logaid-text-sm);
  color: var(--ion-color-medium);
}

.activity-item .activity-extra {
  max-width: 50%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-item .activity-time {
  flex-shrink: 0;
  margin-left: auto;
  cursor: pointer;
}

.activity-item .activity-time:hover {
  text-decoration: underline;
  color: var(--ion-color-primary);
}

/* Tag activity details */
.activity-item .tag-activity-details {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.375rem;
}

.activity-item .tag-transition-separator {
  color: var(--ion-color-medium);
  font-size: var(--logaid-text-sm);
  font-weight: 500;
}

/* Grouped details styles */
.activity-item .grouped-details {
  margin-top: 0.375rem;
  padding-left: 0.5rem;
  border-left: 2px solid var(--ion-color-light);
}

.activity-item .grouped-detail-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.125rem 0;
  font-size: var(--logaid-text-base);
}

.activity-item .detail-subject {
  color: var(--ion-text-color);
  font-weight: var(--logaid-weight-medium);
}

.activity-item .detail-info {
  color: var(--ion-color-medium);
  font-size: var(--logaid-text-sm);
}

/* Grouped notes (location notes, service logs) */
.activity-item .grouped-notes {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.activity-item .grouped-note-item {
  padding: 0.5rem 0.625rem;
  background-color: var(--ion-color-light);
  border-radius: 0.5rem;
  border-left: 3px solid var(--ion-color-primary);
}

/* Work request comments - simpler styling without header */
.activity-item .grouped-note-item.comment-item {
  border-left-color: var(--ion-color-primary);
  padding: 0.375rem 0.625rem;
}

.activity-item .grouped-note-item.comment-item .note-content {
  margin-top: 0;
}

/* File attachments in grouped items */
.activity-item .grouped-item-files {
  margin-top: 0.375rem;
  padding-top: 0.375rem;
  border-top: 1px solid rgba(var(--ion-color-medium-rgb), 0.15);
}

.activity-item .note-header {
  font-size: var(--logaid-text-base);
  margin-bottom: 0.25rem;
}

/* Grouped tag activity — list of affected assets under a single grouped row. */
.activity-item .grouped-tag-assets {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.activity-item .grouped-tag-asset-item {
  padding: 0.375rem 0.625rem;
  background-color: var(--ion-color-light);
  border-radius: 0.5rem;
  border-left: 3px solid var(--ion-color-primary);
  font-size: var(--logaid-text-sm);
}

.activity-item .note-content {
  font-size: var(--logaid-text-sm);
  color: var(--ion-text-color);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Activity type badge colors - solid backgrounds with white icons */
.activity-item .icon-time {
  background-color: #3b82f6;
  color: white;
}

.activity-item .icon-tag-add {
  background-color: #22c55e;
  color: white;
}

.activity-item .icon-tag-change {
  background-color: #f59e0b;
  color: white;
}

.activity-item .icon-tag-active {
  background-color: #10b981;
  color: white;
}

.activity-item .icon-tag-remove {
  background-color: #ef4444;
  color: white;
}

.activity-item .icon-service {
  background-color: #8b5cf6;
  color: white;
}

.activity-item .icon-note {
  background-color: #6366f1;
  color: white;
}

.activity-item .icon-work-request {
  background-color: var(--ion-color-tertiary);
  color: var(--ion-color-tertiary-contrast);
}

.activity-item .icon-work-request-status {
  background-color: var(--ion-color-warning);
  color: var(--ion-color-warning-contrast);
}

.activity-item .icon-work-request-comment {
  background-color: var(--ion-color-primary);
  color: var(--ion-color-primary-contrast);
}

.activity-item .icon-medium {
  background-color: #6b7280;
  color: white;
}

/* Activity Excerpt (collapsed state) */
.activity-item .activity-excerpt {
  margin-top: 0.25rem;
  font-size: var(--logaid-text-sm);
  color: var(--ion-color-medium-shade);
  line-height: 1.4;
}

/* Mobile: show mobile excerpt, hide desktop */
.activity-item .activity-excerpt .excerpt-desktop {
  display: none;
}

.activity-item .activity-excerpt .excerpt-mobile {
  display: inline;
}

/* Activity Expanded Content - shared base styles */
.activity-item .activity-expanded {
  margin-top: 0.5rem;
  padding: 0.5rem 0.625rem;
  background-color: var(--ion-color-light);
  border-radius: 0.5rem;
  border-left: 3px solid var(--ion-color-primary);
}

.activity-item .activity-expanded-content {
  font-size: var(--logaid-text-sm);
  color: var(--ion-text-color);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.activity-item .activity-expanded-files {
  margin-top: 0.375rem;
  padding-top: 0.375rem;
  border-top: 1px solid rgba(var(--ion-color-medium-rgb), 0.15);
}

.activity-item .activity-collapsed-files {
  margin-top: 0.375rem;
}

/* Border color variants for different activity types */
.activity-item .activity-expanded.work-request-description {
  border-left-color: var(--ion-color-tertiary);
}

.activity-item .activity-expanded.work-request-comment {
  border-left-color: var(--ion-color-primary);
}

.activity-item .activity-expanded.location-note {
  border-left-color: #6366f1;
}

.activity-item .activity-expanded.work-request-status {
  border-left-color: var(--ion-color-warning);
}

/* Service Log Details */
.activity-item .service-log-details {
  margin-top: 0.25rem;
}

.activity-item .service-note-row {
  font-size: var(--logaid-text-sm);
}

.activity-item .service-note-row.can-expand {
  cursor: pointer;
}

.activity-item .service-log-summary {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: var(--logaid-text-sm);
  color: var(--ion-color-medium);
}

.activity-item .service-log-summary.can-expand {
  cursor: pointer;
}

.activity-item .service-log-summary.can-expand:hover {
  color: var(--ion-color-primary);
}

.activity-item .service-items-count {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: var(--logaid-weight-medium);
}

.activity-item .service-items-count .service-icon {
  font-size: 0.875rem;
}

.activity-item .service-reading {
  padding: 0.125rem 0.375rem;
  background-color: rgba(var(--ion-color-medium-rgb), 0.1);
  border-radius: 0.25rem;
}

.activity-item .service-note-preview {
  flex: 1;
  min-width: 0;
  font-style: italic;
  color: var(--ion-text-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.25rem;
  font-size: var(--logaid-text-sm);
  color: var(--ion-color-medium);
}

.activity-item .service-files-count {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0.125rem 0.375rem;
  background-color: rgba(var(--ion-color-medium-rgb), 0.1);
  border-radius: 0.25rem;
}

.activity-item .service-files-count ion-icon {
  font-size: 0.75rem;
}

.activity-item .expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0.125rem;
  cursor: pointer;
  color: var(--ion-color-medium);
  font-size: 1rem;
}

.activity-item .expand-btn:hover {
  color: var(--ion-color-primary);
}

/* Corner expand button - positioned in upper right of activity-details */
.activity-item .expand-btn.corner-expand {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 0.875rem;
  padding: 0.125rem 0.25rem;
}

.activity-item .service-log-expanded {
  margin-top: 0.5rem;
  padding: 0.5rem 0.625rem;
  background-color: var(--ion-color-light);
  border-radius: 0.5rem;
  border-left: 3px solid var(--ion-color-tertiary);
}

.activity-item .service-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.activity-item .service-item-name {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: var(--logaid-text-sm);
  color: var(--ion-text-color);
  padding: 0.1875rem 0.375rem;
  background-color: rgba(var(--ion-color-tertiary-rgb), 0.1);
  border-radius: 0.25rem;
}

.activity-item .service-item-name::before {
  content: '✓';
  color: var(--ion-color-tertiary);
  font-weight: var(--logaid-weight-bold);
  font-size: 0.625rem;
}

.activity-item .service-note {
  margin-top: 0.375rem;
  padding-top: 0.375rem;
  border-top: 1px solid rgba(var(--ion-color-medium-rgb), 0.2);
  font-size: var(--logaid-text-sm);
  color: var(--ion-text-color);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.activity-item .service-log-files {
  margin-top: 0.5rem;
  padding-top: 0.375rem;
  border-top: 1px solid rgba(var(--ion-color-medium-rgb), 0.2);
}

/* Desktop scaling - larger avatar and badge */
@media (--bp-md) {
  .activity-item .activity-excerpt .excerpt-desktop {
    display: inline;
  }

  .activity-item .activity-excerpt .excerpt-mobile {
    display: none;
  }

  .activity-item .avatar-container .avatar-small {
    width: 2.5rem;
    height: 2.5rem;
  }

  .activity-item .avatar-container .avatar-small .initials-avatar {
    font-size: 0.875rem;
  }

  .activity-item .activity-type-badge {
    width: 1.375rem;
    height: 1.375rem;
    font-size: 0.6875rem;
    border-width: 2px;
  }
}

/* Mobile adjustments */
@media (--bp-down-sm) {
  .activity-item .activity-content {
    padding: 0.5rem 0;
  }

  .activity-item .activity-meta {
    flex-wrap: wrap;
  }

  .activity-item .activity-extra {
    max-width: 100%;
  }

  .activity-item .activity-time {
    margin-left: 0;
    width: 100%;
    margin-top: 0.25rem;
  }
}

/* =====================================================
 * WORK REQUEST PRIORITY STYLES
 * Consistent priority indicators and badges
 * Used across: WorkRequestList, WorkRequestListItem,
 * WorkRequestHeader, AssetServicePlan, LocationDetail, PersonDetail
 * ===================================================== */

/* Priority indicator bar (vertical colored bar on list items) */
.wr-priority-indicator {
  width: 4px;
  min-height: 2.5rem;
  border-radius: 2px;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.wr-priority-indicator.low {
  background-color: var(--logaid-priority-low);
}

.wr-priority-indicator.medium {
  background-color: var(--logaid-priority-medium);
}

.wr-priority-indicator.high {
  background-color: var(--logaid-priority-high);
}

/* Priority badge (for detail views) */
.wr-priority-badge {
  text-transform: capitalize;
  font-weight: 600;
}

.wr-priority-badge.low {
  --background: var(--logaid-priority-low);
  --color: var(--logaid-priority-low-contrast);
}

.wr-priority-badge.medium {
  --background: var(--logaid-priority-medium);
  --color: var(--logaid-priority-medium-contrast);
}

.wr-priority-badge.high {
  --background: var(--logaid-priority-high);
  --color: var(--logaid-priority-high-contrast);
}

/* =====================================================
 * SECTION SEPARATOR
 * Horizontal line with centered text label
 * Used to visually separate content sections
 * ===================================================== */

.section-separator {
  display: flex;
  align-items: center;
  margin: 1.5rem 0 0.5rem 0;
  color: var(--ion-color-medium);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03rem;
}

.section-separator::before,
.section-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--ion-color-light-shade);
}

.section-separator span {
  padding: 0 0.75rem;
}

/* =====================================================
 * FORM LABEL STYLES
 * Ionic stacked labels are too small on desktop by default
 * ===================================================== */

@media (--bp-md) {
  ion-item ion-label[position="stacked"],
  ion-item ion-label.label-stacked {
    --color: var(--ion-text-color);
    font-size: var(--logaid-text-sm) !important;
    -webkit-transform: translateY(50%) scale(1) !important;
    transform: translateY(50%) scale(1) !important;
    max-width: 100%;
  }
}

/* =====================================================
 * FORM SECTION
 * Section headers for grouping form fields
 * Used in edit modals and pages (AssetEdit, PersonModal, etc.)
 * ===================================================== */

.form-section {
  margin-bottom: 2rem;
}

.form-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
  padding: 0 1rem;
  color: var(--ion-color-primary);
}

.form-section ion-item {
  --padding-start: 0;
}

/* Section-level help in a .form-section. Help for one field uses its control's
   `helper-text` instead — see `.field-note`. */
.form-section .field-helper {
  font-size: 0.75rem;
  color: var(--ion-color-medium);
  margin: 0.25rem 0 0.5rem 0;
  padding: 0;
}

/* Linked user indicator styling */
.linked-user-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
}

.linked-user-indicator ion-icon {
  font-size: 0.875rem;
}

/* =====================================================
 * ACTION BUTTONS
 * Stacked full-width buttons for primary actions
 * Used at bottom of detail views, modals, etc.
 * ===================================================== */

.action-buttons {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* =====================================================
 * DETAIL FIELD LIST
 * Read-only "label over value" rows used on the asset &
 * location detail views so the two render identically.
 * ===================================================== */

.detail-list {
  background: transparent;
}

.detail-list ion-item h3 {
  font-size: var(--logaid-text-sm);
  font-weight: var(--logaid-weight-semibold);
  color: var(--ion-color-medium);
  margin-bottom: 0.25rem;
}

.detail-list ion-item p {
  font-size: var(--logaid-text-base);
  color: var(--ion-color-dark);
}

/* =====================================================
 * FILE ATTACHMENT STYLES
 * Shared styles for displaying file attachments
 * Used by FileAttachmentList, comments, logs, etc.
 * ===================================================== */

.logaid-file-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Image thumbnails grid */
.logaid-image-thumbnails {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.logaid-image-thumb-container {
  position: relative;
  display: inline-block;
}

.logaid-image-thumb {
  width: 3.75rem;
  height: 3.75rem;
  object-fit: cover;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.logaid-image-thumb:hover:not(.is-editable) {
  opacity: 0.9;
  transform: scale(1.02);
}

.logaid-image-thumb.is-editable {
  cursor: default;
}

.logaid-image-thumb.is-editable:hover {
  transform: none;
}

/* Overflow indicator (thumbnail style) */
.logaid-overflow-thumb {
  width: 3.75rem;
  height: 3.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  background: var(--ion-color-light);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.logaid-overflow-thumb:hover {
  background: var(--ion-color-light-shade);
}

.logaid-overflow-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.logaid-overflow-icon {
  font-size: 1.25rem;
  color: var(--ion-color-medium);
}

.logaid-overflow-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ion-color-medium);
}

/* Overflow indicator (row style for non-image files) */
.logaid-overflow-row {
  cursor: pointer;
}

.logaid-overflow-text {
  color: var(--ion-color-medium);
  font-style: italic;
}

/* Non-image file attachment */
.logaid-file-attachment {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--ion-color-light);
  padding: 0.375rem 0.5rem;
  border-radius: 0.375rem;
  max-width: 100%;
  transition: background-color 0.15s ease;
}

.logaid-file-attachment:hover:not(.is-editable) {
  background: var(--ion-color-light-shade);
}

.logaid-file-attachment.is-editable:hover {
  background: var(--ion-color-light);
}

.logaid-file-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.logaid-file-main.clickable {
  cursor: pointer;
}

.logaid-file-icon {
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ion-color-medium-tint);
  border-radius: 0.25rem;
  flex-shrink: 0;
}

.logaid-file-icon ion-icon {
  font-size: 1.25rem;
  color: var(--ion-color-medium-shade);
}

.logaid-file-name {
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 10rem;
}

.logaid-file-size {
  font-size: 0.7rem;
  color: var(--ion-color-medium);
  white-space: nowrap;
}

/* File action buttons (download/delete) */
.logaid-file-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.375rem;
  color: var(--ion-color-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: color 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
  border-radius: 0.25rem;
}

.logaid-file-action-btn:hover:not(:disabled) {
  color: var(--ion-color-primary);
  background: rgba(var(--ion-color-primary-rgb), 0.1);
}

.logaid-file-action-btn.delete:hover:not(:disabled) {
  color: var(--ion-color-danger);
  background: rgba(var(--ion-color-danger-rgb), 0.1);
}

.logaid-file-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.logaid-file-action-btn ion-icon {
  display: block;
}

/* File delete button (overlay on images) */
.logaid-file-delete-btn {
  position: absolute;
  top: -0.375rem;
  right: -0.375rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--ion-color-danger);
  color: white;
  border: 2px solid white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0.875rem;
  transition: transform 0.15s ease, background-color 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.logaid-file-delete-btn:hover:not(:disabled) {
  transform: scale(1.1);
  background: var(--ion-color-danger-shade);
}

.logaid-file-delete-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.logaid-file-delete-btn ion-icon {
  display: block;
}

/* =====================================================
 * LIGHTBOX / GALLERY STYLES
 * Full-screen image viewer overlay
 * ===================================================== */

.logaid-lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  touch-action: none; /* Allow custom touch handling for pinch-zoom and swipe */
}

.logaid-lightbox-content {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logaid-lightbox-image-container {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none; /* Disable browser touch handling for pinch-zoom */
}

.logaid-lightbox-image-container.is-zoomed {
  cursor: grab;
}

.logaid-lightbox-image-container.is-zoomed:active {
  cursor: grabbing;
}

.logaid-lightbox-image {
  max-width: calc(100vw - 6rem);
  max-height: calc(100vh - 6rem);
  object-fit: contain;
  border-radius: 0.25rem;
  user-select: none;
}

@media (--bp-down-sm) {
  .logaid-lightbox-image {
    max-width: calc(100vw - 2rem);
  }
}

.logaid-lightbox-info {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
  color: white;
  align-items: center;
}

.logaid-lightbox-filename {
  font-size: 0.85rem;
  opacity: 0.9;
}

.logaid-lightbox-counter {
  font-size: 0.8rem;
  opacity: 0.7;
  background: rgba(255, 255, 255, 0.15);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

.logaid-lightbox-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0.5rem;
  color: white;
  font-size: 1.5rem;
  opacity: 0.9;
  transition: opacity 0.15s ease, background 0.15s ease;
  z-index: 10;
}

.logaid-lightbox-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.7);
}

.logaid-lightbox-close ion-icon {
  display: block;
}

.logaid-lightbox-download {
  position: absolute;
  bottom: 3rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0.5rem;
  color: white;
  font-size: 1.5rem;
  opacity: 0.9;
  transition: opacity 0.15s ease, background 0.15s ease;
  z-index: 10;
}

.logaid-lightbox-download:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.7);
}

.logaid-lightbox-download ion-icon {
  display: block;
}

/* Gallery navigation buttons */
.logaid-gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  font-size: 1.5rem;
  opacity: 0.8;
  transition: opacity 0.15s ease, background-color 0.15s ease;
  z-index: 10;
}

.logaid-gallery-nav:hover:not(:disabled) {
  opacity: 1;
  background: rgba(255, 255, 255, 0.25);
}

.logaid-gallery-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.logaid-gallery-nav ion-icon {
  display: block;
}

.logaid-gallery-prev {
  left: -3.5rem;
}

.logaid-gallery-next {
  right: -3.5rem;
}

@media (--bp-down-sm) {
  .logaid-gallery-prev {
    left: 0.5rem;
  }

  .logaid-gallery-next {
    right: 0.5rem;
  }

  .logaid-gallery-nav {
    background: rgba(0, 0, 0, 0.5);
  }
}

/* Account switcher action sheet
   - Current account: left accent bar (drawn via inset shadow so text stays
     aligned with non-current rows) + bold text.
   - Cancel: separated from the account list with a top divider/spacing
     and de-emphasized color, since it's an action, not an option. */
.action-sheet-button.account-switcher-current {
  box-shadow: inset 0.1875rem 0 0 var(--ion-color-primary);
  font-weight: var(--logaid-weight-semibold);
}

.action-sheet-button.account-switcher-cancel {
  margin-top: 0.5rem;
  border-top: 0.0625rem solid var(--ion-color-light);
  color: var(--ion-color-medium);
  font-weight: var(--logaid-weight-regular, 400);
}

/* =====================================================
 * LIBRARY CONTROLS
 * Shared between the full-page Library view and the
 * embedded asset/location library section: the action
 * row containing upload/attach buttons + grid-vs-list
 * view toggle, plus the search input that sits below.
 * Owned globally so both surfaces stay visually in
 * sync — change a value here and it lands in both.
 * ===================================================== */
.library-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.library-controls .action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
/* Wide/narrow split keyed off the same 1024px desktop threshold as
   useListLayout. Below desktop the inline upload+attach buttons collapse
   into a single trigger that opens an ion-popover (label is "Options"
   in the global library and "Add" in the asset/location section). */
.library-controls .actions-wide {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.library-controls .actions-narrow {
  display: none;
}
@media (max-width: 63.99rem) {
  .library-controls .actions-wide {
    display: none;
  }
  .library-controls .actions-narrow {
    display: inline-flex;
  }
}
.library-controls .add-menu-list ion-item {
  --min-height: 2.75rem;
  --padding-start: 0.75rem;
  --inner-padding-end: 0.75rem;
}
.library-controls .add-menu-list ion-item.menu-divider-above {
  --border-color: var(--ion-color-step-150, #e0e0e0);
  border-top: 0.0625rem solid var(--ion-color-step-150, #e0e0e0);
  margin-top: 0.25rem;
  padding-top: 0.25rem;
}
.library-controls .view-toggle {
  margin-left: auto;
  width: auto;
  --background: var(--ion-color-light);
}
.library-controls .view-toggle ion-segment-button {
  --indicator-color: var(--logaid-bg-selected);
  --color-checked: var(--ion-color-primary);
  min-width: 2.5rem;
  min-height: 2rem;
}
.library-controls .library-search {
  --background: var(--ion-color-light);
  padding: 0;
}

/* =====================================================
 * CARD STACK — shared page layout for a vertical stack of flat form cards
 * (the inspection form builder's General tab, the notification preferences
 * screen, etc.). Owns the page gutter, centering, and inter-card rhythm so
 * every card-based form screen keeps identical side margins. Prefer this over
 * `.ion-padding` (which is a wider 1rem all-round) for these screens.
 * ===================================================== */
.card-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  /* Side gutter matches the list-page shell's `.ion-padding` (1rem) so settings
     forms line up with list views; vertical rhythm stays a touch roomier. */
  padding: 1.25rem 1rem;
  max-width: 56rem;
  margin: 0 auto;
}
@media (--bp-down-md) {
  .card-stack {
    padding: 0.75rem;
    gap: 0.85rem;
  }
}

/* Flat form card used inside a `.card-stack` (inspection builder General tab,
 * notification preferences, profile). Replaces `ion-card` on these screens so the
 * gutter/side margins stay tight and consistent. */
.card {
  background: var(--ion-color-step-50);
  border-radius: 0.65rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}
/* Aligns a shared SectionHeading with the rows/body below it. */
.card-section-heading {
  padding: 1rem 1.25rem 0;
}

/* Field help, in order of preference:
 * 1. Plain string → the control's `helper-text`; validation → `error-text`, with
 *    `ion-invalid ion-touched` on the CONTROL (on the item they do nothing).
 * 2. Markup, or a non-Ionic control → this class, INSIDE a stacked-label ion-item
 *    after the control. Stacked items lay out in a column, so the note inherits
 *    the item's inset whatever its padding. A note outside the item aligns to the
 *    list edge instead, which is wrong wherever items keep their default inset. */
.field-note {
  display: block;
  padding: 0.25rem 0 0.5rem;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--ion-color-step-700, #4d4d4d);
}

.field-note-danger {
  color: var(--ion-color-danger);
}

/* Helper/error text on a control inside an ion-item.
 *
 * Ionic draws a 1px rule ABOVE this text — `--border-width` on the control,
 * documented as "the border below the input when using helper text" — and it only
 * appears once helper text exists. An `ion-item` holding a form control already
 * draws its own bottom border (`.item-interactive`) BELOW everything, so a field
 * with a hint ends up sandwiched between two identical rules, and the hint reads
 * as a caption for the row underneath rather than the value above it.
 *
 * The item's border is the one that means "row ends here", so keep that and drop
 * the control's.
 *
 * `:not([fill])` is load-bearing. `--border-width` ALSO draws the box on
 * `fill="outline"` and the underline on `fill="solid"`, so zeroing it blanket
 * would erase the border of every filled control on the site. Those variants
 * never had the problem anyway — Ionic already sets `.input-bottom`'s border to
 * none for both. */
ion-item ion-input:not([fill]),
ion-item ion-select:not([fill]),
ion-item ion-textarea:not([fill]) {
  --border-width: 0;
}

/* =====================================================
 * PLAN SCHEDULE LIST
 *
 * The compact tier-and-item list shared by the service plan editor and the
 * read-only plan detail view. One list, tiers with their items nested under
 * them: the card-per-item layout it replaced fit about four items on a phone.
 *
 * Namespaced under `.plan-schedule` on purpose. The inner class names
 * (`.item-row`, `.item-name`, `.item-meta`) are generic enough that
 * InspectionItemList uses them too, so an unscoped rule here would leak into
 * that component's own layout.
 *
 * Interaction lives with each screen: the editor adds hover/cursor, row action
 * buttons and the per-tier add row in its own scoped styles. What is here is
 * only what the two must agree on — if they drift visually, the ladder reads as
 * two different things depending on which screen you came from.
 * ===================================================== */

.plan-schedule {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.plan-schedule .schedule-group {
  border: 1px solid var(--ion-color-light-shade);
  border-radius: 0.5rem;
  overflow: hidden;
}

.plan-schedule .tier-row,
.plan-schedule .item-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  padding: 0.25rem 0.5rem;
}

.plan-schedule .tier-row {
  background: var(--ion-color-light);
  font-weight: 600;
}

/* The standalone group's heading is a label, not a target — it has nothing to
   edit, so it must not look like the tier rows above it. */
.plan-schedule .tier-row-plain {
  font-weight: 500;
  color: var(--ion-color-medium);
}

.plan-schedule .tier-icon {
  font-size: 1rem;
  color: var(--ion-color-medium);
  flex-shrink: 0;
}

.plan-schedule .tier-name {
  white-space: nowrap;
}

.plan-schedule .tier-interval {
  flex: 1;
  min-width: 0;
  font-weight: 400;
  font-size: 0.8125rem;
  color: var(--ion-color-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-schedule .row-count {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ion-color-medium);
}

.plan-schedule .tier-row-plain .row-count {
  padding-right: 0.5rem;
}

.plan-schedule .item-rows {
  display: flex;
  flex-direction: column;
}

/* Indented only when there is a ladder to indent under. */
.plan-schedule .item-rows-nested .item-row {
  padding-left: 1.5rem;
}

.plan-schedule .item-row + .item-row {
  border-top: 1px solid var(--ion-color-light);
}

/* Dimmed rather than moved: a paused item is still part of the plan, and reading
   the ladder means seeing where the gap is. */
.plan-schedule .item-row-paused .item-main,
.plan-schedule .item-row-paused .item-meta {
  opacity: 0.55;
}

.plan-schedule .item-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.5rem;
  min-width: 0;
  flex: 1;
}

.plan-schedule .item-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Its own line at every size. Sharing the name's line meant a long note
   squeezed the name — the one thing on the row that identifies it — down to a
   few characters. Still a single clamped line, so a paragraph-length note
   cannot grow the row without bound. */
.plan-schedule .item-note {
  flex: 1 0 100%;
  min-width: 0;
  font-size: 0.75rem;
  font-style: italic;
  color: var(--ion-color-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-schedule .item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--ion-color-dark);
}

.plan-schedule .item-meta .interval {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

.plan-schedule .item-meta .interval ion-icon {
  font-size: 0.875rem;
  color: var(--ion-color-primary);
}

.plan-schedule .item-meta .interval.muted {
  color: var(--ion-color-medium);
}

/* Fixed-width so a column of them lines up, and never shrinks: the name gives
   way first, since it has an ellipsis and the badge would become unreadable.
   The number alone with the scale in the tooltip — spelling the label out cost
   more width than the name on a dense row. */
.plan-schedule .priority-badge {
  flex-shrink: 0;
  min-width: 1.25rem;
  padding: 0.125rem 0.25rem;
  font-size: 0.6875rem;
  text-align: center;
  cursor: help;
}

/* Phone. The name and its badges keep the first line; the intervals wrap under
   rather than truncating the name to nothing. */
@media (--bp-down-md) {
  .plan-schedule .item-row {
    flex-wrap: wrap;
  }

  .plan-schedule .item-main {
    flex: 1 0 100%;
  }
}
