/**
 * WLB Faults — plugin styles.
 *
 * Uses var(--wlb-*) tokens with fallbacks.
 *
 * @package wlb-faults
 */

/*
 * Tile styles (.wlb-type-tile, .wlb-type-radio, .wlb-tile-label)
 * are inherited from wlb-listings.css — no duplication here.
 * Only fault-specific overrides below.
 */

/* Upload zone styles live in wlb-media/assets/css/upload-zone.css (shared widget). */

/* Hide WP page title when shortcode provides its own heading */
.wlb-has-dynamic-heading .entry-header {
  display: none;
}

/* ---- Page header row (heading + Log a Fault CTA) ---- */

.wlb-faults-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 1rem;
}

.wlb-fault-cta {
  text-decoration: none;
  flex-shrink: 0;
}

.wlb-fault-cta__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 96px;
  gap: 4px;
  border: 1px solid var(--wlb-color-border, #aaa);
  border-radius: var(--wlb-radius-md, 6px);
  box-shadow: none;
  background: var(--wlb-color-surface, #fff);
  padding: 12px 8px;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.wlb-fault-cta__card .wlb-tile-icon {
  display: block;
  color: var(--wlb-color-primary, #2e7d32);
}

.wlb-fault-cta__card .wlb-tile-label {
  font-size: 0.8em;
  font-weight: 600;
  color: #333;
  line-height: 1.3;
}

.wlb-fault-cta:hover .wlb-fault-cta__card {
  border-color: var(--wlb-color-primary, #2e7d32);
  transform: translateY(-1px);
}

@media (max-width: 640px) {
  .wlb-fault-cta__card {
    width: 76px;
  }
}

/* ---- Fault form steps ---- */

.wlb-fault-step__heading {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--wlb-muted, #666);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.5rem;
}

/* ---- Sub-type pills ---- */

.wlb-fault-step--subtype {
  margin-bottom: 1.25rem;
}

.wlb-subtype-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wlb-subtype-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  border: 2px solid var(--pill-color, #999);
  border-radius: 999px;
  background: transparent;
  color: var(--pill-color, #333);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  line-height: 1.4;
}

.wlb-subtype-pill:hover {
  background: var(--pill-color, #999);
  color: #fff;
}

.wlb-subtype-pill.is-selected {
  background: var(--pill-color, #999);
  color: #fff;
}

/* ---- "Add more details" accordion ---- */

.wlb-fault-details {
  border: 2px solid var(--wlb-color-primary, #2e7d32);
  border-radius: var(--wlb-radius-md, 6px);
  background: var(--wlb-color-surface, #fff);
  padding: 0;
  margin-bottom: 1rem;
}

.wlb-fault-details__toggle {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.9rem 1.25rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--wlb-color-primary, #2e7d32);
  background: color-mix(in srgb, var(--wlb-color-primary, #2e7d32) 8%, transparent);
  border-radius: var(--wlb-radius-md, 6px);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s ease;
}

.wlb-fault-details[open] .wlb-fault-details__toggle {
  border-radius: var(--wlb-radius-md, 6px) var(--wlb-radius-md, 6px) 0 0;
}

.wlb-fault-details__toggle:hover {
  background: color-mix(in srgb, var(--wlb-color-primary, #2e7d32) 15%, transparent);
}

.wlb-fault-details__toggle::-webkit-details-marker {
  display: none;
}

.wlb-fault-details__toggle::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border: 5px solid transparent;
  border-left-color: currentColor;
  border-left-width: 7px;
  border-right-width: 0;
  transition: transform 0.2s ease;
}

.wlb-fault-details[open] .wlb-fault-details__toggle::before {
  transform: rotate(90deg);
}

.wlb-fault-details__body {
  padding: 0.5rem 1.25rem 1.25rem;
  border-top: 2px solid var(--wlb-color-primary, #2e7d32);
}

/* --- Mobile: fault type tiles — 2-per-row, horizontal layout --- */
@media (max-width: 639px) {
  #wlb-fault-type-tiles > * { width: 50%; }

  #wlb-fault-type-tiles .uk-card {
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    padding: 10px 8px;
  }

  #wlb-fault-type-tiles .wlb-tile-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin: 0;
    line-height: 0;
  }

  #wlb-fault-type-tiles .wlb-tile-label {
    margin: 0;
    line-height: 1.3;
  }
}

/* ---- GPS button + result row ---- */

.wlb-gps-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
}

.wlb-gps-row__action {
  display: flex;
  align-items: center;
}

.wlb-gps-row__status {
  display: flex;
  align-items: center;
}

.wlb-gps-row__result {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--wlb-color-primary, #2e7d32);
  font-size: 0.9rem;
  justify-self: end;
  text-align: right;
}

@media (max-width: 768px) {
  .wlb-gps-row {
    grid-template-columns: 1fr;
  }

  .wlb-gps-row__action,
  .wlb-gps-row__status,
  .wlb-gps-row__result {
    justify-self: start;
    text-align: left;
  }
}

.wlb-gps-result__icon {
  flex-shrink: 0;
}

.wlb-gps-result__value {
  font-weight: 500;
  word-break: break-all;
}

#wlb-gps-btn {
  padding: 10px 20px;
  font-size: 1rem;
}

#wlb-gps-btn .uk-icon {
  margin-right: 0.4em;
}

/* ---- Fault map wrapper ---- */

.wlb-fault-map-wrap {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	overflow: hidden;
	overflow-x: clip;
}

/* ---- Leaflet map container ---- */

#wlb-fault-map {
	height: 450px;
	width: 100%;
	border-radius: var(--wlb-radius, 4px);
	overflow: clip; /* override leaflet's overflow:hidden — clip doesn't create a scroll container so .leaflet-proxy's huge translate can't inflate ancestor scrollWidth */
	border: 1px solid var(--wlb-border, #e5e5e5);
}

@media ( max-width: 640px ) {
	#wlb-fault-map {
		height: 300px;
	}
}

/* ---- Map popup ---- */

.wlb-map-popup p {
	margin: 0.25em 0 0;
	font-size: 0.85rem;
}

.wlb-map-popup__excerpt {
	color: var(--wlb-muted, #666);
	font-style: italic;
}

.wlb-map-popup__subtype {
	display: inline-block;
	margin-left: 6px;
	padding: 1px 8px;
	border-radius: 999px;
	background: var(--wlb-muted-bg, #f0f0f0);
	color: var(--wlb-muted, #555);
	font-size: 0.75rem;
	font-weight: 500;
	vertical-align: middle;
}

.wlb-fault-card__subtype {
	display: inline-block;
	margin-left: 6px;
	padding: 1px 8px;
	border-radius: 999px;
	background: var(--wlb-muted-bg, #f0f0f0);
	color: var(--wlb-muted, #555);
	font-size: 0.75rem;
	font-weight: 500;
	vertical-align: middle;
}

/* ---- Filter pills ---- */

.wlb-fault-filter-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.wlb-fault-pill {
	padding: 0.3em 0.9em;
	border: 2px solid var(--pill-color, var(--wlb-border, #e5e5e5));
	border-radius: 2em;
	background: transparent;
	color: inherit;
	font-size: 0.85rem;
	cursor: pointer;
	transition: background-color 0.15s, color 0.15s;
}

.wlb-fault-pill:hover {
	background-color: var(--pill-color, var(--wlb-primary, #1e87f0));
	color: #fff;
}

.wlb-fault-pill--active {
	background-color: var(--pill-color, var(--wlb-primary, #1e87f0));
	color: #fff;
}

/* "All" pill uses primary colour when no --pill-color set */
.wlb-fault-pill[data-type="all"] {
	--pill-color: var(--wlb-primary, #1e87f0);
}

/* ---- Fault list ---- */

.wlb-fault-list {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 260px, 1fr ) );
	gap: 1rem;
}

/* ---- Fault card ---- */

.wlb-fault-card {
	padding: 0.85rem 1rem;
	border-left: 4px solid var(--card-color, var(--wlb-border, #e5e5e5));
	border-radius: var(--wlb-radius, 4px);
	background: var(--wlb-card-bg, #fff);
	box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.wlb-fault-card__header {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.5rem;
}

.wlb-fault-card__badge {
	display: inline-block;
	padding: 0.15em 0.6em;
	border-radius: 2em;
	background: var(--card-color, #95a5a6);
	color: #fff;
	font-size: 0.75rem;
	font-weight: 600;
	white-space: nowrap;
}

.wlb-fault-card__status {
	font-size: 0.75rem;
	text-transform: capitalize;
	padding: 0.15em 0.5em;
	border-radius: 2em;
	border: 1px solid currentColor;
}

.wlb-fault-card__status--active {
	color: #e74c3c;
	border-color: #e74c3c;
}

.wlb-fault-card__status--resolved {
	color: #27ae60;
	border-color: #27ae60;
}

.wlb-fault-card__excerpt {
	margin: 0 0 0.4rem;
	font-size: 0.875rem;
	color: var(--wlb-muted, #555);
}

.wlb-fault-card__meta {
	margin: 0 0 0.25rem;
	font-size: 0.75rem;
	color: var(--wlb-muted, #888);
}

.wlb-fault-card__photos {
	margin: 0;
	font-size: 0.75rem;
	color: var(--wlb-muted, #888);
}

/* ---- Resolution dashboard ---- */

.wlb-resolution-dashboard {
	max-width: 100%;
}

.wlb-resolution-header {
	border-bottom: 1px solid var(--wlb-border, #e5e5e5);
	padding-bottom: 0.75rem;
}

.wlb-resolution-table {
	font-size: 0.875rem;
	width: 100%;
}

.wlb-resolution-table th {
	font-weight: 600;
	white-space: nowrap;
	color: var(--wlb-muted, #666);
}

.wlb-resolution-excerpt {
	max-width: 240px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.wlb-resolution-location {
	max-width: 160px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	font-size: 0.8rem;
	color: var(--wlb-muted, #888);
}

.wlb-resolution-date,
.wlb-resolution-ref {
	white-space: nowrap;
	font-size: 0.8rem;
	color: var(--wlb-muted, #888);
}

.wlb-resolution-photos {
	font-size: 0.8rem;
	color: var(--wlb-muted, #888);
}

/* ---- Type badge (resolution table) ---- */

.wlb-resolution-badge {
	display: inline-block;
	padding: 0.15em 0.65em;
	border-radius: 2em;
	color: #fff;
	font-size: 0.75rem;
	font-weight: 600;
	white-space: nowrap;
}

/* ---- Resolve button ---- */

.wlb-resolve-btn {
	white-space: nowrap;
}

.wlb-resolve-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* ---- Responsive — collapse some columns on small screens ---- */

@media ( max-width: 768px ) {
	.wlb-resolution-table .wlb-resolution-ref,
	.wlb-resolution-table .wlb-resolution-photos {
		display: none;
	}

	.wlb-resolution-excerpt {
		max-width: 140px;
	}

	.wlb-resolution-location {
		max-width: 100px;
	}
}

/* ---- Fault dispute form (map popup) ---- */

.wlb-dispute-form {
	margin-top: 0.75rem;
	padding-top: 0.5rem;
	border-top: 1px solid var(--wlb-border, #e5e5e5);
}

.wlb-dispute-btn {
	padding: 0.25em 0.75em;
	border: 1px solid var(--wlb-primary, #1e87f0);
	border-radius: var(--wlb-radius, 4px);
	background: transparent;
	color: var(--wlb-primary, #1e87f0);
	font-size: 0.8rem;
	cursor: pointer;
	transition: background-color 0.15s, color 0.15s;
}

.wlb-dispute-btn:hover {
	background-color: var(--wlb-primary, #1e87f0);
	color: #fff;
}

.wlb-dispute-textarea {
	display: block;
	width: 100%;
	min-height: 4.5rem;
	padding: 0.4em 0.5em;
	border: 1px solid var(--wlb-border, #e5e5e5);
	border-radius: var(--wlb-radius, 4px);
	font-size: 0.8rem;
	resize: vertical;
	box-sizing: border-box;
}

.wlb-dispute-textarea:focus {
	outline: none;
	border-color: var(--wlb-primary, #1e87f0);
	box-shadow: 0 0 0 2px rgba(30, 135, 240, 0.2);
}

.wlb-dispute-char-count {
	margin: 0.2em 0 0.4em;
	font-size: 0.72rem;
	color: var(--wlb-muted, #888);
	text-align: right;
}

.wlb-dispute-actions {
	display: flex;
	gap: 0.4rem;
	margin-top: 0.4rem;
}

.wlb-dispute-submit-btn {
	padding: 0.25em 0.75em;
	border: none;
	border-radius: var(--wlb-radius, 4px);
	background: var(--wlb-primary, #1e87f0);
	color: #fff;
	font-size: 0.8rem;
	cursor: pointer;
	transition: opacity 0.15s;
}

.wlb-dispute-submit-btn:hover {
	opacity: 0.85;
}

.wlb-dispute-submit-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.wlb-dispute-cancel-btn {
	padding: 0.25em 0.75em;
	border: 1px solid var(--wlb-border, #e5e5e5);
	border-radius: var(--wlb-radius, 4px);
	background: transparent;
	color: inherit;
	font-size: 0.8rem;
	cursor: pointer;
}

.wlb-dispute-cancel-btn:hover {
	background: var(--wlb-muted-bg, #f8f8f8);
}

.wlb-dispute-message {
	margin: 0.4rem 0 0;
	font-size: 0.78rem;
}

.wlb-dispute-message--error {
	color: #e74c3c;
}

.wlb-dispute-message--success {
	color: #27ae60;
}

/* ---- My Faults status badges ---- */

.wlb-badge-fault-active   { background: #e74c3c; color: #fff; }
.wlb-badge-fault-noted    { background: #f0ad4e; color: #fff; }
.wlb-badge-fault-resolved { background: #27ae60; color: #fff; }
.wlb-badge-fault-deferred { background: #95a5a6; color: #fff; }
.wlb-badge-fault-disputed { background: #8e44ad; color: #fff; }

/* --- Recent faults list (homepage fault map panel) --- */
.wlb-recent-faults { margin-top: 20px; }
.wlb-recent-faults__heading {
  font-size: 0.75em; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--wlb-color-muted, #888); margin-bottom: 8px;
}
.wlb-recent-faults__list { list-style: none; margin: 0; padding: 0; }
.wlb-recent-fault-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0; border-bottom: 1px solid var(--wlb-color-border, #eee);
  font-size: 0.85em; min-width: 0;
}
.wlb-recent-fault-item:last-child { border-bottom: none; }
.wlb-recent-fault-item__dot {
  flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%;
  background: var(--dot-color, #999);
}
.wlb-recent-fault-item__type { font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.wlb-recent-fault-item__desc {
  flex: 1; color: #555; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.wlb-recent-fault-item__date { white-space: nowrap; color: #888; flex-shrink: 0; }
