/* 手持裝置／年長者友善閱讀 */

.doc-preview-read {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.signoff-doc-read {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-size: calc(15px * var(--text-zoom-scale, 1));
    line-height: 1.75;
    color: #1e293b;
    background: #fff;
    border: 1px solid #000;
    border-radius: 0;
    padding: 12px;
    margin-bottom: 12px;
}

.signoff-doc-read.mobile-compact {
    border: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: 8px;
}

.signoff-doc-read .signoff-doc-title {
    text-align: center;
    font-size: calc(22px * var(--text-zoom-scale, 1));
    font-weight: 700;
    letter-spacing: 6px;
    margin-bottom: 14px;
}

.signoff-meta-table {
    width: 100%;
    border-collapse: collapse;
    font-size: inherit;
}

.signoff-meta-table td {
    border: 1px solid #000;
    padding: 8px 10px;
    vertical-align: top;
    word-break: break-word;
}

.signoff-meta-table .sf-label {
    background: #f9fafb;
    font-weight: 700;
    white-space: nowrap;
}

.signoff-body-box {
    border: 1px solid #000;
    border-top: none;
    padding: 12px 10px 0;
    min-height: 0;
    height: auto;
}

.signoff-body-box .signoff-section-title {
    font-weight: 700;
    margin-bottom: 8px;
}

.signoff-section-proposed {
    margin-top: 12px;
}

.signoff-body-text {
    white-space: pre-wrap;
    line-height: 1.85;
    word-break: break-word;
    overflow-wrap: anywhere;
    text-align: left;
}

.signoff-body-closing {
    margin-top: 12px;
    margin-bottom: 8px;
    text-align: right;
}

.signoff-sig-in-body {
    margin: 0 -10px 0;
}

.signoff-sig-in-body .signoff-sig-wrap {
    margin: 0;
}

.signoff-sig-in-body .signoff-sig-table {
    margin-top: 0;
    table-layout: fixed;
}

.signoff-sig-in-body .signoff-sig-table tr > *:first-child {
    border-left: none;
}

.signoff-sig-in-body .signoff-sig-table tr > *:last-child {
    border-right: none;
}

.signoff-sig-in-body .signoff-sig-table tr:last-child > * {
    border-bottom: none;
}

.signoff-body-box,
.signoff-body-box .signoff-section-title {
    text-align: left;
}

/* 簽名頁載入後須靠左，避免遺留 .loading 的置中樣式影響內文 */
#remote-form-preview {
    text-align: left;
}

#remote-form-preview.loading {
    text-align: center;
}

.trip-attach-block {
    text-align: left;
}

.trip-attach-pdf-object,
.trip-attach-pdf-frame {
    min-height: 280px;
    background: #f8fafc;
}

#remote-sign-status,
#remote-form-preview,
#detail-content {
    font-size: calc(1rem * var(--text-zoom-scale, 1));
}

#detail-content .signoff-doc-read,
#detail-content .doc-preview-read {
    background: #fff;
}

.signoff-doc-footer {
    font-size: calc(13px * var(--text-zoom-scale, 1));
    color: #475569;
    margin-top: 8px;
    text-align: right;
}

.signoff-sig-section {
    margin-top: 10px;
}

.signoff-sig-section-title {
    font-weight: 700;
    text-align: center;
    background: #f9fafb;
    border: 1px solid #000;
    border-bottom: none;
    padding: 8px 10px;
}

.signoff-sig-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    border: 1px solid #000;
}

.signoff-sig-card {
    border-right: 1px solid #000;
    min-width: 0;
}

.signoff-sig-card:last-child {
    border-right: none;
}

.signoff-sig-card-label {
    background: #f8fafc;
    font-weight: 700;
    text-align: center;
    padding: 8px 10px;
    border-bottom: 1px solid #000;
    font-size: 14px;
}

.signoff-sig-slot {
    padding: 10px;
    text-align: center;
    min-height: 56px;
}

.signoff-sig-slot.empty {
    color: #cbd5e1;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.signoff-sig-slot img {
    max-height: 52px;
    max-width: 100%;
    object-fit: contain;
    display: block;
    margin: 0 auto 6px;
}

.signoff-sig-evidence {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.5;
    word-break: break-word;
}

.signoff-sig-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.signoff-sig-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin-top: 10px;
    table-layout: fixed;
}

.signoff-sig-table th,
.signoff-sig-table td {
    border: 1px solid #000;
    padding: 8px;
    vertical-align: top;
    word-break: break-word;
}

.signoff-sig-table .sig-col-applicant {
    width: 14%;
}

.signoff-sig-table .sig-col-counter {
    width: 16%;
}

.signoff-sig-table .sig-col-approval {
    width: auto;
}

.signoff-sig-applicant {
    width: 100%;
    margin-top: 10px;
}

/* 年長者閱讀模式 */
html.elder-reading-mode {
    -webkit-text-size-adjust: 100%;
}

html.elder-reading-mode .signoff-doc-read {
    font-size: calc(17px * var(--text-zoom-scale, 1));
    line-height: 1.9;
}

html.elder-reading-mode .signoff-body-text {
    font-size: calc(18px * var(--text-zoom-scale, 1));
    line-height: 2;
}

html.elder-reading-mode .signoff-doc-read .signoff-doc-title {
    font-size: calc(24px * var(--text-zoom-scale, 1));
}

html.elder-reading-mode h1,
html.elder-reading-mode #remote-title {
    font-size: 22px !important;
}

html.elder-reading-mode .sub {
    font-size: 16px !important;
    line-height: 1.7 !important;
}

