@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* ── Overlay ─────────────────────────────────────────────── */
#contrato-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0,0,0,0.88);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: flex-end;
    justify-content: center;
}
#contrato-overlay.visible { display: flex; }

/* ── Modal ───────────────────────────────────────────────── */
.contrato-modal {
    font-family: 'Poppins', sans-serif;
    background: #111318;
    border: 1px solid rgba(255,255,255,0.08);
    border-bottom: none;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 600px;
    height: 96vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.35s cubic-bezier(0.32,0.72,0,1);
}
@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Linha de cor no topo */
.contrato-topo-linha {
    height: 3px;
    width: 100%;
    flex-shrink: 0;
    border-radius: 20px 20px 0 0;
}

/* Handle */
.contrato-handle {
    display: flex;
    justify-content: center;
    padding: 8px 0 2px;
    flex-shrink: 0;
}
.contrato-handle span {
    width: 32px; height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.12);
}

/* ══════════════════════════════════════════════════════════
   METADE SUPERIOR — leitura do contrato (50% da tela)
   ══════════════════════════════════════════════════════════ */
.contrato-topo {
    flex: 0 0 48%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}

/* Header compacto */
.contrato-header {
    padding: 6px 18px 8px;
    flex-shrink: 0;
}
.contrato-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 100px;
    margin-bottom: 4px;
    border: 1px solid;
}
.contrato-badge svg { width: 9px; height: 9px; }
.contrato-titulo {
    font-size: 16px;
    font-weight: 700;
    color: #f0f0f0;
    line-height: 1.2;
    margin: 0 0 1px;
}
.contrato-versao {
    font-size: 10px;
    color: rgba(255,255,255,0.3);
    margin: 0 0 6px;
}

/* Barra de progresso */
.contrato-progress-wrap {
    height: 2px;
    background: rgba(255,255,255,0.06);
    border-radius: 2px;
    overflow: hidden;
}
.contrato-progress-bar {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    transition: width 0.15s ease;
}
.contrato-read-pct {
    font-size: 9px;
    color: rgba(255,255,255,0.25);
    text-align: right;
    margin-top: 2px;
}

/* Corpo com scroll */
.contrato-body {
    flex: 1;
    overflow-y: scroll;
    padding: 4px 18px 12px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
/* Scrollbar visível */
.contrato-body::-webkit-scrollbar { width: 4px; }
.contrato-body::-webkit-scrollbar-track { background: rgba(255,255,255,0.04); border-radius: 2px; }
.contrato-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }

/* Texto */
.contrato-doc {
    font-size: 11.5px;
    line-height: 1.7;
    color: rgba(255,255,255,0.6);
}
.contrato-doc .doc-titulo {
    font-size: 12px; font-weight: 700;
    color: #f0f0f0; text-align: center; margin: 0 0 2px;
}
.contrato-doc .doc-subtitulo {
    font-size: 9px; text-align: center;
    color: rgba(255,255,255,0.28);
    letter-spacing: 0.07em; text-transform: uppercase;
    margin: 0 0 14px;
}
.contrato-doc .doc-secao {
    font-size: 9px; font-weight: 700;
    letter-spacing: 0.1em; text-transform: uppercase;
    padding-bottom: 5px; border-bottom: 1px solid;
    margin: 16px 0 7px;
}
.contrato-doc p { margin: 0 0 8px; }
.contrato-doc .doc-clausula {
    border-left: 2px solid;
    padding: 8px 10px;
    margin: 8px 0;
    border-radius: 0 6px 6px 0;
    background: rgba(255,255,255,0.02);
}
.contrato-doc .doc-clausula strong {
    display: block; font-size: 11px;
    color: #f0f0f0; margin-bottom: 2px;
}
.contrato-doc ul { padding-left: 14px; margin: 4px 0 8px; }
.contrato-doc ul li { margin-bottom: 4px; }
.contrato-doc .doc-rodape-contrato {
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: 14px; padding: 10px 0;
    font-size: 9px; color: rgba(255,255,255,0.2);
    text-align: center;
}

/* ══════════════════════════════════════════════════════════
   METADE INFERIOR — ações (50% restante, fixo)
   ══════════════════════════════════════════════════════════ */
.contrato-baixo {
    flex: 0 0 52%;
    display: flex;
    flex-direction: column;
    padding: 10px 18px 16px;
    background: #0e1014;
    overflow: hidden;
}

/* Alerta */
.contrato-read-alert {
    display: flex;
    align-items: center;
    gap: 7px;
    background: rgba(255,180,0,0.07);
    border: 1px solid rgba(255,180,0,0.2);
    border-radius: 8px;
    padding: 7px 10px;
    margin-bottom: 8px;
    font-size: 10.5px;
    color: rgba(255,200,50,0.8);
    flex-shrink: 0;
}
.contrato-read-alert svg { width: 13px; height: 13px; flex-shrink: 0; }
.contrato-read-alert.hidden { display: none; }

