/* ================================================================
   Flujo de firma v2 — Phase 2 del rewrite de openclaimsai_webforms.

   Source of truth (design contract):
     static/src/mockups/signing_flow_v2.html  (owner-approved)

   Estilo alineado con id_verification.css — el cliente venía de
   verificar identidad y no debe percibir cambio de producto.

   Tokens compartidos:
     · Fuente:    DM Sans
     · Primario:  #3B4D8C (navy)
     · Texto:     #1E2235 / #4A4F63 / #6E7590 / #9BA1B5
     · Card bg:   #FAFAFC
     · Borders:   #F1F2F6 / #E4E6ED / #D0D3DE
     · Radius:    8 / 10 / 14-16 px
     · Animación: fade-up + pop  (mismas que idv)

   Class prefix: sg- (signing) — paralelo a idv- (id verification).

   Cargado por: views/webform_signing_document.xml en
   /signing_document/<doc_ids>.

   Para mantener consistencia, NO modificar este CSS sin
   actualizar el mockup primero (CODING_PLAN.md §0).
   ================================================================ */

/* ---------- Animations (mismas que idv) ---------- */
@keyframes sg-pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes sg-fade-up {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes sg-pulse-yellow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, .50); }
    50%      { box-shadow: 0 0 0 14px rgba(245, 158, 11, 0); }
}
@keyframes sg-pulse {
    0%, 100% { opacity: 0.3; }
    50%      { opacity: 0.7; }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1E2235;
    background: #fff;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: inherit; }

/* ============================================================
   Override Odoo's website wrapwrap so the signing UI fills the
   viewport (mismo patrón que idv-page-active en id_verification).
   Activado por JS en boot vía body.sg-page-active.
   ============================================================ */
body.sg-page-active #wrapwrap { overflow: hidden !important; height: 100vh !important; }
/* :not(.sg-sign-header) — our own signing header is a <header> too; without
   the exclusion it was hidden along with Odoo's website header. */
body.sg-page-active header:not(.sg-sign-header),
body.sg-page-active footer,
body.sg-page-active .o_header_standard,
body.sg-page-active .o_footer,
body.sg-page-active nav.navbar { display: none !important; }

/* ============================================================
   Estructura común (igual que idv-page)
   ============================================================ */
.sg-page {
    position: fixed;
    inset: 0;
    background: #fff;
    font-family: 'DM Sans', sans-serif;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}
.sg-page.active { display: flex; }

/* ---------- Language switcher ----------
   Labeled segmented control (English | Español) under the step bars.
   The active option is the signer's res.partner.lang. */
.sg-lang-switcher {
    display: flex;
    justify-content: center;
    padding: 18px 20px 0;
    flex-shrink: 0;
}
.sg-lang-seg {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #F1F2F6;
    border-radius: 999px;
    padding: 3px 3px 3px 12px;
}
.sg-lang-globe {
    color: #9BA1B5;
    margin-right: 6px;
    flex-shrink: 0;
}
.sg-lang-btn {
    background: transparent;
    border: 0;
    color: #6B7089;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    padding: 7px 16px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.sg-lang-btn:hover { color: #1E2235; }
.sg-lang-btn.active {
    background: #3B4D8C;
    color: #fff;
    box-shadow: 0 1px 3px rgba(30, 34, 53, 0.18);
}
.sg-lang-btn:focus-visible {
    outline: 2px solid #3B4D8C;
    outline-offset: 2px;
}

/* ---------- Top nav (back + label) ---------- */
.sg-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 0;
    flex-shrink: 0;
}
.sg-nav-back {
    background: #FAFAFC;
    border: 1px solid #F1F2F6;
    cursor: pointer;
    padding: 7px;
    display: flex;
    align-items: center;
    border-radius: 8px;
    transition: background 0.2s ease;
}
.sg-nav-back:hover { background: #F1F2F6; }
.sg-nav-back svg { color: #4A4F63; }
.sg-nav-label {
    font-size: 11px;
    color: #9BA1B5;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 600;
}

/* ---------- Step bars (3 pasos: Bienvenida · Firmar · Listo) ---------- */
.sg-step-bars {
    display: flex;
    gap: 5px;
    padding: 14px 24px 0;
    flex-shrink: 0;
}
.sg-bar {
    flex: 1;
    height: 3px;
    border-radius: 3px;
    background: #E4E6ED;
    transition: background 0.4s ease;
}
.sg-bar.filled { background: #3B4D8C; }

/* ---------- Pantalla central (igual idv-screen) ---------- */
.sg-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    text-align: center;
    gap: 22px;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

/* Pantallas que usan ancho completo (la del documento) */
.sg-screen-wide {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: hidden;
}

/* Animación de aparición */
.sg-fadein {
    opacity: 0;
    transform: translateY(14px);
    animation: sg-fade-up 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ---------- Brand ---------- */
.sg-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.sg-brand-mark {
    width: 32px; height: 32px;
    background: #3B4D8C;
    color: #fff;
    border-radius: 8px;
    display: grid; place-items: center;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .5px;
}
.sg-brand-name {
    font-size: 14px;
    font-weight: 600;
    color: #1E2235;
}
/* res.company logo — replaces the "OC" mark when the company has one. */
.sg-brand-logo {
    height: 44px;
    width: auto;
    max-width: 220px;
    object-fit: contain;
    border-radius: 6px;
    flex-shrink: 0;
}
/* No logo → the office name in capitals (never OCAI branding). */
.sg-brand-wordmark {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #1E2235;
}

/* ---------- Welcome screen ---------- */
.sg-verified-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(22, 163, 74, .08);
    border: 1px solid rgba(22, 163, 74, .20);
    color: #15803d;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    margin-bottom: 6px;
}
.sg-verified-pill svg { color: #16a34a; }

.sg-shield-icon { margin-bottom: 4px; }
.sg-welcome-title {
    font-size: 24px;
    font-weight: 700;
    color: #1E2235;
    margin: 0;
    line-height: 1.25;
}
.sg-welcome-sub {
    font-size: 14px;
    color: #9BA1B5;
    margin-top: 10px;
    line-height: 1.65;
    max-width: 320px;
}

/* Doc card (qué vas a firmar) */
.sg-doc-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: #FAFAFC;
    border-radius: 14px;
    border: 1.5px solid #F1F2F6;
    width: 100%; max-width: 320px;
    text-align: left;
}
.sg-doc-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    background: rgba(59, 77, 140, 0.06);
    border: 1px solid rgba(59, 77, 140, 0.10);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    color: #3B4D8C;
}
.sg-doc-text { flex: 1; min-width: 0; }
.sg-doc-title {
    font-size: 14px;
    font-weight: 600;
    color: #1E2235;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sg-doc-desc {
    font-size: 12px;
    color: #9BA1B5;
    margin-top: 3px;
}

/* Info card con pasos numerados (mismo patrón idv) */
.sg-info-card {
    display: flex; flex-direction: column; gap: 18px;
    padding: 22px 26px;
    background: #FAFAFC;
    border-radius: 16px;
    border: 1px solid #F1F2F6;
    width: 100%; max-width: 320px;
}
.sg-info-row { display: flex; align-items: center; gap: 14px; }
.sg-info-num {
    width: 30px; height: 30px; border-radius: 8px;
    background: rgba(59,77,140,0.06);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #3B4D8C; flex-shrink: 0;
}
.sg-info-row span { font-size: 13px; color: #6E7590; line-height: 1.4; text-align: left; }

.sg-encrypt {
    display: flex; align-items: center; justify-content: center;
    gap: 5px;
    margin-top: 4px;
}
.sg-encrypt span { font-size: 11px; color: #C8CCD8; }

/* ---------- Buttons (mismo patrón idv) ---------- */
.sg-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; max-width: 320px;
    padding: 14px 28px;
    border-radius: 10px;
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    letter-spacing: 0.01em;
    border: none;
}
.sg-btn-primary {
    background: #3B4D8C; color: #fff;
    box-shadow: 0 2px 8px rgba(59,77,140,0.12);
}
.sg-btn-primary:hover {
    background: #2E3F75;
    box-shadow: 0 6px 20px rgba(59,77,140,0.25);
    transform: translateY(-1px);
}
.sg-btn-primary:disabled { opacity: 0.45; cursor: default; transform: none; box-shadow: none; }

.sg-btn-outline {
    background: #fff; color: #4A4F63;
    border: 1px solid #E4E6ED;
}
.sg-btn-outline:hover { background: #FAFAFC; }

.sg-btn-ghost {
    background: transparent; color: #9BA1B5;
    border: none;
}
.sg-btn-ghost:hover { color: #4A4F63; }

/* ============================================================
   Pantalla 2 — Firma del documento
   Layout ancho (no centrada como las otras), porque el PDF
   necesita espacio. Mantenemos misma paleta y micro-detalles.
   ============================================================ */
.sg-sign-shell {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #FAFAFC;
}
.sg-sign-header {
    background: #fff;
    padding: 10px 16px;
    border-bottom: 1px solid #F1F2F6;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    box-shadow: 0 1px 0 rgba(30, 34, 53, 0.04);
}
.sg-sign-header-left {
    display: flex; align-items: center; gap: 12px;
    flex: 1; min-width: 0;
}
.sg-sign-header-right {
    display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
}
.sg-sign-brand-mark {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #3B4D8C 0%, #5E6FB3 100%);
    color: #fff;
    display: grid; place-items: center;
    font-family: 'DM Sans', sans-serif;
    font-weight: 800; font-size: 12px;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}
.sg-sign-brand-logo {
    height: 32px;
    width: auto;
    max-width: 96px;
    object-fit: contain;
    border-radius: 6px;
    flex-shrink: 0;
}
.sg-sign-brand-wordmark {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #1E2235;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Progress badge: big numeric "X / Y firmas" — replaces the tiny uppercase
   "X DE Y FIRMADAS" subtitle that customers were missing. */
.sg-progress-badge {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    padding: 8px 14px;
    border-radius: 999px;
    background: #FEF3C7;
    border: 1.5px solid #F59E0B;
    font-family: 'DM Sans', sans-serif;
    color: #92400E;
    transition: all 0.25s ease;
}
.sg-progress-badge[data-state="signing"] {
    background: #FEF3C7;
    border-color: #F59E0B;
    color: #92400E;
}
.sg-progress-badge[data-state="done"] {
    background: #DCFCE7;
    border-color: #16A34A;
    color: #14532D;
}
.sg-progress-badge .sg-progress-badge-num {
    font-size: 17px; font-weight: 800;
    line-height: 1;
}
.sg-progress-badge .sg-progress-badge-sep,
.sg-progress-badge .sg-progress-badge-tot {
    font-size: 14px; font-weight: 600;
    opacity: 0.7;
}
.sg-progress-badge .sg-progress-badge-lbl {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-left: 5px;
}

/* Signer chip: "Firmando como [Name]" — Docusign-style identity confirmation */
.sg-signer-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 8px;
    background: #FAFAFC;
    border: 1px solid #F1F2F6;
    border-radius: 999px;
    font-family: 'DM Sans', sans-serif;
}
.sg-signer-chip .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #16A34A;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18);
}
.sg-signer-chip .signer-as {
    font-size: 10px;
    color: #9BA1B5;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    line-height: 1.1;
}
.sg-signer-chip .signer-name {
    font-size: 13px;
    color: #1E2235;
    font-weight: 700;
    line-height: 1.1;
}

/* Guidance banner — Docusign-style persistent instruction strip beneath
   the header.  Changes copy + color based on state (empty / signing / done). */
.sg-guidance-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    background: linear-gradient(180deg, #FEF3C7 0%, #FDE68A 100%);
    border-bottom: 1px solid #F59E0B;
    color: #78350F;
    flex-shrink: 0;
    transition: all 0.3s ease;
}
.sg-guidance-banner[data-state="signing"] {
    background: linear-gradient(180deg, #DBEAFE 0%, #BFDBFE 100%);
    border-bottom-color: #3B82F6;
    color: #1E3A8A;
}
.sg-guidance-banner[data-state="done"] {
    background: linear-gradient(180deg, #DCFCE7 0%, #BBF7D0 100%);
    border-bottom-color: #16A34A;
    color: #14532D;
}
.sg-guidance-banner[data-state="hidden"] {
    display: none;
}
.sg-guidance-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: rgba(255,255,255,0.6);
    display: grid; place-items: center;
    flex-shrink: 0;
}
.sg-guidance-body { flex: 1; min-width: 0; }
.sg-guidance-title {
    font-size: 14px; font-weight: 700;
    line-height: 1.2;
}
.sg-guidance-sub {
    font-size: 12px;
    margin-top: 2px;
    line-height: 1.4;
    opacity: 0.85;
}
.sg-guidance-action {
    flex-shrink: 0;
    /* also .sg-btn — undo its width:100% so the banner text keeps its room */
    width: auto;
    max-width: none;
    background: #1E2235;
    color: #fff;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex; align-items: center; gap: 6px;
    border: none; cursor: pointer;
    box-shadow: 0 2px 8px rgba(30, 34, 53, 0.25);
    transition: transform 0.15s ease;
}
.sg-guidance-action:hover { transform: translateY(-1px); }
.sg-guidance-action:active { transform: translateY(0); }

@media (max-width: 640px) {
    .sg-sign-header { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
    .sg-sign-header-right { gap: 6px; }
    .sg-progress-badge { padding: 6px 10px; }
    .sg-progress-badge .sg-progress-badge-lbl { display: none; }
    .sg-signer-chip { padding: 4px 8px 4px 6px; }
    .sg-signer-chip .signer-as { display: none; }
    .sg-sign-brand-logo { height: 26px; max-width: 72px; }
    .sg-guidance-banner { padding: 10px 12px; gap: 8px; }
    .sg-guidance-icon { width: 30px; height: 30px; }
    .sg-guidance-title { font-size: 13px; }
    .sg-guidance-sub { font-size: 11px; }
    .sg-guidance-action { padding: 8px 12px; font-size: 12px; }
}
.sg-sign-header .sg-icon-btn {
    width: 36px; height: 36px;
    background: #FAFAFC;
    border: 1px solid #F1F2F6;
    border-radius: 8px;
    display: grid; place-items: center;
    color: #4A4F63;
}
.sg-sign-header .sg-icon-btn:hover { background: #F1F2F6; }
.sg-sign-doc { flex: 1; min-width: 0; }
.sg-sign-doc .name {
    font-size: 14px;
    font-weight: 600;
    color: #1E2235;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sg-sign-doc .meta {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
    color: #9BA1B5;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.sg-sign-progress {
    height: 3px;
    background: #E4E6ED;
    flex-shrink: 0;
}
.sg-sign-progress .fill {
    height: 100%;
    background: #3B4D8C;
    width: 33%;
    transition: width 0.4s ease;
}

.sg-doc-viewport {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 22px 14px 110px;
    -webkit-overflow-scrolling: touch;
}

.sg-pdf-page {
    position: relative;
    max-width: 720px;
    margin: 0 auto 18px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(30, 34, 53, .08), 0 1px 3px rgba(30, 34, 53, .04);
    overflow: hidden;
}
.sg-pdf-mock {
    padding: 50px 56px;
    font-family: 'Times New Roman', serif;
    font-size: 14px;
    color: #111;
    line-height: 1.6;
    min-height: 720px;
}
.sg-pdf-mock h2 { text-align: center; margin: 0 0 12px; font-size: 22px; }
.sg-pdf-mock .sub { text-align: center; color: #666; font-size: 12px; margin-bottom: 24px; }
.sg-pdf-mock p { margin: 0 0 14px; }
.sg-pdf-mock .ph {
    display: inline-block;
    height: 11px;
    background: #e5e7eb;
    border-radius: 3px;
    vertical-align: middle;
    margin: 0 2px;
}

/* Campos de firma en el PDF */
.sg-field {
    position: absolute;
    border: 2px dashed #3B4D8C;
    background: rgba(59, 77, 140, .08);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: #3B4D8C;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
    user-select: none;
}
.sg-field:hover { background: rgba(59, 77, 140, .14); }
.sg-field:active { transform: scale(.98); }
.sg-field.signed {
    border-style: solid;
    background: rgba(22, 163, 74, .07);
    border-color: #16a34a;
    color: #15803d;
}
.sg-field.next {
    background: rgba(245, 158, 11, .14);
    border-color: #f59e0b;
    color: #b45309;
    animation: sg-pulse-yellow 1.6s ease-in-out infinite;
}
.sg-field.required::after {
    content: '*';
    position: absolute;
    top: 2px; right: 8px;
    color: #dc2626;
    font-size: 14px;
    font-weight: 700;
}
.sg-field-badge {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 22px; height: 22px;
    border-radius: 999px;
    background: #3B4D8C;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: grid; place-items: center;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(30, 34, 53, .20);
}
.sg-field.signed .sg-field-badge { background: #16a34a; }
.sg-field.next .sg-field-badge { background: #f59e0b; }

.sg-coach {
    position: absolute;
    background: #1E2235;
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    z-index: 5;
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 6px 16px rgba(30, 34, 53, .25);
}
.sg-coach::after {
    content: '';
    position: absolute;
    bottom: -6px; left: 14px;
    border: 6px solid transparent;
    border-top-color: #1E2235;
    border-bottom: 0;
}
/* "Above the field" variant — arrow points down toward the field */
.sg-coach.above::after {
    bottom: auto;
    top: -6px;
    border: 6px solid transparent;
    border-bottom-color: #1E2235;
    border-top: 0;
}

/* Field overlay safeguards (mobile audit 2026-05-14):
   · enforce a tap-friendly minimum so small "initial" rects are tappable
   · prevent text overflow that breaks the layout on narrow phones */
.sg-field {
    min-width: 44px;
    min-height: 44px;
    padding: 4px 6px;
    text-align: center;
    line-height: 1.15;
    /* Slightly bigger amber halo so the .next field reads as the next
       action even at small sizes (initials, dates). */
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0);
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.sg-field.next {
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18);
}
.sg-field > span:last-child {
    font-size: 11px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Pre-filled text overlays — Docusign-style read-only data preview.
   Visually low-key so the customer reads it as "info" not "tap to interact".
   The actual text gets stamped into the PDF at sealing time; this is just
   a preview so the customer sees a fully-populated document before signing.

   Wraps to multiple lines (matches the PDF stamper's auto-fit behaviour
   instead of cutting with ellipsis on a single line). */
.sg-prefill {
    position: absolute;
    background: rgba(59, 77, 140, 0.04);
    border-bottom: 1px solid rgba(59, 77, 140, 0.18);
    color: #1E2235;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    padding: 1px 4px;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    pointer-events: none;          /* never blocks signature clicks */
    user-select: none;
    border-radius: 2px;
    line-height: 1.15;
}
/* Customer-editable text input — clientText rects.  Visually clear that
   it's INTERACTIVE (not just data shown to read).  Amber border + light
   amber background mirrors the .sg-field "tap to sign" affordance. */
.sg-client-input {
    position: absolute;
    box-sizing: border-box;
    background: rgba(245, 158, 11, 0.10);
    border: 1.5px dashed #F59E0B;
    border-radius: 6px;
    padding: 2px 6px;
    color: #1E2235;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    outline: none;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}
.sg-client-input::placeholder {
    color: #B45309;
    font-style: italic;
    font-weight: 400;
    opacity: 0.7;
}
.sg-client-input:hover { background: rgba(245, 158, 11, 0.16); }
.sg-client-input.focused {
    background: #fff;
    border-style: solid;
    border-color: #3B4D8C;
    box-shadow: 0 0 0 3px rgba(59, 77, 140, 0.16);
}
.sg-client-input.filled {
    background: rgba(22, 163, 74, 0.06);
    border-style: solid;
    border-color: #16A34A;
    color: #14532D;
}
.sg-client-input.required:not(.filled)::after {
    /* Pseudo-element on <input> doesn't render in most browsers, so the
       required state is reflected via the amber border + .flash effect
       below.  This rule kept as no-op for future-proofing. */
}
.sg-client-input.flash {
    animation: sg-input-flash 0.6s ease-out 0s 2;
}
@keyframes sg-input-flash {
    0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6); }
    50%  { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0.0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.0); }
}

/* Customer-checkable box — clientCheck rects.  Square button that toggles
   a check mark.  Bigger than the rect's raw size so it's tappable on mobile. */
.sg-client-check {
    position: absolute;
    box-sizing: border-box;
    background: rgba(245, 158, 11, 0.10);
    border: 1.5px dashed #F59E0B;
    border-radius: 4px;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 0.15s ease, border-color 0.15s ease;
    user-select: none;
}
.sg-client-check input[type="checkbox"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.sg-client-check .sg-cc-mark {
    color: transparent;
    transition: color 0.15s ease;
}
.sg-client-check.checked {
    background: rgba(22, 163, 74, 0.10);
    border-style: solid;
    border-color: #16A34A;
}
.sg-client-check.checked .sg-cc-mark { color: #15803D; }
.sg-client-check:hover { background: rgba(245, 158, 11, 0.20); }
.sg-client-check.flash {
    animation: sg-input-flash 0.6s ease-out 0s 2;
}

/* Customer-selectable radio — clientRadio / clientRadioGroup rects.
   Radios with the same group_name are mutually exclusive (the native
   <input type="radio"> name attribute handles that for us). */
.sg-client-radio {
    position: absolute;
    box-sizing: border-box;
    background: rgba(245, 158, 11, 0.10);
    border: 1.5px dashed #F59E0B;
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 0.15s ease, border-color 0.15s ease;
    user-select: none;
}
.sg-client-radio input[type="radio"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.sg-client-radio .sg-rd-dot {
    width: 55%; height: 55%;
    border-radius: 50%;
    background: transparent;
    transition: background 0.15s ease;
}
.sg-client-radio.checked {
    background: rgba(22, 163, 74, 0.10);
    border-style: solid;
    border-color: #16A34A;
}
.sg-client-radio.checked .sg-rd-dot { background: #15803D; }
.sg-client-radio:hover { background: rgba(245, 158, 11, 0.20); }
.sg-client-radio.flash {
    animation: sg-input-flash 0.6s ease-out 0s 2;
}

/* Envelope ID badge — same look as the badge the PDF stamper draws on
   the final signed PDF, mirrored on the live signing view so the customer
   can quote the ID in support emails. */
.sg-envelope-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #fff;
    border: 1px solid #333;
    color: #666;
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 2px;
    z-index: 6;
    pointer-events: none;
    white-space: nowrap;
}

/* Auto-check overlay (Prior Claim Yes/No) — read-only green check */
.sg-prefill.sg-autocheck {
    display: grid;
    place-items: center;
    background: rgba(22, 163, 74, 0.06);
    border-bottom: none;
    border: 1.5px solid #16A34A;
    border-radius: 4px;
    color: #15803D;
    padding: 0;
}

/* PDF page loading overlay */
.sg-doc-loading {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 50;
    font-family: 'DM Sans', sans-serif;
}
.sg-doc-loading-spinner {
    width: 42px; height: 42px;
    border: 3px solid #E4E6ED;
    border-top-color: #3B4D8C;
    border-radius: 50%;
    animation: sg-spin 0.9s linear infinite;
}
.sg-doc-loading-text {
    font-size: 13px;
    color: #4A4F63;
    text-align: center;
}
.sg-doc-loading-text strong {
    display: block;
    color: #1E2235;
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 2px;
}
@keyframes sg-spin { to { transform: rotate(360deg); } }

/* Bottom action bar (sticky en móvil + desktop) */
.sg-sign-bottom {
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, #fff 70%, rgba(255, 255, 255, 0));
    padding: 14px 14px calc(env(safe-area-inset-bottom, 0px) + 14px);
    z-index: 20;
}
.sg-sign-bottom-inner {
    max-width: 720px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #F1F2F6;
    border-radius: 14px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 24px rgba(30, 34, 53, .06), 0 2px 4px rgba(30, 34, 53, .04);
}
.sg-sign-bottom .step-text {
    flex: 1;
    font-size: 13px;
    color: #4A4F63;
}
.sg-sign-bottom .step-text strong { color: #1E2235; font-weight: 700; }
.sg-sign-bottom .sg-btn { width: auto; max-width: none; padding: 10px 16px; }

/* Floating zoom controls */
.sg-zoom-fab {
    position: fixed;
    right: 16px;
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border: 1px solid #F1F2F6;
    border-radius: 999px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 8px 24px rgba(30, 34, 53, .08);
    z-index: 15;
}
.sg-zoom-fab button {
    width: 36px; height: 36px;
    border: none;
    background: transparent;
    border-radius: 999px;
    display: grid; place-items: center;
    color: #4A4F63;
}
.sg-zoom-fab button:hover { background: #F1F2F6; color: #1E2235; }

/* ============================================================
   Pantalla 3 — Modal Adoptar firma
   ============================================================ */
.sg-modal-back {
    position: fixed;
    inset: 0;
    background: rgba(30, 34, 53, .55);
    backdrop-filter: blur(6px);
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    animation: sg-fade-up .25s ease;
}
@media (min-width: 640px) {
    .sg-modal-back { align-items: center; padding: 24px; }
}

.sg-adopt-modal {
    background: #fff;
    width: 100%;
    max-width: 520px;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -16px 48px rgba(30, 34, 53, .25);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    animation: sg-pop .35s cubic-bezier(0.22, 1, 0.36, 1);
}
@media (min-width: 640px) {
    .sg-adopt-modal { border-radius: 16px; max-height: 85vh; }
}

.sg-adopt-handle {
    align-self: center;
    width: 40px; height: 5px;
    border-radius: 3px;
    background: #E4E6ED;
    margin: 8px 0 4px;
}
@media (min-width: 640px) { .sg-adopt-handle { display: none; } }

.sg-adopt-header {
    padding: 14px 22px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #F1F2F6;
}
.sg-adopt-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: #1E2235;
    margin: 0;
    flex: 1;
}
.sg-adopt-header .sg-icon-btn {
    width: 36px; height: 36px;
    background: #FAFAFC;
    border: 1px solid #F1F2F6;
    border-radius: 8px;
    display: grid; place-items: center;
    color: #4A4F63;
}
.sg-adopt-header .sg-icon-btn:hover { background: #F1F2F6; }

.sg-adopt-tabs {
    display: flex;
    gap: 4px;
    padding: 6px;
    background: #FAFAFC;
    margin: 14px 22px 0;
    border-radius: 10px;
    border: 1px solid #F1F2F6;
}
.sg-adopt-tabs button {
    flex: 1;
    height: 38px;
    border: none;
    background: transparent;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    color: #9BA1B5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}
.sg-adopt-tabs button.active {
    background: #fff;
    color: #1E2235;
    box-shadow: 0 1px 3px rgba(30, 34, 53, .08);
}
.sg-adopt-tabs button svg { width: 14px; height: 14px; }

.sg-adopt-body {
    flex: 1;
    padding: 18px 22px 0;
    overflow-y: auto;
}

.sg-draw-canvas {
    position: relative;
    background: #FAFAFC;
    border: 1.5px dashed #D0D3DE;
    border-radius: 12px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.sg-draw-canvas .baseline {
    position: absolute;
    left: 12%; right: 12%;
    bottom: 30%;
    height: 1px;
    background: #D0D3DE;
}
.sg-draw-canvas .hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9BA1B5;
    font-size: 13px;
    font-weight: 500;
    pointer-events: none;
}

.sg-demo-sig {
    width: 80%;
    max-width: 280px;
    height: 80px;
    display: block;
}
.sg-demo-sig path { fill: none; stroke: #1E2235; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.sg-draw-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    font-size: 12px;
    color: #9BA1B5;
}
.sg-draw-actions button {
    background: #fff;
    border: 1px solid #E4E6ED;
    color: #4A4F63;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
}
.sg-draw-actions button:hover { background: #FAFAFC; }

.sg-type-input {
    width: 100%;
    height: 64px;
    padding: 0 18px;
    border: 1.5px solid #D0D3DE;
    border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 28px;
    font-weight: 500;
    color: #1E2235;
    background: #fff;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.sg-type-input:focus {
    border-color: #3B4D8C;
    box-shadow: 0 0 0 4px rgba(59, 77, 140, .12);
}
.sg-type-help {
    margin-top: 8px;
    font-size: 12px;
    color: #9BA1B5;
    text-align: center;
}

.sg-upload-zone {
    display: block;
    background: #FAFAFC;
    border: 1.5px dashed #D0D3DE;
    border-radius: 12px;
    padding: 36px 18px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.sg-upload-zone:hover { border-color: #3B4D8C; background: rgba(59, 77, 140, .04); }
.sg-upload-zone svg { color: #9BA1B5; margin-bottom: 8px; }
.sg-upload-zone .lbl { font-size: 14px; font-weight: 600; color: #1E2235; }
.sg-upload-zone .sub { margin-top: 4px; font-size: 12px; color: #9BA1B5; }

.sg-disclosure {
    font-size: 12px;
    color: #9BA1B5;
    line-height: 1.55;
    padding: 16px 22px 0;
    border-top: 1px solid #F1F2F6;
    margin-top: 18px;
}
.sg-disclosure strong { color: #4A4F63; font-weight: 600; }

.sg-adopt-actions {
    padding: 14px 22px calc(env(safe-area-inset-bottom, 0px) + 14px);
    background: #fff;
    border-top: 1px solid #F1F2F6;
}
.sg-adopt-actions .sg-btn { max-width: none; }

/* ============================================================
   Pantalla 4 — Éxito (firma recibida, esperando supervisor)
   ============================================================ */
.sg-success {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    text-align: center;
    gap: 22px;
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
}

.sg-success-check {
    width: 88px; height: 88px;
    border-radius: 999px;
    background: #16a34a;
    color: #fff;
    display: grid; place-items: center;
    box-shadow: 0 12px 32px rgba(22, 163, 74, .30);
    animation: sg-pop .55s cubic-bezier(.34, 1.56, .64, 1);
}
.sg-success-check svg {
    width: 46px; height: 46px;
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    animation: sg-draw-check .7s ease-out .25s forwards;
}
@keyframes sg-draw-check { to { stroke-dashoffset: 0; } }

.sg-success-title {
    font-size: 24px;
    font-weight: 700;
    color: #1E2235;
    margin: 0;
    line-height: 1.25;
}
.sg-success-title .name { color: #3B4D8C; }
.sg-success-sub {
    font-size: 14px;
    color: #6E7590;
    margin: 0;
    line-height: 1.65;
    max-width: 360px;
}
.sg-success-sub strong { color: #1E2235; font-weight: 600; }

/* Estado de revisión — hace claro al cliente que aún no es definitivo */
.sg-status-card {
    width: 100%;
    background: #FFF8E1;
    border: 1px solid #FFE082;
    border-radius: 14px;
    padding: 16px 18px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    text-align: left;
}
.sg-status-card .icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: #FFE082;
    color: #92400e;
    display: grid; place-items: center;
    flex-shrink: 0;
}
.sg-status-card .text { flex: 1; }
.sg-status-card .title {
    font-size: 13px;
    font-weight: 700;
    color: #92400e;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.sg-status-card .sub {
    font-size: 13px;
    color: #6E7590;
    margin: 4px 0 0;
    line-height: 1.5;
}

/* Forensic transparency block */
.sg-forensic {
    width: 100%;
    background: #FAFAFC;
    border: 1px solid #F1F2F6;
    border-radius: 14px;
    padding: 16px 18px;
    text-align: left;
}
.sg-forensic .head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid #F1F2F6;
}
.sg-forensic .head .lbl {
    font-size: 12px;
    font-weight: 700;
    color: #1E2235;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.sg-forensic .head .lbl::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 999px;
    background: #16a34a;
}
.sg-forensic .head .id {
    font-size: 11px;
    color: #9BA1B5;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}
.sg-forensic-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sg-forensic-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
}
.sg-forensic-row .key {
    width: 90px;
    color: #9BA1B5;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 11px;
}
.sg-forensic-row .val {
    flex: 1;
    color: #4A4F63;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    word-break: break-all;
}
.sg-forensic-row .val strong { color: #1E2235; font-weight: 700; }

.sg-success-actions {
    width: 100%; max-width: 320px;
    display: flex; flex-direction: column;
    gap: 8px;
}

/* Hand-off al Public Adjuster (openclaimsai_connector) — verde = siguiente paso */
.sg-handoff {
    width: 100%;
    background: linear-gradient(135deg, #F0FAF4 0%, #E1F4E9 100%);
    border: 1px solid #BFE6CC;
    border-radius: 16px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
    box-shadow: 0 6px 20px rgba(22, 163, 74, 0.10);
}
.sg-handoff-head {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sg-handoff-badge {
    width: 32px; height: 32px;
    flex-shrink: 0;
    border-radius: 9px;
    background: #16a34a;
    color: #fff;
    display: grid; place-items: center;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.30);
}
.sg-handoff-title {
    font-size: 14px;
    font-weight: 700;
    color: #14532d;
    line-height: 1.3;
}
.sg-handoff-sub {
    font-size: 13px;
    color: #4A4F63;
    margin: 0;
    line-height: 1.55;
}
.sg-handoff-sub strong { color: #14532d; font-weight: 700; }

/* Chip con el nombre del Public Adjuster */
.sg-handoff-name {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid #C6E9D2;
    border-radius: 10px;
    padding: 10px 12px;
}
.sg-handoff-name .lbl {
    font-size: 10px;
    font-weight: 700;
    color: #15803d;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.sg-handoff-name .val {
    font-size: 14px;
    font-weight: 700;
    color: #1E2235;
    line-height: 1.3;
}

/* Botón verde */
.sg-btn-success {
    background: #16a34a; color: #fff;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.18);
}
.sg-btn-success:hover {
    background: #15803d;
    box-shadow: 0 6px 20px rgba(22, 163, 74, 0.28);
    transform: translateY(-1px);
}
.sg-btn-success:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }

.sg-handoff .sg-btn {
    width: 100%;
    max-width: none;
    margin-top: 2px;
}
.sg-handoff-btn-arrow {
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.sg-handoff .sg-btn:hover .sg-handoff-btn-arrow { transform: translateX(3px); }
.sg-handoff .sg-btn.is-loading { opacity: 0.9; cursor: default; transform: none; }

/* Aviso: no refrescar / no volver a presionar */
.sg-handoff-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: #5b6470;
}
.sg-handoff-note svg { flex-shrink: 0; margin-top: 1px; color: #15803d; }
.sg-handoff-note strong { color: #14532d; font-weight: 700; }

.sg-handoff-spinner {
    width: 15px; height: 15px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    display: inline-block;
    animation: sg-handoff-spin 0.7s linear infinite;
}
@keyframes sg-handoff-spin { to { transform: rotate(360deg); } }
.sg-handoff-error {
    font-size: 12px;
    color: #B42318;
    margin: 0;
    line-height: 1.45;
}

.sg-success-footer {
    text-align: center;
    font-size: 12px;
    color: #9BA1B5;
    padding: 16px 20px calc(env(safe-area-inset-bottom, 0px) + 16px);
}

/* ============================================================
   Pantalla 5 — Error / link expirado
   ============================================================ */
.sg-error-icon {
    width: 80px; height: 80px;
    background: #FFF3E0;
    color: #E65100;
    border-radius: 999px;
    display: grid; place-items: center;
    margin-bottom: 4px;
}
.sg-error-icon svg { width: 40px; height: 40px; }

.sg-error-title {
    font-size: 22px;
    font-weight: 700;
    color: #1E2235;
    margin: 0;
    line-height: 1.3;
}
.sg-error-sub {
    font-size: 14px;
    color: #6E7590;
    margin: 0;
    line-height: 1.6;
    max-width: 340px;
}