/* 手持裝置：滿版、直向欄位、避免窄欄換行 */
@media (max-width: 768px) {
    body.mobile-sign-page,
    body.remote-sign-mode {
        padding: 4px !important;
    }

    body.mobile-sign-page .wrap,
    body.remote-sign-mode #remote-page {
        max-width: none !important;
        width: 100% !important;
        padding: 4px !important;
        margin: 0 !important;
        box-sizing: border-box;
    }

    body.mobile-sign-page .card,
    body.remote-sign-mode .remote-card,
    body.remote-sign-mode #remote-page > div {
        padding: 10px !important;
        border-radius: 8px;
        box-shadow: none !important;
        border: 1px solid #e2e8f0;
    }

    /* 遠端簽名頁外層卡片已有白底，內文可透明；詳情／閱讀 modal 須保留白底 */
    body.mobile-sign-page .doc-preview-read,
    body.mobile-sign-page .signoff-doc-read {
        padding: 0 !important;
        font-size: calc(16px * var(--text-zoom-scale, 1));
        line-height: 1.85;
        border: none !important;
        border-radius: 0 !important;
        background: transparent !important;
    }

    #detail-content .doc-preview-read,
    #detail-content .signoff-doc-read,
    #remote-form-preview .doc-preview-read,
    #remote-form-preview .signoff-doc-read {
        padding: 0 0 12px !important;
        font-size: calc(16px * var(--text-zoom-scale, 1));
        line-height: 1.85;
        border: none !important;
        border-radius: 0 !important;
        background: #fff !important;
    }

    #detail-content .signoff-body-box,
    #remote-form-preview .signoff-body-box {
        background: #fff;
    }

    #detail-content .signoff-body-text,
    #remote-form-preview .signoff-body-text {
        background: #fff;
    }

    .signoff-doc-read .signoff-doc-title {
        font-size: calc(20px * var(--text-zoom-scale, 1));
        letter-spacing: 4px;
        margin-bottom: 10px;
    }

    .signoff-meta-table {
        border: none;
    }

    .signoff-meta-table,
    .signoff-meta-table tbody,
    .signoff-meta-table tr,
    .signoff-meta-table td {
        display: block;
        width: 100% !important;
        box-sizing: border-box;
    }

    .signoff-meta-table tr {
        margin-bottom: 0;
        border-bottom: none;
    }

    .signoff-meta-table td {
        border: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .signoff-meta-table tr td:first-child {
        border-top: none;
    }

    .signoff-meta-table .sf-label {
        padding: 8px 0 4px;
        font-size: calc(13px * var(--text-zoom-scale, 1));
        background: transparent;
        color: #64748b;
    }

    .signoff-meta-table td:not(.sf-label) {
        padding: 0 0 12px;
        font-size: calc(16px * var(--text-zoom-scale, 1));
        background: #fff;
        border-bottom: 1px solid #e5e7eb;
    }

    .signoff-body-box {
        border: none;
        border-top: 1px solid #e5e7eb;
        padding: 12px 0;
        margin-top: 4px;
    }

    .signoff-body-text {
        font-size: calc(17px * var(--text-zoom-scale, 1));
        line-height: 1.95;
    }

    .trip-attach-pdf-object,
    .trip-attach-pdf-frame {
        height: 55vh !important;
        min-height: 320px;
    }

    /* 手機：每職位一卡（職稱 + 簽名配對），由 buildSignoffSigTableHtml compact 模式產生 */
    .signoff-sig-section {
        margin-top: 12px;
    }

    .signoff-sig-section-title {
        border: 1px solid #cbd5e1;
        border-bottom: none;
        border-radius: 10px 10px 0 0;
        background: #f1f5f9;
        text-align: left;
        padding: 10px 12px;
        font-size: calc(14px * var(--text-zoom-scale, 1));
        color: #334155;
    }

    .signoff-sig-section-title + .signoff-sig-cards {
        border: 1px solid #cbd5e1;
        border-top: none;
        border-radius: 0 0 10px 10px;
        padding: 10px;
        background: #fff;
    }

    .signoff-sig-cards {
        display: flex;
        flex-direction: column;
        gap: 10px;
        border: none;
    }

    .signoff-sig-card {
        border: 1px solid #cbd5e1;
        border-radius: 10px;
        overflow: hidden;
        background: #fff;
    }

    .signoff-sig-card-label {
        background: #f1f5f9;
        color: #1e293b;
        text-align: left;
        border-bottom: 1px solid #e2e8f0;
        font-size: calc(16px * var(--text-zoom-scale, 1));
        font-weight: 700;
        padding: 10px 12px;
    }

    .signoff-sig-slot {
        padding: 12px;
        min-height: 64px;
        text-align: left;
        background: #fff;
    }

    .signoff-sig-slot img {
        max-height: 56px;
        max-width: 100%;
        object-fit: contain;
        display: block;
        margin-bottom: 8px;
    }

    .signoff-sig-evidence {
        font-size: calc(12px * var(--text-zoom-scale, 1));
        line-height: 1.6;
        color: #64748b;
    }

    .signoff-sig-wrap {
        overflow: visible;
        margin-bottom: 4px;
    }

    .text-zoom-bar {
        width: calc(100vw - 16px);
        max-width: none;
        left: 8px;
        right: 8px;
        transform: none;
        border-radius: 12px;
        flex-wrap: wrap;
        justify-content: center;
        padding: 10px;
    }

    .text-zoom-bar button {
        flex: 0 1 auto;
        min-width: 44px;
    }

    .text-zoom-bar button.text-zoom-reset,
    .text-zoom-bar #text-reading-mode-btn {
        flex: 1;
        min-width: 64px;
    }
}
