/*
 * Signet — the two surfaces: a console on a chairside laptop and a form on a
 * patient's phone. The phone half is the one that has to be right: it is held
 * at arm's length by someone who may be nervous, so the type is large, the
 * targets are 44px, and nothing important sits below a fold without a reason.
 */

.sg-console {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: var(--sp-4);
    align-items: start;
}

.sg-patient {
    max-width: 640px;
    margin: 0 auto;
    display: grid;
    gap: var(--sp-4);
}

.sg-card {
    background: var(--surface-1, #fff);
    border: 1px solid var(--border-1, #e2e8f0);
    border-radius: var(--radius-2, 12px);
    padding: var(--sp-4, 16px);
    margin-bottom: var(--sp-4, 16px);
    display: grid;
    gap: var(--sp-3, 12px);
}

.sg-card__title {
    font-weight: 650;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
}

.sg-card h2 { margin: 0; font-size: 1.15rem; }

.sg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-3, 12px);
}

.sg-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2, 8px);
}

.sg-spacer { flex: 1 1 auto; }

.sg-state {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* The wording. This is the thing the receipt pins, so it is set to be read
   rather than skimmed past. */
.sg-wording {
    font-size: 1rem;
    line-height: 1.55;
    max-height: 340px;
    overflow-y: auto;
    padding-right: var(--sp-2, 8px);
}

.sg-wording p { margin: 0 0 var(--sp-3, 12px); }

.sg-tmpl { margin: 0; font-size: 0.85rem; opacity: 0.75; }

/* Questions ---------------------------------------------------------- */

.sg-q {
    border: 1px solid var(--border-1, #e2e8f0);
    border-radius: var(--radius-2, 12px);
    padding: var(--sp-3, 12px);
    margin: 0 0 var(--sp-3, 12px);
    display: grid;
    gap: var(--sp-2, 8px);
}

.sg-q legend { font-weight: 600; padding: 0 var(--sp-2, 8px); }

.sg-q__opt {
    display: flex;
    align-items: center;
    gap: var(--sp-2, 8px);
    min-height: 44px;              /* a fingertip, not a mouse pointer */
    padding: var(--sp-2, 8px);
    border-radius: var(--radius-1, 8px);
    cursor: pointer;
}

.sg-q__opt:hover { background: var(--surface-2, #f1f5f9); }
.sg-q__opt input { width: 20px; height: 20px; }

/* Answers, as the clinician sees them -------------------------------- */

.sg-answers { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2, 8px); }

.sg-answer {
    display: grid;
    gap: 2px;
    padding: var(--sp-2, 8px) var(--sp-3, 12px);
    border-left: 3px solid transparent;
    background: var(--surface-2, #f1f5f9);
    border-radius: var(--radius-1, 8px);
}

.sg-answer b { font-size: 0.85rem; font-weight: 600; }
.sg-answer span { font-size: 0.9rem; }
.sg-answer.is-right { border-left-color: #15803d; }
.sg-answer.is-wrong { border-left-color: #b91c1c; }

/* Signatures --------------------------------------------------------- */

.sg-pad {
    width: 100%;
    height: 140px;
    background: #fff;
    border: 1px dashed var(--border-2, #94a3b8);
    border-radius: var(--radius-2, 12px);
    touch-action: none;             /* a signature must not scroll the page */
}

.sg-sig {
    max-width: 100%;
    background: #fff;
    border: 1px solid var(--border-1, #e2e8f0);
    border-radius: var(--radius-1, 8px);
}

/* The receipt -------------------------------------------------------- */

.sg-receipt {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 4px var(--sp-3, 12px);
    margin: 0;
    font-size: 0.85rem;
}

.sg-receipt dt { opacity: 0.7; }
.sg-receipt dd { margin: 0; font-family: var(--font-mono, ui-monospace, monospace); overflow-wrap: anywhere; }

/* Toast -------------------------------------------------------------- */

.sg-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    max-width: min(520px, calc(100vw - 32px));
    padding: 12px 16px;
    border-radius: var(--radius-2, 12px);
    background: #0f172a;
    color: #f8fafc;
    font-size: 0.9rem;
    z-index: 60;
}

.sg-toast.is-ok { background: #14532d; }
.sg-toast.is-warn { background: #78350f; }
.sg-toast.is-error { background: #7f1d1d; }

@media (max-width: 900px) {
    .sg-console { grid-template-columns: minmax(0, 1fr); }
}

/* The template editor. Each question is a small bordered group so the options
   and the "correct" choice read as belonging to it. */
.sg-tpl { display: grid; gap: var(--sp-3, 12px); }
.sg-tpl textarea { min-width: 0; resize: vertical; font: inherit; }
.sg-tpl__q {
    display: grid;
    gap: var(--sp-2, 8px);
    min-width: 0;
    margin: 0;
    padding: var(--sp-3, 12px);
    border: 1px solid var(--border-1, #e2e8f0);
    border-radius: var(--radius-1, 8px);
}
.sg-tpl__q legend { font-weight: 600; font-size: 0.9rem; padding: 0 var(--sp-1, 4px); }
.sg-tpl__q .btn { justify-self: start; }
.sg-tpl__errors {
    margin: 0;
    padding: var(--sp-2, 8px) var(--sp-2, 8px) var(--sp-2, 8px) var(--sp-5, 24px);
    border-radius: var(--radius-1, 8px);
    background: var(--danger-bg, #fdecec);
    color: var(--danger, #b42318);
}
