/* Styles for ConsentSigningFlow.js (js/modules/consent/ConsentSigningFlow.js).
   Plain Bootstrap-compatible CSS. No third-party branding. */

/* Handwriting face for typed signatures. Self-hosted (SIL Open Font License, see
   fonts/DancingScript-OFL.txt): a HIPAA app should not call a third party at signing time. */
@font-face {
    font-family: "Dancing Script";
    src: url('../fonts/DancingScript-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

/* ---- Sticky progress bar -------------------------------------------- */
.csf-bar {
    position: sticky;
    top: var(--csf-top, 0px);
    z-index: 990; /* below the portal navbar (1000) and Bootstrap modals (1055) */
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    padding: 0.5rem 0.75rem;
    margin-bottom: 1rem;
}
.csf-bar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.csf-progress { font-weight: 600; min-width: 0; }
.csf-action { min-width: 110px; min-height: 44px; flex-shrink: 0; }
.csf-confirm {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0.35rem 0 0;
    padding-left: 0;
    font-size: 0.8125rem;
    line-height: 1.3;
}
.csf-confirm .form-check-input {
    float: none;
    flex-shrink: 0;
    margin: 0.1rem 0 0;
    width: 1.5rem;
    height: 1.5rem;
}
.csf-confirm .form-check-label { min-height: 44px; display: block; padding: 0.55rem 0; }
.csf-hint { font-size: 0.75rem; color: #6c757d; min-height: 0; }
.csf-hint:empty { display: none; }

/* ---- Bottom confirmation card (mirrors the top bar after the last form) -- */
.csf-confirm-bottom {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    background: #fff;
    border: 1px solid #ffe69c;
    border-left: 4px solid #ffc107;
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.csf-confirm-bottom .form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    flex: 1 1 260px;
    margin: 0;
    padding-left: 0;
}
.csf-confirm-bottom .form-check-input {
    float: none;
    flex-shrink: 0;
    margin: 0.1rem 0 0;
    width: 1.5rem;
    height: 1.5rem;
}
.csf-confirm-bottom .form-check-label {
    flex: 1 1 auto;
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0.1rem 0;
}
.csf-finish-bottom { min-width: 110px; min-height: 44px; flex-shrink: 0; }

/* ---- Signature tags inside the form ---------------------------------- */
.signature-field.csf-enhanced > .signature-canvas-container,
.signature-field.csf-enhanced > .signature-actions { display: none; }

.csf-tag {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    max-width: 100%;
    scroll-margin-top: calc(var(--csf-top, 0px) + var(--csf-bar-height, 120px) + 16px);
    scroll-margin-bottom: 24px;
    border-radius: 0.5rem;
}
.csf-tag-main {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 56px;
    min-width: 44px;
    padding: 0.5rem 0.9rem;
    text-align: left;
    color: #5c4300;
    background: #fff3bf;
    border: 2px solid #f0a500;
    border-radius: 0.5rem;
    cursor: pointer;
}
.csf-tag-main:hover { background: #ffec99; }
.csf-tag-main:focus-visible,
.csf-tag-change:focus-visible { outline: 3px solid #0d6efd; outline-offset: 2px; }
.csf-tag-icon { font-size: 1.5rem; }
.csf-tag-text { display: flex; flex-direction: column; line-height: 1.2; }
.csf-tag-title { font-weight: 700; }
.csf-tag-label { font-size: 0.8125rem; }

.csf-tag.csf-signed .csf-tag-main {
    background: #fff;
    border-color: #198754;
    padding: 0.35rem 0.6rem;
    justify-content: center;
}
.csf-stamp { display: block; max-width: 100%; max-height: 90px; height: auto; }
.csf-tag-change {
    flex: 0 0 auto;
    min-height: 44px;
    min-width: 44px;
    padding: 0 0.75rem;
    background: transparent;
    border: 1px solid #6c757d;
    border-radius: 0.5rem;
    color: #495057;
    font-size: 0.875rem;
    align-self: center;
}
.csf-tag-change[hidden] { display: none; }

.csf-tag.csf-pulse .csf-tag-main {
    outline: 4px solid #0d6efd;
    outline-offset: 3px;
    animation: csf-pulse 0.9s ease-in-out 2;
}
@keyframes csf-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.55); }
    50% { box-shadow: 0 0 0 10px rgba(13, 110, 253, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .csf-tag.csf-pulse .csf-tag-main { animation: none; }
}

/* ---- Adopt dialog ----------------------------------------------------- */
.csf-modal .nav-link { min-height: 44px; }
.csf-type-preview {
    margin-top: 0.75rem;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: 1px dashed #adb5bd;
    border-radius: 0.5rem;
    background: #fff;
    color: rgb(0, 0, 139);
    font-family: "Dancing Script", cursive;
    font-weight: 600;
    font-size: 2.5rem;
    line-height: 1.1;
    overflow: hidden;
    word-break: break-word;
    text-align: center;
}
.csf-draw-wrap {
    border: 1px solid #adb5bd;
    border-radius: 0.5rem;
    background: #fff;
    touch-action: none;
    overscroll-behavior-y: contain;
}
/* touch-action:none alone stops the canvas from scrolling the page, but Android
   Chrome's pull-to-refresh is a separate overscroll gesture on the document and
   is not stopped by touch-action on a child element. overscroll-behavior-y is
   what actually disables it, which is why drawing top-to-bottom (an overscroll-
   like downward drag) triggered a page refresh while bottom-to-top did not. */
.csf-draw-canvas { display: block; width: 100%; height: 180px; touch-action: none; overscroll-behavior-y: contain; }

@media (max-width: 575.98px) {
    .csf-bar { padding: 0.4rem 0.6rem; }
    .csf-type-preview { font-size: 2rem; }
}

/* ---- Kiosk / touch additions ------------------------------------------ */
.csf-bar[hidden] { display: none; }
.csf-confirm[hidden] { display: none; }
/* Short viewports (tablet landscape with the on-screen keyboard open): keep the
   dialog at the top so the name input stays visible above the keyboard. */
@media (max-height: 600px) {
    .csf-modal .modal-dialog { align-items: flex-start; margin-top: 0.5rem; }
}

/* ---- Typed text fields ({{TEXT:...}} placeholders) ------------------- */
input.consent-text-field {
    display: inline-block;
    vertical-align: baseline;
    margin: 0 0.25rem;
}
.consent-text-value {
    border-bottom: 1px solid #000;
    padding: 0 0.25rem;
}