#contrato-erro {
    display: none;
    background: rgba(220,50,50,0.12);
    border: 1px solid rgba(220,50,50,0.3);
    color: #ff7070;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 10.5px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

/* Checkbox */
.contrato-aceite {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    flex-shrink: 0;
}
.contrato-aceite-box {
    width: 20px; height: 20px; min-width: 20px;
    border-radius: 5px;
    border: 2px solid rgba(255,255,255,0.18);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
    background: rgba(255,255,255,0.03);
}
.contrato-aceite-box svg {
    width: 12px; height: 12px;
    opacity: 0; transform: scale(0.4);
    transition: all 0.18s ease;
    color: #fff;
}
.contrato-aceite.marcado .contrato-aceite-box svg {
    opacity: 1; transform: scale(1);
}
.contrato-aceite-label {
    font-size: 11.5px; line-height: 1.4;
    color: rgba(255,255,255,0.5);
}
.contrato-aceite-label strong { color: #f0f0f0; }

/* Canvas */
.contrato-assinatura-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: opacity 0.25s;
    min-height: 0;
    margin-bottom: 10px;
}
.contrato-assinatura-wrap.bloqueado {
    opacity: 0.3;
    pointer-events: none;
}
.contrato-assinatura-topo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
    flex-shrink: 0;
}
.contrato-assinatura-label {
    font-size: 9px; font-weight: 600;
    letter-spacing: 0.1em; text-transform: uppercase;
    color: rgba(255,255,255,0.3);
}
.btn-limpar {
    background: none; border: none;
    font-family: 'Poppins', sans-serif;
    font-size: 10px; cursor: pointer;
    padding: 0; text-decoration: underline;
    text-underline-offset: 2px;
    transition: opacity 0.2s; opacity: 0.6;
}
.btn-limpar:hover { opacity: 1; }

.canvas-wrap {
    flex: 1;
    position: relative;
    border: 1.5px dashed rgba(255,255,255,0.12);
    border-radius: 10px;
    background: rgba(255,255,255,0.02);
    overflow: hidden;
    cursor: crosshair;
    transition: border-color 0.2s;
    min-height: 80px;
}
.canvas-wrap:hover { border-color: rgba(255,255,255,0.25); }
.canvas-wrap.assinado { border-style: solid; }

.canvas-wrap canvas {
    display: block;
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
}
.canvas-placeholder {
    position: absolute; inset: 0;
    display: flex; align-items: center;
    justify-content: center; gap: 6px;
    pointer-events: none; transition: opacity 0.25s;
}
.canvas-wrap.assinado .canvas-placeholder { opacity: 0; }
.canvas-placeholder svg { width: 14px; height: 14px; opacity: 0.2; }
.canvas-placeholder span { font-size: 11px; color: rgba(255,255,255,0.18); }

/* Botões */
.contrato-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.btn-pdf {
    display: flex; align-items: center; justify-content: center;
    width: 44px; min-width: 44px; height: 44px;
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.45);
    cursor: pointer; transition: all 0.2s; flex-shrink: 0;
}
.btn-pdf svg { width: 15px; height: 15px; }
.btn-pdf:hover:not(:disabled) { background: rgba(255,255,255,0.09); color: #fff; }
.btn-pdf:disabled { opacity: 0.2; cursor: not-allowed; }

.btn-assinar {
    flex: 1; height: 44px;
    border: none; border-radius: 10px;
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center;
    justify-content: center; gap: 7px;
    transition: all 0.2s ease;
}
.btn-assinar svg { width: 15px; height: 15px; }
.btn-assinar:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-assinar:not(:disabled):active { transform: scale(0.98); }

/* ── Sucesso ─────────────────────────────────────────────── */
.contrato-sucesso {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
    gap: 12px;
    flex: 1;
}
.contrato-sucesso.visible { display: flex; }
.sucesso-icon {
    width: 64px; height: 64px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid;
    animation: popIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
.sucesso-icon svg { width: 30px; height: 30px; }
.sucesso-titulo { font-size: 19px; font-weight: 700; color: #f0f0f0; margin: 0; }
.sucesso-texto { font-size: 12px; color: rgba(255,255,255,0.4); max-width: 300px; line-height: 1.6; margin: 0; }
.btn-continuar {
    height: 46px; padding: 0 28px;
    border: none; border-radius: 10px;
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; gap: 7px;
    transition: opacity 0.2s, transform 0.2s;
}
.btn-continuar:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-continuar svg { width: 15px; height: 15px; }

.spin { animation: spinR 0.8s linear infinite; }
@keyframes spinR { to { transform: rotate(360deg); } }