/* ============================================
   WORK ORDERS
   ============================================ */

#workorders-view { display: none; }

.wo-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.wo-header h2 { font-family: var(--font-mono); font-size: 20px; font-weight: 700; }

.wo-filters {
    display: flex; gap: 4px;
    background: var(--bg-2); border-radius: 8px; padding: 3px;
}
.wo-filter {
    padding: 7px 16px; border-radius: 6px;
    font-size: 13px; font-weight: 600; color: var(--text-2);
    cursor: pointer; transition: all var(--transition); border: none; background: none;
}
.wo-filter:hover { color: var(--text-1); }
.wo-filter.active { background: var(--accent); color: white; }

.wo-summary { display: flex; gap: 16px; margin-bottom: 20px; }
.wo-summary-card {
    flex: 1; background: var(--bg-1); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; text-align: center;
}
.wo-summary-card .wo-sum-value { font-family: var(--font-mono); font-size: 24px; font-weight: 700; }
.wo-summary-card .wo-sum-label { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

.wo-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 14px;
}

.wo-card {
    background: var(--bg-1); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    cursor: pointer; transition: all var(--transition);
    border-left: 4px solid var(--accent);
}
.wo-card:hover { background: var(--bg-2); transform: translateY(-1px); }
.wo-card.wo-in-progress { border-left-color: var(--orange); }
.wo-card.wo-completed { border-left-color: var(--green); }

