/*
    Plant Library - the list (PlantLibraryPage), the item (PlantItemPage) and its fly-up form
    (PlantSheet). See Specs/PlantLibrary-Design.md section 6.4.

    Tokens only, so every rule resolves correctly under Tradie Classic, Tradie Light and
    Professional with Dark Mode on or off: Dark.css and Professional.css redefine the tokens
    themselves, and this file is always enabled. The status colours (--ok/--warn/--danger) carry
    meaning and are left at full strength; their pills are tinted with a translucent fill so the
    same rule works on light and dark surfaces, and every pill also says its status in words.
*/

/* ── List toolbar ─────────────────────────────────────────────────────────────────────────── */

.PlantLibraryToolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 6px 0 10px 0;
}

input.PlantLibrarySearch {
    display: block;
    width: 100%;
    box-sizing: border-box;
    height: 42px;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
}

/* Compound, so it beats jQuery Mobile's ".ui-mobile label { display: block }". */
.PlantLibraryToolbar label.PlantLibraryToggle {
    display: flex;
    margin: 0;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text);
    font-size: var(--type-base);
    user-select: none;
}

.PlantLibraryToggle input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.PlantLibraryToggleTrack {
    display: block;
    position: relative;
    flex: 0 0 auto;
    width: 42px;
    min-width: 42px;
    box-sizing: border-box;
    height: 24px;
    border-radius: 12px;
    background: var(--border-strong);
    transition: background .15s;
}

.PlantLibraryToggleThumb {
    display: block;
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
    transition: left .15s;
}

.PlantLibraryToggle input:checked + .PlantLibraryToggleTrack {
    background: var(--brand);
}

.PlantLibraryToggle input:checked + .PlantLibraryToggleTrack .PlantLibraryToggleThumb {
    left: 21px;
}

