/* Surveys module (#117): list, responses sheet, set-up, dialogs.
   Every class is "sv-"-prefixed: propshaft loads every stylesheet on every page. */

.sv-page { max-width: 1180px; margin: 0 auto; padding: 0 16px 64px; color: #1f2937; }
.sv-page--narrow { max-width: 820px; }
.sv-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 18px 0 14px; flex-wrap: wrap; }
.sv-head h1 { margin: 0; font-size: 1.6em; }
.sv-eyebrow { color: #64748b; font-size: 0.86em; margin: 0 0 2px; }
.sv-back { color: #475569; text-decoration: none; font-size: 0.9em; }
.sv-back:hover { text-decoration: underline; }

.sv-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 6px; border: 1px solid #cbd5e1;
          background: #fff; color: #1e293b; font-weight: 600; font-size: 0.9em; text-decoration: none; cursor: pointer; line-height: 1.3; font-family: inherit; }
.sv-btn:hover { background: #f8fafc; }
.sv-btn-primary { background: #1e3a8a; border-color: #1e3a8a; color: #fff; }
.sv-btn-primary:hover { background: #1e40af; }
.sv-btn-danger { color: #b91c1c; border-color: #fecaca; }
.sv-btn-sm { padding: 4px 9px; font-size: 0.82em; }
.sv-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.sv-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sv-actions form { margin: 0; }

.sv-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 0 0 16px; }
.sv-stat { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px 14px; }
.sv-stat-label { color: #64748b; font-size: 0.82em; }
.sv-stat-value { font-size: 1.5em; font-weight: 700; color: #0f172a; font-variant-numeric: tabular-nums; }
.sv-stat-sub { color: #64748b; font-size: 0.8em; }

.sv-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 10px; }
.sv-seg { display: inline-flex; border: 1px solid #cbd5e1; border-radius: 999px; overflow: hidden; }
.sv-seg a, .sv-seg button { padding: 5px 12px; font-size: 0.86em; color: #1e293b; text-decoration: none; background: #fff; border: 0;
                            font-family: inherit; cursor: pointer; }
.sv-seg a + a, .sv-seg button + button { border-left: 1px solid #e2e8f0; }
.sv-seg .is-on { background: #0f172a; color: #fff; }
.sv-count { opacity: 0.7; margin-left: 4px; font-variant-numeric: tabular-nums; }
.sv-search { padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 6px; min-width: 200px; font: inherit; font-size: 0.9em; }
.sv-spacer { flex: 1; }

.sv-tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75em; font-weight: 600; white-space: nowrap; }
.sv-tag-live { background: #dbeafe; color: #1e40af; }
.sv-tag-done { background: #e2e8f0; color: #334155; }
.sv-tag-draft { background: #fff; color: #92400e; border: 1px solid #fcd34d; }
.sv-tag-replied { background: #e2e8f0; color: #334155; }
.sv-tag-not { background: #fee2e2; color: #991b1b; }
.sv-tag-src-q { background: #dbeafe; color: #1e40af; }
.sv-tag-src-note { background: #fff; border: 1px solid #cbd5e1; color: #334155; }
.sv-tag-src-info { background: #f1f5f9; color: #334155; }

/* Surveys list */
.sv-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; }
.sv-table th { text-align: left; font-size: 0.8em; color: #64748b; font-weight: 600; padding: 9px 12px; background: #f8fafc; border-bottom: 1px solid #e5e7eb; }
.sv-table td { padding: 12px; border-bottom: 1px solid #f1f5f9; vertical-align: top; font-size: 0.92em; }
.sv-table tr:last-child td { border-bottom: 0; }
.sv-name { font-weight: 600; color: #0f172a; text-decoration: none; }
.sv-name:hover { text-decoration: underline; }
.sv-sub { color: #64748b; font-size: 0.85em; margin-top: 2px; }
.sv-urgent { color: #b91c1c; font-weight: 600; }
.sv-bar { height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-top: 5px; width: 140px; }
.sv-bar > span { display: block; height: 100%; background: #1e3a8a; }
.sv-bar.is-done > span { background: #334155; }
.sv-num { font-variant-numeric: tabular-nums; }
.sv-empty { padding: 28px; text-align: center; color: #64748b; background: #fff; border: 1px dashed #cbd5e1; border-radius: 10px; }

/* Detail tabs */
.sv-tabs { display: flex; gap: 18px; border-bottom: 1px solid #e5e7eb; margin: 0 0 14px; }
.sv-tabs a { padding: 8px 2px; text-decoration: none; color: #475569; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sv-tabs a.is-on { color: #0f172a; border-bottom-color: #1e3a8a; }

/* Responses sheet */
.sv-live { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85em; color: #475569; }
.sv-live-dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.sv-live-dot.is-on { background: #16a34a; box-shadow: 0 0 0 3px #dcfce7; }
.sv-sheet-wrap { overflow: auto; max-height: 70vh; border: 1px solid #e5e7eb; border-radius: 10px; background: #fff; }
.sv-sheet { border-collapse: separate; border-spacing: 0; font-size: 0.86em; min-width: 100%; }
.sv-sheet th, .sv-sheet td { padding: 7px 10px; border-bottom: 1px solid #f1f5f9; border-right: 1px solid #f1f5f9; white-space: nowrap;
                             background: #fff; text-align: left; }
.sv-sheet th { position: sticky; top: 0; z-index: 3; background: #f8fafc; color: #334155; font-weight: 600; }
.sv-sheet th a { color: inherit; text-decoration: none; }
.sv-sheet th a:hover { text-decoration: underline; }
/* Exactly 44px wide: the frozen name column sticks at left: 44px, so a
   narrower number column would let it slide over the next column. */
.sv-sheet td.sv-rownum, .sv-sheet th.sv-rownum { color: #94a3b8; width: 44px; min-width: 44px; max-width: 44px;
                                                 box-sizing: border-box; text-align: right; background: #f8fafc; }
.sv-sheet.is-frozen .sv-freeze-0 { position: sticky; left: 0; z-index: 2; }
.sv-sheet.is-frozen .sv-freeze-1 { position: sticky; left: 44px; z-index: 2; box-shadow: 1px 0 0 #e2e8f0; }
.sv-sheet.is-frozen th.sv-freeze-0, .sv-sheet.is-frozen th.sv-freeze-1 { z-index: 4; }
.sv-sheet td.is-wide { white-space: normal; min-width: 220px; max-width: 360px; }
.sv-sheet td.is-name { font-weight: 600; }
.sv-sheet tr.is-not td:not(.sv-rownum) { color: #64748b; }
.sv-sheet tr.is-new td { background: #eff6ff; }
/* After .is-new and as specific, so a fresh reply's low score still shows red. */
.sv-sheet tr td.is-low { background: #fee2e2; color: #991b1b; font-weight: 700; }
.sv-sheet tr.sv-group td { background: #f1f5f9; font-weight: 600; color: #334155; }
.sv-sheet td.sv-note { cursor: pointer; color: #64748b; max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.sv-sheet td.sv-note.has-notes { color: #1e293b; }
.sv-sheet td.sv-note a { color: inherit; text-decoration: none; display: block; }
.sv-note-count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: #1e3a8a; color: #fff;
                 font-size: 0.78em; text-align: center; margin-right: 6px; }
.sv-footer { color: #64748b; font-size: 0.82em; margin-top: 8px; }

/* Setup */
.sv-panel { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.sv-panel h2 { font-size: 1.05em; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.sv-setup-row { display: grid; grid-template-columns: 64px 40px minmax(200px, 1fr) 150px 120px; gap: 10px; align-items: center;
                padding: 7px 0; border-bottom: 1px solid #f1f5f9; }
.sv-setup-row:last-child { border-bottom: 0; }
.sv-setup-row.is-hidden .sv-setup-label input { color: #94a3b8; }
.sv-setup-row input[type="text"] { width: 100%; box-sizing: border-box; padding: 5px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; font-size: 0.9em; }
.sv-setup-note { color: #64748b; font-size: 0.78em; margin-top: 2px; }
.sv-iconbtn { border: 1px solid #cbd5e1; background: #fff; border-radius: 5px; width: 26px; height: 26px; cursor: pointer; font-size: 0.8em; padding: 0; }
.sv-iconbtn[disabled] { opacity: 0.35; cursor: default; }
.sv-toggle { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; }
.sv-toggle button { margin-top: 2px; }
.sv-check { width: 18px; height: 18px; border: 2px solid #0f172a; border-radius: 4px; background: #fff; display: inline-flex; align-items: center;
            justify-content: center; color: #fff; font-size: 12px; padding: 0; cursor: pointer; }
.sv-check.is-on { background: #1e3a8a; border-color: #1e3a8a; }
.sv-field { margin-bottom: 14px; }
.sv-field label, .sv-label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 0.92em; }
.sv-field input[type="text"], .sv-field input[type="date"], .sv-field select, .sv-field textarea {
  width: 100%; box-sizing: border-box; padding: 8px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; }
.sv-hint { color: #64748b; font-size: 0.82em; margin-top: 3px; }
.sv-years { display: flex; flex-wrap: wrap; gap: 6px; }
.sv-years label { display: inline-flex; gap: 5px; align-items: center; padding: 4px 9px; border: 1px solid #cbd5e1; border-radius: 999px;
                  font-weight: 500; font-size: 0.88em; cursor: pointer; }
.sv-errors { padding: 10px 14px; background: #fee2e2; border: 1px solid #fecaca; color: #991b1b; border-radius: 6px; margin-bottom: 14px; }

/* Question builder */
.sv-q { border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.sv-q-top { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.sv-q-num { font-weight: 700; color: #64748b; min-width: 22px; }
.sv-q-grid { display: grid; grid-template-columns: 1fr 200px; gap: 10px; }
.sv-q textarea, .sv-q input[type="text"], .sv-q select { width: 100%; box-sizing: border-box; padding: 7px 8px; border: 1px solid #cbd5e1;
                                                         border-radius: 6px; font: inherit; font-size: 0.92em; }
.sv-q-options { margin-top: 8px; }
.sv-q.is-removed { display: none; }

/* Dialogs */
.sv-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 1000; display: flex; align-items: flex-start;
            justify-content: center; padding: 40px 12px; overflow-y: auto; }
.sv-dialog { background: #fff; border-radius: 12px; width: 100%; max-width: 760px; box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25); }
.sv-dialog-head { padding: 16px 20px; border-bottom: 1px solid #e5e7eb; display: flex; justify-content: space-between; gap: 12px; }
.sv-dialog-head h2 { margin: 0; font-size: 1.15em; }
.sv-dialog-body { padding: 16px 20px; }
.sv-dialog-foot { padding: 12px 20px; border-top: 1px solid #e5e7eb; display: flex; align-items: center; gap: 10px; }
.sv-close { border: 0; background: transparent; font-size: 1.4em; line-height: 1; cursor: pointer; color: #64748b; text-decoration: none; }
.sv-channels { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; margin-bottom: 14px; }
.sv-channel { display: flex; gap: 10px; align-items: flex-start; border: 1px solid #cbd5e1; border-radius: 8px; padding: 10px; cursor: pointer; }
.sv-channel:has(input:checked) { border-color: #1e3a8a; background: #eff6ff; }
.sv-channel input { margin-top: 3px; }
.sv-channel-count { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.sv-channel.is-empty { opacity: 0.55; }
.sv-insert { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 6px 0 12px; font-size: 0.85em; color: #64748b; }
.sv-insert button { font-family: ui-monospace, monospace; font-size: 0.95em; }
.sv-preview { border: 1px solid #e5e7eb; border-radius: 8px; background: #f8fafc; padding: 12px 14px; white-space: pre-wrap; font-size: 0.9em; }
.sv-preview-meta { color: #64748b; font-size: 0.82em; margin-bottom: 6px; white-space: normal; }
.sv-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: #fff; z-index: 1000;
             box-shadow: -10px 0 30px rgba(15, 23, 42, 0.2); display: flex; flex-direction: column; }
.sv-drawer-body { padding: 14px 18px; overflow-y: auto; flex: 1; }
.sv-comment { padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
.sv-comment-meta { font-size: 0.8em; color: #64748b; }
.sv-mention { color: #1e3a8a; font-weight: 600; }
.sv-suggest { border: 1px solid #e5e7eb; border-radius: 6px; margin-top: 4px; background: #fff; }
.sv-suggest button { display: block; width: 100%; text-align: left; padding: 6px 10px; border: 0; background: #fff; cursor: pointer; font: inherit; font-size: 0.9em; }
.sv-suggest button:hover { background: #eff6ff; }
.sv-person { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f1f5f9; }
.sv-person-name { flex: 1; }
.sv-radio-card { display: flex; gap: 10px; border: 1px solid #cbd5e1; border-radius: 8px; padding: 10px; cursor: pointer; margin-bottom: 8px; }
.sv-radio-card:has(input:checked) { border-color: #1e3a8a; background: #eff6ff; }
.sv-toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 9px 16px;
            border-radius: 8px; font-size: 0.9em; z-index: 1100; }

@media (max-width: 720px) {
  .sv-setup-row { grid-template-columns: 56px 34px 1fr; }
  .sv-setup-row > :nth-child(4), .sv-setup-row > :nth-child(5) { display: none; }
  .sv-q-grid { grid-template-columns: 1fr; }
  .sv-table .sv-hide-sm { display: none; }
}
