/* ChapsV_AppSFA_DAF.css — Deal Approval Form styles */

.daf-page { max-width: 900px; margin: 16px auto; padding: 0 12px; font-family: OpenSans, sans-serif; font-size: inherit; }
.daf-layout { display: flex; gap: 12px; align-items: flex-start; }
.daf-form-col { flex: 1; min-width: 0; }
.daf-summary-col { width: 220px; flex-shrink: 0; position: sticky; top: 12px; }

/* overflow:visible (not hidden) is intentional — the admin "Reviewing as ▾"
   <select> popup must escape the card's bounds; overflow:hidden was clipping
   the option list behind the comment textarea. The rounded-top-corner clip
   that overflow:hidden previously provided is restored via border-radius
   on .daf-card-header below. */
.daf-card { background: #fff; border: 1px solid #dde1e7; border-radius: 4px; margin-bottom: 10px; overflow: visible; }
.daf-card.hidden { display: none; }

.daf-card-header { padding: 8px 14px; background: #f7f8fa; border-bottom: 1px solid #dde1e7; font-size: 12px; font-weight: 600; color: #444; display: flex; align-items: center; gap: 8px; border-radius: 4px 4px 0 0; }
.daf-section-badge { font-size: 10px; font-weight: 700; color: #666; background: #e4e6ea; border-radius: 3px; padding: 1px 6px; }

.daf-skip-notice { display: none; padding: 7px 14px; background: #fafafa; border-bottom: 1px solid #eee; font-size: 12px; color: #999; align-items: center; gap: 6px; }
.daf-skip-notice.visible { display: flex; }

/* Question rows: label takes majority width (minmax(0,1fr) — the min:0 keeps
   long labels from forcing horizontal overflow); control column is a fixed
   180px — enough room for the widest path-style buttons ("Yes — with deliverables",
   "No — T&M only") at ~165px combined, with a small breathing margin.
   The dependent strips (.daf-appr-strip, .daf-detail-strip, .daf-subq-block)
   keep their 224px left indent as a visual relation marker; they intentionally
   sit inside the label column now rather than aligned to the control column. */
.daf-field-row { display: grid; grid-template-columns: minmax(0, 1fr) 180px; align-items: start; padding: 6px 14px; border-bottom: 1px solid #f2f3f5; min-height: 34px; }
.daf-field-row:last-child { border-bottom: none; }
.daf-field-row.hidden { display: none; }
/* Reviewer-filtered hide: non-admin DAF role holders see only their questions.
   !important beats .visible / display:grid / display:block on all element types. */
.daf-reviewer-hidden { display: none !important; }

.daf-field-label { font-size: 12px; color: #555; padding-top: 4px; padding-right: 10px; line-height: 1.45; }
.daf-fid { display: inline-block; font-size: 10px; font-weight: 700; color: #1a73e8; background: #e8f0fe; border-radius: 3px; padding: 1px 5px; margin-right: 4px; letter-spacing: 0.1px; }
.daf-info-icon { display: inline-block; font-size: 10px; color: #aaa; cursor: pointer; margin-left: 3px; vertical-align: middle; }
.daf-info-icon:hover { color: #1a73e8; }

.daf-field-control { padding-top: 2px; }

.daf-yn-group { display: flex; gap: 5px; flex-wrap: wrap; }
.daf-yn-btn { display: inline-flex; align-items: center; padding: 3px 12px; border: 1px solid #c8cdd5; border-radius: 3px; font-size: 12px; color: #444; background: #fff; cursor: pointer; transition: all 0.1s; user-select: none; font-family: inherit; white-space: nowrap; }
.daf-yn-btn:hover { border-color: #1a73e8; color: #1a73e8; }
.daf-yn-btn.sel-yes { background: #fff3e0; border-color: #e67700; color: #b85c00; font-weight: 500; }
.daf-yn-btn.sel-no  { background: #e8f5e9; border-color: #2e7d32; color: #256427; font-weight: 500; }
.daf-yn-btn.sel-path { background: #e8f0fe; border-color: #1a73e8; color: #1558b0; font-weight: 500; }
.daf-yn-btn:disabled { opacity: 0.6; cursor: not-allowed; pointer-events: none; }

.daf-appr-strip { display: none; padding: 5px 14px 6px 224px; background: #fffbf0; border-bottom: 1px solid #fde8c0; }
.daf-appr-strip.visible { display: block; }
.daf-appr-title { font-size: 10px; font-weight: 700; color: #b85c00; text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 3px; }
.daf-appr-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.daf-appr-pill { font-size: 11px; background: #fff; border: 1px solid #e0a060; color: #7a4000; border-radius: 3px; padding: 1px 7px; font-weight: 500; }
.daf-appr-note { font-size: 10px; color: #a07040; margin-top: 3px; }

.daf-detail-strip { display: none; padding: 0 14px 8px 224px; background: #fafbfc; border-bottom: 1px solid #f0f2f5; }
.daf-detail-strip.visible { display: block; }
/* box-sizing: border-box keeps `width: 100%` honest — without it the 5+8 padding
   and 1+1 border are added on top of 100%, which together with .daf-card's
   intentional `overflow: visible` (for the native <select> popup) caused the
   textarea to visibly bleed past the card's right edge. */
.daf-dtxt { width: 100%; max-width: 100%; box-sizing: border-box; border: 1px solid #c8cdd5; border-radius: 3px; padding: 5px 8px; font-size: 12px; font-family: inherit; color: #333; background: #fff; resize: vertical; min-height: 48px; outline: none; }
.daf-dtxt:focus { border-color: #1a73e8; }
.daf-dtxt::placeholder { color: #c0c4cc; }
.daf-dtxt:read-only { background: #f7f8fa; color: #888; cursor: default; }

.daf-path-strip { display: none; padding: 5px 14px; font-size: 11px; font-weight: 600; align-items: center; gap: 6px; border-bottom: 1px solid; }
.daf-path-strip.visible { display: flex; }
.daf-path-strip.d1 { background: #e8f0fe; color: #1a73e8; border-color: #c5d8fc; }
.daf-path-strip.d5 { background: #e8f5e9; color: #2e7d32; border-color: #b2dfdb; }

.daf-subq-block { display: none; padding: 8px 14px 10px 224px; background: #fafbfc; border-bottom: 1px solid #f0f2f5; }
.daf-subq-block.visible { display: block; }
.daf-subq-item { margin-bottom: 8px; }
.daf-subq-label { display: block; font-size: 11px; font-weight: 600; color: #555; margin-bottom: 3px; }
.daf-subq-id { color: #1a73e8; font-weight: 700; margin-right: 3px; }

.daf-action-bar { background: #fff; border: 1px solid #dde1e7; border-radius: 4px; padding: 9px 14px; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
/* Action-bar buttons (Save Draft / Cancel) toggled by the revise-state machine.
   Used by _buildForm (initial submitted state), _lockForm and _unlockForm. */
.daf-action-bar button.hidden { display: none; }
.daf-btn-primary { padding: 5px 18px; background: #1a73e8; color: #fff; border: none; border-radius: 3px; font-size: 12px; font-weight: 500; cursor: pointer; font-family: inherit; }
.daf-btn-primary:hover { background: #1558b0; }
.daf-btn-primary:disabled { background: #a0b4d4; cursor: not-allowed; }
.daf-btn-secondary { padding: 5px 13px; background: #fff; color: #555; border: 1px solid #c8cdd5; border-radius: 3px; font-size: 12px; cursor: pointer; font-family: inherit; }
.daf-btn-secondary:hover { border-color: #888; }
.daf-progress-text { font-size: 12px; color: #888; margin-left: auto; margin-right: 8px; }
.daf-status-msg { font-size: 12px; color: #2e7d32; font-weight: 500; }

/* ─── DAFSTATUS soft pill (action-bar + tab badge) ────────────────────────
   Single class-based style source shared by the in-form pill (action bar)
   and the tab badge (TabLabel). Soft pastel backgrounds + darker same-hue
   text + 1px same-hue border. Palette is Tailwind-inspired:
     pending/notstarted → slate-100 / slate-600 / slate-300
     inprogress         → amber-100 / amber-800 / amber-300
     approved           → green-100 / green-800 / green-300
     rejected           → red-100   / red-800   / red-300
*/
.daf-status-pill { display: inline-block; border-radius: 15px; padding: 2px 10px; font-size: 11px; font-weight: 600; border: 1px solid transparent; line-height: 1.5; }
.daf-status-pill.status-pending    { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.daf-status-pill.status-inprogress { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.daf-status-pill.status-approved   { background: #dcfce7; color: #166534; border-color: #86efac; }
.daf-status-pill.status-rejected   { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

/* ─── Disabled Submit-for-Approval button ─────────────────────────────────
   The button uses `w2ui-btn w2ui-btn-blue daf-btn-primary` so the w2ui base
   button reset applies and the daf-btn-primary layout (padding/radius) is
   preserved. But w2ui-btn-blue's background is declared with !important in
   ChapsV_AppBuilder.css — it overrides daf-btn-primary:disabled's gray fill.
   These two rules win the cascade (higher specificity AND !important) so a
   submitted/locked Submit button renders unambiguously disabled: gray fill,
   muted text, not-allowed cursor, no hover state, full opacity (otherwise
   w2ui's default 0.5 opacity stacks with our gray and looks washed out).
*/
button.w2ui-btn.w2ui-btn-blue.daf-btn-primary:disabled,
button.w2ui-btn.w2ui-btn-blue.daf-btn-primary[disabled] {
    background: #d0d6dd !important;
    color: #8a8f96 !important;
    border-color: #c0c6cd !important;
    cursor: not-allowed !important;
    opacity: 1 !important;
}
button.w2ui-btn.w2ui-btn-blue.daf-btn-primary:disabled:hover,
button.w2ui-btn.w2ui-btn-blue.daf-btn-primary[disabled]:hover {
    background: #d0d6dd !important;
    color: #8a8f96 !important;
    border-color: #c0c6cd !important;
}

.daf-review-block { background: #f7f8fa; border: 1px solid #dde1e7; border-radius: 3px; padding: 6px 10px; margin-top: 0; font-size: 11px; }
.daf-review-fid { display: inline-block; font-size: 10px; font-weight: 700; color: #555; background: #e6e9ee; border-radius: 3px; padding: 1px 5px; margin-right: 4px; letter-spacing: 0.1px; }
.daf-review-role { font-weight: 600; color: #555; }
.daf-review-status { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 10px; font-weight: 700; margin-left: 6px; }
.daf-review-status.pending { background: #f0f0f0; color: #888; }
.daf-review-status.approved { background: #e8f5e9; color: #2e7d32; }
.daf-review-status.rejected { background: #fdecea; color: #c62828; }
.daf-review-comment { margin-top: 4px; color: #777; font-style: italic; }

.daf-summary-card { background: #fff; border: 1px solid #dde1e7; border-radius: 4px; overflow: hidden; }
.daf-summary-header { padding: 8px 12px; background: #f7f8fa; border-bottom: 1px solid #dde1e7; font-size: 11px; font-weight: 600; color: #444; }
.daf-summary-body { padding: 8px 10px; }
.daf-prog-wrap { background: #eaecef; border-radius: 2px; height: 3px; margin-bottom: 3px; overflow: hidden; }
.daf-prog-fill { height: 100%; background: #1a73e8; border-radius: 2px; transition: width 0.25s; width: 0%; }
.daf-prog-lbl { font-size: 10px; color: #aaa; margin-bottom: 8px; }
.daf-summ-empty { font-size: 12px; color: #bbb; }
.daf-summ-item { padding: 5px 8px; border-radius: 3px; margin-bottom: 5px; background: #fffbf0; border: 1px solid #f0d090; }
.daf-summ-name { font-size: 11px; font-weight: 600; color: #7a4000; }
.daf-summ-qs   { font-size: 10px; color: #a07040; margin-top: 1px; }

/* ─── Phase 4 review controls ─────────────────────────────────────────── */

/* Expanded review-block form (D-02) */
.daf-review-block.expanded { padding: 8px 12px; }
.daf-review-header { display: flex; align-items: center; gap: 8px; }

.daf-review-form { margin-top: 6px; }

/* Admin attribution dropdown row */
.daf-review-attribution { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 11px; color: #555; }
.daf-review-attribution label { color: #888; }
.daf-review-attr-select { font-size: 11px; padding: 2px 6px; border: 1px solid #c8cdd5; border-radius: 3px; background: #fff; color: #333; min-width: 160px; font-family: inherit; }
.daf-review-attr-select:focus { outline: none; border-color: #1a73e8; }

/* Decision pills (Approve / Reject) */
.daf-review-controls { display: flex; gap: 6px; margin-bottom: 6px; }
.daf-review-decision-btn { display: inline-flex; align-items: center; padding: 3px 12px; border: 1px solid #c8cdd5; border-radius: 3px; font-size: 12px; color: #444; background: #fff; cursor: pointer; transition: all 0.1s; user-select: none; font-family: inherit; }

/* Color-coded by intent — green for approve, red for reject. Pale fill by
   default; deeper fill when selected via .sel-approve / .sel-reject. Reuses
   the approved/rejected palette already used by the status pills and revise
   annotations — no new color tokens introduced. */
.daf-review-decision-btn[data-decision="approved"] { background: #f0fdf4; border-color: #86efac; color: #166534; }
.daf-review-decision-btn[data-decision="approved"]:hover { border-color: #2e7d32; }
.daf-review-decision-btn[data-decision="rejected"] { background: #fff5f5; border-color: #fca5a5; color: #991b1b; }
.daf-review-decision-btn[data-decision="rejected"]:hover { border-color: #c62828; }

.daf-review-decision-btn.sel-approve { background: #e8f5e9; border-color: #2e7d32; color: #256427; font-weight: 500; }
.daf-review-decision-btn.sel-reject { background: #fdecea; border-color: #c62828; color: #b71c1c; font-weight: 500; }
.daf-review-decision-btn:disabled { opacity: 0.6; cursor: not-allowed; pointer-events: none; }

/* Approve All bulk button — primary green action. Overrides .daf-btn-secondary
   neutral styling for the bulk-approve use case in the action bar. The id
   prefix selector matches the per-recid id pattern produced by the JS
   (#daf-approve-all-{recid}). Specificity (0,1,0) matches .daf-btn-secondary;
   this rule comes later so it wins via source order. */
[id^="daf-approve-all-"] { background: #2e7d32; color: #fff; border-color: #256427; }
[id^="daf-approve-all-"]:hover { background: #256427; border-color: #1d501b; }
[id^="daf-approve-all-"]:disabled { background: #a0c4a3; border-color: #a0c4a3; color: #fff; cursor: not-allowed; }

/* Comment textarea — match .daf-dtxt style but slightly tighter padding.
   box-sizing: border-box prevents the 5+8 padding and 1+1 border from being
   added on top of width:100%, which (with .daf-card overflow:visible) caused
   the textarea to bleed past the card's right edge. */
.daf-review-cmt { width: 100%; max-width: 100%; box-sizing: border-box; border: 1px solid #c8cdd5; border-radius: 3px; padding: 5px 8px; font-size: 12px; font-family: inherit; color: #333; background: #fff; resize: vertical; min-height: 36px; outline: none; }
.daf-review-cmt:focus { border-color: #1a73e8; }
.daf-review-cmt::placeholder { color: #c0c4cc; }

/* Submit Review button row (with optional Cancel button on Edit Review path) */
.daf-review-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.daf-review-submit-btn { padding: 4px 14px; background: #1a73e8; color: #fff; border: none; border-radius: 3px; font-size: 11px; font-weight: 500; cursor: pointer; font-family: inherit; }
.daf-review-submit-btn:hover { background: #1558b0; }
.daf-review-submit-btn:disabled { background: #a0b4d4; cursor: not-allowed; }
/* Cancel button (Edit Review only) — secondary/neutral, matches .daf-review-edit-btn register */
.daf-review-cancel-btn { padding: 4px 12px; background: #fff; color: #555; border: 1px solid #c8cdd5; border-radius: 3px; font-size: 11px; cursor: pointer; font-family: inherit; }
.daf-review-cancel-btn:hover { border-color: #888; color: #333; }

/* Collapsed read-only summary (D-03) */
.daf-review-block.collapsed { background: #f7f8fa; padding: 6px 10px; }
.daf-review-summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 11px; }
.daf-review-by { color: #777; }
.daf-review-when { color: #aaa; font-size: 10px; }
.daf-review-edit-btn { margin-left: auto; padding: 2px 8px; background: #fff; color: #555; border: 1px solid #c8cdd5; border-radius: 3px; font-size: 10px; cursor: pointer; font-family: inherit; }
.daf-review-edit-btn:hover { border-color: #888; }

/* ── Global DAF Comment section ─────────────────────────────────────── */
.daf-global-comment {
    margin: 12px 0 8px;
    padding: 10px 12px;
    border: 1px solid #dde1e7;
    border-radius: 4px;
    background: #fafafa;
}
.daf-global-comment-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}
.daf-global-comment-txt {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    border: 1px solid #c8cdd5;
    border-radius: 3px;
    padding: 6px 8px;
    font-size: 12px;
    font-family: inherit;
    color: #333;
    background: #fff;
    outline: none;
    min-height: 54px;
}
.daf-global-comment-txt:focus { border-color: #1a73e8; }
.daf-global-comment-txt::placeholder { color: #c0c4cc; }
.daf-global-comment-txt[readonly] {
    background: #f7f8fa;
    color: #888;
    cursor: default;
}
.daf-global-comment-meta {
    font-size: 11px;
    color: #888;
    margin: 4px 0;
    min-height: 1em;
}
.daf-global-comment-save {
    margin-top: 6px;
    padding: 5px 18px;
    background: #1a73e8;
    color: #fff;
    border: none;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}
.daf-global-comment-save:hover { background: #1558b0; }
.daf-global-comment-save:disabled { background: #a0b4d4; cursor: not-allowed; }

/* ── History modal (Phase 6) ─────────────────────────────────────── */

/* Full-viewport overlay */
.daf-history-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
}

/* Modal box */
.daf-history-modal {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.22);
    width: 780px;
    max-width: 96vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Modal header */
.daf-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #e8e8e8;
    background: #f7f8fa;
    flex-shrink: 0;
}
.daf-history-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #222;
}

/* Close button */
.daf-history-close {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: #888;
    padding: 2px 6px;
    border-radius: 3px;
}
.daf-history-close:hover { background: #eee; color: #333; }

/* Scrollable body */
.daf-history-body {
    overflow-y: auto;
    padding: 16px 18px;
    flex: 1;
}

/* Loading/error state */
.daf-history-loading {
    color: #999;
    font-size: 13px;
    padding: 20px 0;
    text-align: center;
}

/* One card per submission version */
.daf-hist-version-card {
    border: 1px solid #e0e2e6;
    border-radius: 5px;
    margin-bottom: 16px;
    overflow: hidden;
}

/* Version card header */
.daf-hist-version-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f2f4f7;
    border-bottom: 1px solid #e0e2e6;
    font-size: 13px;
}
.daf-hist-version-badge {
    font-weight: 700;
    color: #3a5fa0;
    font-size: 13px;
    min-width: 60px;
}
.daf-hist-meta {
    color: #555;
    flex: 1;
}

/* Answers and reviews sections within a version card */
.daf-hist-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    margin: 10px 14px 4px;
}

/* Answer rows */
.daf-hist-answer-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 4px 14px;
    font-size: 12px;
    border-top: 1px solid #f0f0f0;
}
.daf-hist-answer-row:first-child { border-top: none; }
.daf-hist-qcode {
    font-weight: 600;
    color: #3a5fa0;
    min-width: 52px;
    flex-shrink: 0;
}
.daf-hist-qlabel { color: #444; flex: 1; }
.daf-hist-avalue {
    font-weight: 600;
    color: #1a1a1a;
    min-width: 36px;
    text-align: right;
    flex-shrink: 0;
}
.daf-hist-detail {
    font-size: 11px;
    color: #666;
    margin: 0 14px 4px 74px;
    font-style: italic;
}

/* Review rows */
.daf-hist-review-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 4px 14px;
    font-size: 12px;
    border-top: 1px solid #f0f0f0;
}
.daf-hist-rev-qcode {
    font-weight: 600;
    color: #3a5fa0;
    min-width: 52px;
    flex-shrink: 0;
}
.daf-hist-rev-by { color: #444; flex: 1; }
.daf-hist-rev-date { color: #888; font-size: 11px; flex-shrink: 0; }
.daf-hist-rev-comment {
    font-size: 11px;
    color: #666;
    margin: 0 14px 4px 74px;
    font-style: italic;
}

/* "View History" button — secondary style matching daf-btn-secondary */
.daf-btn-history {
    background: #fff;
    border: 1px solid #c8ccd4;
    color: #3a5fa0;
    padding: 5px 14px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    margin-left: 8px;
}
.daf-btn-history:hover {
    background: #f0f4fb;
    border-color: #3a5fa0;
}

/* ── Revise & Resubmit review annotations (read-only, shown while editing) ── */
.daf-revise-annotation {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 10px;
    margin-top: 4px;
    border-radius: 3px;
    font-size: 11px;
    border: 1px solid transparent;
}
.daf-revise-annotation.rejected {
    background: #fff5f5;
    border-color: #fca5a5;
    color: #991b1b;
}
.daf-revise-annotation.approved {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
    opacity: 0.75;
}
.daf-revise-annotation-label {
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}
.daf-revise-annotation-comment {
    font-style: italic;
    color: inherit;
    opacity: 0.85;
}