.PlantLibraryToggle input:focus-visible + .PlantLibraryToggleTrack {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.PlantLibraryNotice,
.PlantLibraryEmpty,
.PlantSectionEmpty {
    color: var(--text-muted);
    font-size: var(--type-sm);
    padding: 6px 2px;
}

.PlantLibraryEmpty {
    padding: 24px 8px;
    text-align: center;
    font-size: var(--type-base);
}

.PlantLibraryNoticeError {
    color: var(--danger);
    font-weight: 700;
}

/* ── List rows ────────────────────────────────────────────────────────────────────────────── */

.PlantListHeading {
    margin: 14px 2px 6px 2px;
    font-size: var(--type-sm);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.PlantRowGroup {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

a.PlantRow {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    min-height: 44px;
    box-sizing: border-box;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    color: var(--text) !important;
    text-decoration: none !important;
    font-weight: normal;
    text-shadow: none;
}

a.PlantRow:last-child {
    border-bottom: none;
}

a.PlantRow:active {
    background: var(--surface-2);
}

.PlantRowMain {
    flex: 1 1 auto;
    min-width: 0;
}

.PlantRowName {
    font-size: var(--type-base);
    font-weight: 700;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.PlantRowSub {
    margin-top: 2px;
    font-size: var(--type-sm);
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.PlantRowMeta {
    flex: 0 1 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 55%;
}

/* ── Status pills ─────────────────────────────────────────────────────────────────────────── */

.PlantPill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    border: 1px solid currentColor;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    box-sizing: border-box;
}

/* Text stays --text for contrast on any surface; the border and the tint carry the colour. */
.PlantPillAvailable {
    color: var(--ok);
    background: rgba(46, 125, 50, .14);
}

.PlantPillOut {
    color: var(--warn);
    background: rgba(249, 168, 37, .16);
}

.PlantPillOverdue,
.PlantPillUnavailable {
    color: var(--danger);
    background: rgba(214, 69, 69, .14);
}

.PlantPill.PlantPillAvailable,
.PlantPill.PlantPillOut,
.PlantPill.PlantPillOverdue,
.PlantPill.PlantPillUnavailable {
    -webkit-text-fill-color: var(--text);
}

.PlantWarnBadge {
    color: var(--warn);
    font-size: 16px;
}

.PlantSrOnly {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ── Item page ────────────────────────────────────────────────────────────────────────────── */

.PlantCard {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

.PlantCardHead {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.PlantCardName {
    font-size: var(--type-lg);
    font-weight: 700;
    color: var(--text);
}

.PlantFacts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 12px;
    margin: 10px 0 0 0;
    font-size: var(--type-sm);
}

.PlantFacts dt {
    color: var(--text-muted);
    font-weight: 700;
}

.PlantFacts dd {
    margin: 0;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Vehicle-detail dates (WOF/COF, rego, service) - the text says "(overdue)" too. */
.PlantFacts dd.PlantDueOverdue {
    color: var(--danger);
    font-weight: 700;
}

.PlantFacts dd.PlantDueSoon {
    color: var(--warn);
    font-weight: 700;
}

.PlantItemActions {
    margin: 10px 0;
}

.ui-btn.PlantPrimaryAction {
    margin: 0 0 8px 0;
}

.PlantSecondaryRow {
    display: flex;
    gap: 8px;
}

button.ui-btn.PlantSecondaryAction,
button.ui-btn.PlantSmallAction {
    flex: 1 1 0;
    margin: 0;
    border: 1px solid var(--border-strong) !important;
    background: var(--surface) !important;
    color: var(--text) !important;
    text-shadow: none !important;
    font-weight: 700;
}

button.ui-btn.PlantSecondaryAction {
    margin-bottom: 8px;
}

button.ui-btn.PlantSmallAction {
    display: inline-block;
    width: auto;
    margin-top: 8px;
    padding: 6px 14px;
    font-size: var(--type-sm);
}

.PlantItemHeldBy {
    margin: 0 0 8px 0;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
}

.PlantItemBlocked {
    border-color: var(--danger);
}

.PlantSection {
    margin: 16px 0 0 0;
}

.PlantSectionTitle {
    margin: 0 2px 6px 2px;
    font-size: var(--type-sm);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.PlantIssue,
.PlantNote,
.PlantHistory > li {
    padding: 10px 12px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

.PlantIssue.PlantIssueBlocking {
    border-left: 4px solid var(--danger);
}

.PlantIssue.PlantIssueWarning {
    border-left: 4px solid var(--warn);
}

.PlantIssue.PlantIssueResolved {
    border-left-color: var(--border-strong);
    opacity: .8;
}

.PlantIssueHead {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.PlantIssueTitle {
    font-weight: 700;
}

.PlantIssueTags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.PlantTag {
    padding: 1px 7px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-strong);
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.PlantTag.PlantTagBlocking {
    border-color: var(--danger);
    background: rgba(214, 69, 69, .14);
}

.PlantTag.PlantTagWarning {
    border-color: var(--warn);
    background: rgba(249, 168, 37, .16);
}

.PlantIssueText,
.PlantNoteText,
.PlantHistoryNote {
    margin-top: 4px;
    white-space: pre-wrap;
    word-break: break-word;
}

.PlantNoteMeta {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.PlantIssueThread {
    margin-top: 8px;
    padding-left: 10px;
    border-left: 2px solid var(--border);
}

.PlantIssueThread .PlantNote {
    padding: 4px 0;
    margin: 0;
    border: none;
    background: transparent;
}

.PlantHistory {
    list-style: none;
    margin: 0;
    padding: 0;
}

.PlantHistory > li.PlantHistoryOpen {
    border-color: var(--warn);
}

.PlantHistoryWho {
    font-weight: 700;
}

.PlantHistoryWhen {
    font-size: var(--type-sm);
    color: var(--text-muted);
}

.PlantHistoryNote {
    font-size: var(--type-sm);
}

/* ── Photos ───────────────────────────────────────────────────────────────────────────────── */

.PlantThumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0;
}

.PlantThumb {
    display: block;
    width: 72px;
    height: 72px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    overflow: hidden;
    cursor: pointer;
}

.PlantThumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.PlantPhotoPickers {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.PlantPhotoPickers .file-input-button {
    flex: 1 1 0;
    margin: 4px 0;
}

.PlantPhotoOverlay {
    position: fixed;
    inset: 0;
    z-index: 3100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    background: rgba(0, 0, 0, .88);
}

/* One photo per screen width; a swipe snaps to the next. The track runs edge to edge. */
.PlantPhotoTrack {
    display: flex;
    align-self: stretch;
    margin: 0 -16px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

.PlantPhotoTrack::-webkit-scrollbar {
    display: none;
}

.PlantPhotoSlide {
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    box-sizing: border-box;
    scroll-snap-align: center;
    scroll-snap-stop: always;
}

.PlantPhotoOverlay img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.PlantPhotoCounter {
    min-height: 1.2em;
    color: #FFFFFF;
    font-size: var(--type-sm);
}

/* Previous/Next sit over the photo's edges, at the middle of the screen. */
.PlantPhotoOverlay .PlantPhotoNav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .45);
}

.PlantPhotoOverlay .PlantPhotoNav::before {
    content: "";
    display: block;
    width: 12px;
    height: 12px;
    margin: 0 auto;
    border: solid #FFFFFF;
    border-width: 0 3px 3px 0;
}

.PlantPhotoOverlay .PlantPhotoPrev {
    left: 6px;
}

.PlantPhotoOverlay .PlantPhotoPrev::before {
    transform: translateX(2px) rotate(135deg);
}

.PlantPhotoOverlay .PlantPhotoNext {
    right: 6px;
}

.PlantPhotoOverlay .PlantPhotoNext::before {
    transform: translateX(-2px) rotate(-45deg);
}

.PlantPhotoOverlay .PlantPhotoNav:disabled {
    visibility: hidden;
}

.PlantPhotoCaption {
    color: #FFFFFF;
    font-size: var(--type-sm);
    text-align: center;
}

.PlantPhotoBar {
    display: flex;
    gap: 10px;
}

.PlantPhotoBar button {
    min-height: 40px;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, .6);
    background: transparent;
    color: #FFFFFF;
    font-family: var(--font);
    font-size: var(--type-base);
}

.PlantPhotoBar button.PlantPhotoRemove {
    border-color: var(--danger);
}

/* ── The fly-up form ──────────────────────────────────────────────────────────────────────── */

/* One layer below the date picker's own sheet (Pickers.css, 3000/3001), as Assign Job's is. */
.totm-scrim.PlantSheetScrim {
    z-index: 2500;
}

.totm-sheet.PlantSheet {
    z-index: 2501;
}

.PlantSheetSection {
    margin-bottom: 14px;
}

/* Under .PlantSheet so <label> and <div> labels match - jQuery Mobile restyles bare labels. */
.PlantSheet .PlantSheetLabel {
    display: block;
    margin: 0 0 6px 0;
    font-size: var(--type-sm);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}

input.PlantSheetInput,
textarea.PlantSheetTextArea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
}

input.PlantSheetInput {
    height: 40px;
}

textarea.PlantSheetTextArea {
    min-height: 72px;
    resize: vertical;
}

.PlantChoice {
    display: flex;
    gap: 6px;
}

button.PlantChoiceOption {
    flex: 1 1 0;
    min-height: 44px;
    padding: 6px 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: var(--type-base);
    font-weight: 700;
    cursor: pointer;
}

button.PlantChoiceOption.PlantChoiceSelected {
    border: 2px solid var(--brand);
    background: var(--surface-2);
}

button.PlantChoiceOption.PlantChoiceBlocking.PlantChoiceSelected {
    border-color: var(--danger);
}

button.PlantChoiceOption.PlantChoiceWarning.PlantChoiceSelected {
    border-color: var(--warn);
}

.PlantChoiceHint {
    display: block;
    font-size: 11px;
    font-weight: normal;
    color: var(--text-muted);
}

.PlantSheetError {
    margin: 4px 0 0 0;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--danger);
    color: var(--danger);
    background: var(--surface);
    font-size: var(--type-sm);
    font-weight: 700;
}

.totm-sheet.PlantSheet .totm-sheet-done:disabled {
    opacity: .6;
    cursor: default;
}

/* ── Servicing (PlantServicing-Design.md section 7, OnTheGo.View.PlantService) ─────────────── */

/* "Due soon" - not yet a problem, so the brand colour rather than a warning colour. */
.PlantPillDueSoon {
    color: var(--brand);
    background: rgba(63, 81, 181, .12);
}

.PlantPill.PlantPillDueSoon {
    -webkit-text-fill-color: var(--text);
}

/* The list's wrench, beside the status pill. */
.PlantServiceBadge {
    font-size: 16px;
}

.PlantServiceBadge.PlantServiceBadgeDue {
    color: var(--warn);
}

.PlantServiceBadge.PlantServiceBadgeOverdue {
    color: var(--danger);
}

/* One service checklist - the same card as an issue or a history row. */
.PlantServiceCard {
    padding: 10px 12px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

.PlantServiceRule {
    margin-top: 4px;
}

.PlantServiceHistoryTitle {
    margin: 12px 2px 6px 2px;
    font-size: var(--type-sm);
    font-weight: 700;
    color: var(--text-muted);
}

/* "Record outcome" for a checklist saved but not yet recorded. */
.PlantItemHeldBy.PlantServicePending {
    border-color: var(--warn);
}

/* A one-off message on the item (OnTheGo.View.PlantItem.showNotice) - a failed pre-start check. */
.PlantItemHeldBy.PlantItemNotice {
    border-color: var(--danger);
    font-weight: 700;
}

/* A line of explanation at the top of a sheet (the pre-start note, "saved on this phone"). */
.PlantSheet .PlantSheetIntro {
    margin: 0 0 14px 0;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    font-size: var(--type-sm);
}