.wo-card-top {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 8px;
}
.wo-card-name { font-weight: 700; font-size: 15px; }
.wo-card-price { font-family: var(--font-mono); font-size: 16px; font-weight: 700; color: var(--green); }
.wo-card-vehicle { font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.wo-card-meta {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-bottom: 8px;
}
.wo-card-date { font-size: 11px; color: var(--text-2); font-family: var(--font-mono); }
.wo-status {
    display: inline-flex; padding: 3px 10px; border-radius: 20px;
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.wo-st-in_progress { background: var(--orange-dim); color: var(--orange); }
.wo-st-completed { background: var(--green-dim); color: var(--green); }

.wo-card-items { font-size: 12px; color: var(--text-2); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.wo-card-item-line { display: flex; justify-content: space-between; padding: 2px 0; }
.wo-card-section-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-2); margin-top: 4px; margin-bottom: 2px; }

.wo-card-notes { font-size: 12px; color: var(--text-2); font-style: italic; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.wo-card-duration { font-size: 12px; color: var(--text-2); margin-top: 4px; }

.wo-card-actions {
    display: flex; gap: 6px; margin-top: 12px; padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* Work order line items in modal */
.wo-line-item {
    display: flex; gap: 8px; align-items: center; margin-bottom: 6px;
}
.wo-line-item input[type="text"] { flex: 1; padding: 8px 12px; font-size: 13px; }
.wo-line-item input[type="number"] { width: 110px; padding: 8px 12px; font-size: 13px; font-family: var(--font-mono); }
.wo-line-remove {
    background: none; border: none; color: var(--text-2);
    cursor: pointer; font-size: 18px; padding: 4px 8px;
    border-radius: 4px; transition: all var(--transition); flex-shrink: 0;
}
.wo-line-remove:hover { color: var(--red); background: var(--red-dim); }

.wo-total-bar {
    background: var(--bg-2); border-radius: var(--radius-sm); padding: 12px 16px;
}
.wo-total-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 0; font-size: 13px; color: var(--text-2);
}
.wo-total-val { font-family: var(--font-mono); font-weight: 600; }
.wo-grand-total {
    border-top: 2px solid var(--border-light); margin-top: 6px; padding-top: 8px;
    font-size: 15px; font-weight: 700; color: var(--text-0);
}
.wo-grand-total .wo-total-val { color: var(--green); font-size: 16px; }

@media (max-width: 900px) {
    .wo-grid { grid-template-columns: 1fr; }
    .wo-summary { flex-direction: column; }
}

.wo-number {
    font-family: var(--font-mono); font-size: 12px; font-weight: 700;
    color: var(--accent); background: var(--accent-glow);
    padding: 2px 8px; border-radius: 4px;
    margin-right: 8px;
}

.wo-search-bar {
    display: flex; gap: 8px; margin-bottom: 20px;
}
.wo-search-bar input {
    flex: 1; padding: 10px 14px; font-size: 14px;
}

/* Quantity field on parts lines */
.wo-line-item input.wo-line-qty {
    width: 58px; flex: 0 0 58px;
    padding: 8px 6px; text-align: center;
    font-size: 13px; font-family: var(--font-mono);
}
.wo-line-x {
    color: var(--text-2); font-size: 13px;
    flex-shrink: 0; margin: 0 -4px;
}

/* ─── CHECK-IN PANEL (from the phone) ─────────────────── */
.wo-checkin { margin-top: 4px; }
.wo-checkin-empty {
    margin-top: 16px; padding: 14px 16px; font-size: 13px; line-height: 1.55;
    color: var(--text-2); background: var(--bg-2);
    border: 1px dashed var(--border-light); border-radius: var(--radius-sm);
}
.wo-checkin-empty code {
    font-family: var(--font-mono); font-size: 12px; color: var(--accent);
    background: var(--bg-3); padding: 1px 6px; border-radius: 4px;
}
.wo-ck-row {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
    padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.wo-ck-row:last-child { border-bottom: none; }
.wo-ck-label { color: var(--text-1); flex: 1; min-width: 0; }
.wo-ck-label em {
    display: block; font-style: normal; font-size: 12px;
    color: var(--text-2); margin-top: 2px;
}
.wo-ck-state {
    font-family: var(--font-mono); font-size: 12px; font-weight: 700;
    flex-shrink: 0; text-transform: uppercase; letter-spacing: 0.5px;
}
.wo-ck-skipped { font-size: 12px; color: var(--text-2); padding-top: 10px; }

.wo-ph-stage {
    font-size: 11px; font-weight: 700; color: var(--text-2);
    text-transform: uppercase; letter-spacing: 1px; margin: 14px 0 8px;
    display: flex; align-items: center; gap: 8px;
}
.wo-ph-stage:first-child { margin-top: 0; }
.wo-ph-stage span {
    font-family: var(--font-mono); background: var(--bg-3);
    color: var(--text-1); padding: 1px 7px; border-radius: 10px; letter-spacing: 0;
}
.wo-ph-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.wo-ph {
    aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden;
    background: var(--bg-3); border: 1px solid var(--border);
    cursor: zoom-in; transition: border-color var(--transition);
}
.wo-ph:hover { border-color: var(--accent); }
.wo-ph img { width: 100%; height: 100%; object-fit: cover; display: block; }

.wo-photo-viewer {
    position: fixed; inset: 0; z-index: 3000; background: rgba(0,0,0,0.92);
    display: flex; align-items: center; justify-content: center;
    padding: 40px; cursor: zoom-out; animation: fadeUp 0.15s ease;
}
.wo-photo-viewer img {
    max-width: 100%; max-height: 100%; object-fit: contain;
    border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ─── CHECKLIST TEMPLATE EDITOR (Settings) ────────────── */
.ck-tpl-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ck-tpl-row input { flex: 1; min-width: 0; }
.ck-tpl-row select { width: 230px; flex-shrink: 0; font-size: 13px; }
.ck-tpl-row button {
    width: 34px; height: 34px; flex-shrink: 0; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-2);
    color: var(--text-2); cursor: pointer; font-size: 16px;
    transition: all var(--transition);
}
.ck-tpl-row button:hover { border-color: var(--red); color: var(--red); }

/* Work order shared with the customer */
.qt-shared-btn {
    border-color: var(--green) !important;
    color: var(--green) !important;
    background: var(--green-dim) !important;
}

/* ─── Share dialog: choose what the customer sees ─── */
.wsh-list { border: 1px solid var(--border); border-radius: var(--radius); padding: 2px 14px; background: var(--bg-2); }
.wsh-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); cursor: pointer; margin: 0; }
.wsh-row:last-of-type { border-bottom: none; }
.wsh-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.wsh-txt { flex: 1; min-width: 0; }
.wsh-txt b { display: block; font-size: 14px; color: var(--text-0); font-weight: 600; }
.wsh-txt span { display: block; font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wsh-ph-head { display: flex; align-items: center; gap: 8px; padding: 12px 0 8px; border-top: 1px solid var(--border); }
.wsh-ph-head b { flex: 1; font-size: 14px; }
.wsh-ph-head span { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); }
.wsh-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding-bottom: 12px; }
.wsh-ph { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; outline: 3px solid transparent; outline-offset: -3px; cursor: pointer; background: #000; }
.wsh-ph img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .22; filter: grayscale(1); }
.wsh-ph b { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-size: 9.5px; font-weight: 700;
            letter-spacing: .5px; text-transform: uppercase; padding: 2px 0 3px; background: rgba(0,0,0,.6); color: var(--text-2); }
.wsh-ph.on b { background: var(--accent); color: #fff; }
.wsh-ph.on { outline-color: var(--accent); }
.wsh-ph.on img { opacity: 1; filter: none; }
.wsh-ph i { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; font-style: normal; font-size: 11px;
            color: #fff; background: rgba(0,0,0,.55); border: 2px solid rgba(255,255,255,.7); display: flex; align-items: center; justify-content: center; }
.wsh-ph.on i { background: var(--accent); border-color: var(--accent); }
.wsh-link { text-align: center; border-top: 1px solid var(--border); padding-top: 16px; }
