/* ---------------------------------------------------------------------------
   Job View (View.JobView.js, Specs/Scheduler-JobView-Design.md). One job on one
   screen: a header with the status pill, summary tiles, then a stack of
   sections. Tables reuse .UserTable; everything here is spacing and emphasis.
   Light-only, like the rest of the Scheduler (Modern.css has no dark palette).
   --------------------------------------------------------------------------- */
/* Side padding on the view itself, not on #SettingsDialogContent, so it is the same in every
   theme and leaves the other settings dialogs alone. */
.JobView {
    color: var(--totm-text, #1A1A1A);
    padding: 0 16px 12px 16px;
}

.JobView .JvHeader {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 2px 0 12px 0;
}

.JobView .JvJobCode {
    font-size: var(--totm-fs-xl, 18px);
    font-weight: 600;
}

.JobView .JvStatus {
    padding: 1px 9px;
    border-radius: 10px;
    font-size: var(--totm-fs-sm, 13px);
    font-weight: 500;
}

.JobView .JvHeaderCustomer {
    color: var(--totm-text-muted, #5F6368);
}

/* Scheduler.css paints every button brand blue with !important - match its weight for a quiet icon button. */
.JobView button.JvReload {
    margin-left: auto;
    padding: 3px 9px !important;
    background-color: #fff !important;
    color: var(--totm-text, #1A1A1A) !important;
    border: 1px solid var(--totm-border-strong, #C9CCD1) !important;
    border-radius: 5px !important;
    cursor: pointer;
}

/* The Job View's dialog background - #EFEFEF, rather than the #EEEEEE (#D4D4D4 under neutral
   chrome) every other settings dialog uses; its white tiles and tables read as cards on it.
   Scoped with :has() so only the Job View changes; the body prefix out-ranks Chrome-Neutral.css's
   .totm-chrome-neutral #SettingWrapperDialog. */
:root {
    --jv-dialog-bg: #EFEFEF;
}

body #SettingWrapperDialog:has(#SettingsDialogContent > .JobView) {
    background-color: var(--jv-dialog-bg);
}

/* Bookings: "Show on Scheduler" on every row. Same !important reasoning as .JvReload. */
.JobView button.JvShowBooking {
    padding: 2px 8px !important;
    background-color: #fff !important;
    color: var(--totm-brand, #1976D2) !important;
    border: 1px solid var(--totm-border-strong, #C9CCD1) !important;
    border-radius: 5px !important;
    white-space: nowrap;
    cursor: pointer;
}

.JobView .JvTiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.JobView .JvTile {
    border: 1px solid var(--totm-border, #E3E5E8);
    border-radius: 6px;
    padding: 8px 10px;
    background: #fff;
}

.JobView .JvTileValue {
    font-size: var(--totm-fs-lg, 16px);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.JobView .JvTileLabel {
    font-size: var(--totm-fs-xs, 12px);
    color: var(--totm-text-muted, #5F6368);
}

.JobView .JvSection {
    margin-bottom: 16px;
}

.JobView .JvSectionTitle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 6px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--totm-border, #E3E5E8);
    font-size: var(--totm-fs-lg, 16px);
    font-weight: 600;
}

.JobView .JvCount:not(:empty) {
    min-width: 18px;
    padding: 0 6px;
    border-radius: 9px;
    background: var(--totm-brand-tint, #E8F1FB);
    color: var(--totm-brand-ink, #0C447C);
    font-size: var(--totm-fs-xs, 12px);
    text-align: center;
}

.JobView .JvSubTitle {
    margin: 10px 0 4px 0;
    font-size: var(--totm-fs-sm, 13px);
    font-weight: 600;
    color: var(--totm-text-muted, #5F6368);
}

.JobView .JvFields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 8px 24px;
}

.JobView .JvField {
    display: flex;
    gap: 8px;
}

/* Description: the label sits above, so the text has the whole width of the dialog - a job
   description can run to many lines. */
.JobView .JvFieldWide {
    grid-column: 1 / -1;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
}

    .JobView .JvField.JvFieldWide label {
        flex: none;
    }

.JobView .JvField label {
    flex: 0 0 120px;
    color: var(--totm-text-muted, #5F6368);
}

.JobView .JvFieldValue {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.JobView .JvPreWrap {
    white-space: pre-wrap;
}

.JobView .JvMuted {
    color: var(--totm-text-muted, #5F6368);
    font-size: var(--totm-fs-xs, 12px);
}

.JobView .JvList {
    margin: 0;
    padding-left: 18px;
}

    .JobView .JvList li + li {
        margin-top: 6px;
    }

.JobView .JvEmpty {
    color: var(--totm-text-muted, #5F6368);
    font-style: italic;
    padding: 4px 0;
}

.JobView .JvError {
    color: #b3261e;
}

.JobView .JvTableWrap {
    overflow-x: auto;
}

.JobView .JvTable {
    width: 100%;
}

    .JobView .JvTable th {
        text-align: left;
        white-space: nowrap;
    }

    .JobView .JvTable .JvNum {
        text-align: right;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .JobView .JvTable tr.JvUpcoming td {
        background: var(--totm-brand-tint, #E8F1FB);
    }

.JobView .JvIcon {
    margin-right: 5px;
    color: var(--totm-text-muted, #5F6368);
}

.JobView .JvBadges {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}

.JobView .JvBadge {
    padding: 0 6px;
    border-radius: 8px;
    border: 1px solid var(--totm-border-strong, #C9CCD1);
    font-size: var(--totm-fs-2xs, 11px);
    white-space: nowrap;
}

.JobView .JvBadgeInfo {
    border-color: var(--totm-brand, #1976D2);
    color: var(--totm-brand-ink, #0C447C);
}

.JobView .JvBadgeOk {
    border-color: #2E7D32;
    color: #1B5E20;
}

.JobView .JvBadgeWarn {
    border-color: #B26A00;
    color: #8A4B00;
}

.JobView .JvBadgeBad {
    border-color: #b3261e;
    color: #b3261e;
}

.JobView .JvImages {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.JobView .JvImageThumb {
    width: 96px;
    height: 72px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--totm-border, #E3E5E8);
}

.JobView button.JvLinkButton {
    margin-top: 6px;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    color: var(--totm-brand, #1976D2) !important;
    text-decoration: underline;
    cursor: pointer;
}

/* Completed forms: the form name is the expander. Same !important reasoning as .JvReload. */
.JobView button.JvFormToggle {
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    color: var(--totm-brand, #1976D2) !important;
    font-weight: 500 !important;
    text-align: left;
    cursor: pointer;
}

.JobView tr.JvFormDetailRow > td {
    background: var(--totm-brand-tint, #E8F1FB);
}

.JobView .JvFormDetail {
    padding: 6px 4px;
}

/* Photos and videos: one tile shape for both, a fixed-size thumbnail over a one-line caption. */
.JobView .JvPhoto {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    width: 100px;
    color: var(--totm-text, #1A1A1A);
    text-decoration: none;
}

.JobView .JvPhotoName {
    width: 100%;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--totm-fs-2xs, 11px);
    color: var(--totm-text-muted, #5F6368);
    text-align: center;
}

.JobView .JvFileIcon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 72px;
    font-size: 28px;
    color: var(--totm-text-muted, #5F6368);
    border: 1px solid var(--totm-border, #E3E5E8);
    border-radius: 4px;
    background: #fff;
}

/* A video tile is a button - same !important reasoning as .JvReload. */
.JobView button.JvVideoTile {
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    color: var(--totm-text, #1A1A1A) !important;
    cursor: pointer;
}

.JobView .JvVideoPlayer {
    margin-top: 8px;
}

.JobView .JvVideo {
    display: block;
    max-width: 100%;
    max-height: 420px;
    background: #000;
    border-radius: 4px;
}

.JobView .JvFileList:empty {
    display: none;
}

/* Collapsible sections: the whole heading is the button. Same !important reasoning as .JvReload. */
.JobView button.JvSectionToggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 0;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    color: var(--totm-text, #1A1A1A) !important;
    font: inherit;
    font-weight: 600 !important;
    text-align: left;
    cursor: pointer;
}

.JobView .JvChevron {
    width: 12px;
    font-size: var(--totm-fs-xs, 12px);
    color: var(--totm-text-muted, #5F6368);
    transition: transform var(--totm-motion, 0.15s ease);
}

.JobView .JvCollapsed .JvChevron {
    transform: rotate(-90deg);
}

.JobView .JvCollapsed .JvSectionTitle {
    margin-bottom: 0;
}

/* Date Required leads the tiles, in the brand tint so it reads as the job's target date. */
.JobView .JvTile.JvTileRequired {
    border-color: var(--totm-brand, #1976D2);
    background: var(--totm-brand-tint, #E8F1FB);
}
