/* Work Order module. Ports the page-local <style> blocks of v3's WorkOrderEdit (chat bubbles,
   FDD preview) and the wo-print-* classes its print window relied on. */

.required-field .mud-input-slot::before { border-color: var(--mud-palette-warning); }

.fdd-detection-preview:hover { box-shadow: 0 4px 18px rgba(15, 23, 42, 0.12); }
.fdd-detection-preview:focus-visible { outline: 2px solid var(--mud-palette-primary); outline-offset: 2px; }

/* Chat Logs */
.chat-messages-area {
    height: 350px;
    overflow-y: auto;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 8px;
}
.chat-row { display: flex; margin-bottom: 6px; }
.chat-row-me { justify-content: flex-end; }
.chat-row-other { justify-content: flex-start; }
.chat-bubble {
    max-width: 80%;
    padding: 6px 10px;
    border-radius: 8px;
    word-break: break-word;
}
.chat-bubble-me { background: #d9edf7; color: #333; border-bottom-right-radius: 2px; }
.chat-bubble-other { background: #337ab7; color: #fff; border-bottom-left-radius: 2px; }
.chat-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 2px; }
.chat-name { font-weight: 600; font-size: 0.75rem; white-space: nowrap; }
.chat-bubble-me .chat-name { color: #555; }
.chat-bubble-other .chat-name { color: #fff; }
.chat-time { font-size: 0.65rem; text-align: right; white-space: nowrap; line-height: 1.2; }
.chat-bubble-me .chat-time { color: #999; }
.chat-bubble-other .chat-time { color: rgba(255, 255, 255, 0.85); }
.chat-text { font-size: 0.85rem; white-space: pre-wrap; }
.chat-bubble-me .chat-text { color: #333; }
.chat-bubble-other .chat-text { color: #fff; }
.chat-input-area { display: flex; align-items: center; gap: 6px; }
.chat-send-btn { height: 40px; min-width: 70px !important; }

@media (max-width: 600px) {
    .chat-messages-area { height: 250px; padding: 6px; }
    .chat-bubble { max-width: 90%; padding: 5px 8px; }
    .chat-name { font-size: 0.7rem; }
    .chat-time { font-size: 0.6rem; }
    .chat-text { font-size: 0.8rem; }
    .chat-send-btn { min-width: 55px !important; font-size: 0.75rem; }
}

/* Downtimes tab keeps v3's blue header row. */
.wo-downtime-table thead tr { background: #a7dcfe; }
.wo-downtime-table { font-size: 0.85rem; }

/* Print WO. The hidden DOM is copied into the print window by print-helper.js, which also
   copies these stylesheet links, so the rules live here rather than inline. */
.workorder-detail-print .print-title { display: none; font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.wo-print-section { margin-bottom: 14px; page-break-inside: avoid; }
.wo-print-section-title {
    font-weight: 700;
    font-size: 13px;
    color: #2c5364;
    border-bottom: 2px solid #3d6b7f;
    padding-bottom: 4px;
    margin-bottom: 6px;
}
.wo-print-meta-table,
.wo-print-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.wo-print-meta-table td,
.wo-print-table td,
.wo-print-table th { border: 1px solid #cbd5e1; padding: 4px 6px; vertical-align: top; }
.wo-print-label { font-weight: 600; background: #f1f5f9; width: 140px; white-space: nowrap; }
.wo-print-table th { background: #e3f2fd; text-align: left; }
.wo-print-number { text-align: right; font-variant-numeric: tabular-nums; }
.wo-print-total-row td { font-weight: 700; background: #eef5ff; }
.wo-print-empty { color: #64748b; font-style: italic; padding: 4px 0; }
.wo-assignee-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.wo-assignee-chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: #e3f2fd;
    color: #0d47a1;
    font-size: 12px;
    border: 1px solid #bbdefb;
}
.wo-print-sig-img { max-width: 100%; max-height: 120px; }
.wo-print-sig-img-wrap { padding: 2px 0 4px; }
.wo-print-sig-table td { vertical-align: bottom; }
.wo-print-sig-caption { font-weight: 600; margin-top: 4px; border-top: 1px solid #94a3b8; padding-top: 3px; }

/* Drawn signature shown on the General Information tab. */
.wo-sig-shown {
    margin: 4px 0 2px;
    padding: 4px;
    border: 1px solid var(--cmms-line);
    border-radius: 8px;
    background: #fff;
    max-width: 320px;
}

.wo-sig-shown img {
    display: block;
    width: 100%;
    max-height: 120px;
    object-fit: contain;
}

/* ── Completion signature dialog ─────────────────────────────────────────── */
.wo-sig-title {
    display: flex;
    gap: 10px;
    align-items: center;
    color: var(--cmms-primary-dark);
}

.wo-sig-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.wo-sig-card {
    display: flex;
    flex-direction: column;
    padding: 12px;
    border: 1px solid var(--cmms-line);
    border-radius: 10px;
    background: var(--cmms-surface);
}

.wo-sig-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.wo-sig-card-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--cmms-body);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.wo-sig-pad {
    display: block;
    width: 100%;
    height: 160px;
    border: 1px dashed var(--cmms-line-input);
    border-radius: 8px;
    background: #fff;
    cursor: crosshair;
    /* A touch starting on the pad draws; it must not scroll or zoom the dialog. */
    touch-action: none;
    -ms-touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.wo-sig-pad:hover {
    border-color: var(--cmms-primary-light);
}

.wo-sig-hint {
    margin-top: 4px;
    color: var(--cmms-faint);
    font-size: 0.7rem;
    text-align: center;
    letter-spacing: 0.03em;
}

@media (max-width: 720px) {
    .wo-sig-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .wo-sig-card {
        padding: 10px;
    }

    .wo-sig-pad {
        height: 140px;
    }
}
