/* ==========================================================================
   Plenario · Firma Electrónica de Documentos
   Tema claro alineado con Plenario Tickets
   ========================================================================== */

:root {
    --brand:       #2563eb;
    --brand-dark:  #1d4ed8;
    --brand-soft:  #eff6ff;
    --sidebar:     #0f172a;
    --bg:          #f8fafc;
    --card:        #ffffff;
    --text:        #1e293b;
    --text-strong: #0f172a;
    --muted:       #64748b;
    --line:        #e2e8f0;
    --line-soft:   #f1f5f9;
    --ok:          #16a34a;
    --ok-bg:       #dcfce7;
    --warn:        #b45309;
    --warn-bg:     #fef3c7;
    --err:         #dc2626;
    --err-bg:      #fee2e2;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ---------- Header ---------- */
header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    padding: 14px 24px;
    box-shadow: 0 1px 0 rgba(15,23,42,.02);
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 1100px;
    margin: 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-strong);
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    letter-spacing: -.5px;
}

.brand-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-strong);
    line-height: 1.1;
}

.brand-tag {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    margin-top: 2px;
}

.app-user {
    text-align: right;
    font-size: 13px;
    color: var(--muted);
}

.app-user strong {
    display: block;
    color: var(--text-strong);
    font-weight: 600;
    font-size: 14px;
}

.title {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
    color: var(--text-strong);
    font-weight: 700;
}

.subtitle {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
    font-weight: 400;
}

.wrap {
    max-width: 760px;
    margin: 24px auto;
    padding: 0 16px 60px;
}

/* ---------- Stepper ---------- */
.stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}

.step {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--line-soft);
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    border: 2px solid var(--line);
    transition: all .2s ease;
}

.step-label { white-space: nowrap; }

.step.is-active .step-num {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-soft);
}

.step.is-active { color: var(--text-strong); }

.step.is-done .step-num {
    background: var(--ok);
    color: #fff;
    border-color: var(--ok);
}

.step.is-done .step-num::after {
    content: '✓';
    font-size: 16px;
    line-height: 1;
}

.step.is-done .step-num span { display: none; }

.step.is-done { color: var(--ok); }

.step-line {
    flex: 1 1 auto;
    height: 2px;
    background: var(--line);
    margin: 0 6px;
    border-radius: 1px;
    min-width: 16px;
}

.step-line.is-done { background: var(--ok); }

@media (max-width: 540px) {
    .step-label { display: none; }
    .stepper { padding: 14px; }
}

/* ---------- Cards ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
    margin-bottom: 16px;
    overflow: hidden;
}

.card h3 {
    margin: 0;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -.2px;
    color: var(--text-strong);
    background: #ffffff;
}

.content { padding: 18px 20px; }

/* ---------- Welcome / Final / Error containers ---------- */
.wcontent {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 70vh;
    padding: 20px;
}

.welcome-container,
.final-container,
.error-container {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 40px 48px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(15,23,42,.06);
    max-width: 640px;
    margin: 40px auto;
    animation: fadeIn .5s ease;
}

.welcome-icon,
.final-icon,
.error-icon {
    font-size: 56px;
    margin-bottom: 12px;
}

.final-icon { color: var(--ok); }
.error-icon { color: var(--err); }

.welcome-text h2,
.final-text h1,
.error-text h1 {
    font-size: 26px;
    margin: 8px 0 12px;
    color: var(--text-strong);
    font-weight: 700;
}

.final-text h1 { color: var(--ok); }
.error-text h1 { color: var(--err); }

.welcome-text p,
.final-text h2,
.error-text h2 {
    font-size: 16px;
    color: var(--muted);
    line-height: 1.6;
    font-weight: 400;
    margin: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Doc rows ---------- */
.doc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line-soft);
}

.doc-row:last-child { border-bottom: none; }

.doc-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-strong);
}

/* ---------- Buttons ---------- */
.btn {
    appearance: none;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text-strong);
    border-radius: 8px;
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
    min-height: 40px;
    font-size: 14px;
    transition: all .15s ease;
    font-family: inherit;
}

.btn:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(37,99,235,.2);
}

.btn-primary:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #ffffff;
}

.btn-primary:disabled {
    opacity: .5;
    cursor: not-allowed;
    background: var(--brand);
    border-color: var(--brand);
    color: #ffffff;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
}

.btn-outline:hover {
    background: var(--brand-soft);
    border-color: var(--brand);
    color: var(--brand);
}

.btn-camera {
    width: 100%;
    text-align: center;
    background: var(--brand-soft);
    border: 1px dashed var(--brand);
    color: var(--brand);
    font-weight: 600;
}

.btn-camera:hover {
    background: #dbeafe;
    color: var(--brand-dark);
    border-color: var(--brand-dark);
}

/* ---------- Uploader ---------- */
.uploader {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

@media (min-width: 720px) {
    .uploader {
        grid-template-columns: repeat(3, 1fr);
    }
}

.up-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    background: var(--line-soft);
    transition: border-color .15s ease;
}

.up-card:hover { border-color: var(--brand); }

.up-head {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 6px;
    color: var(--text-strong);
}

.helper {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 10px;
    line-height: 1.4;
}

.thumb {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    display: none;
    margin-top: 10px;
    background: #ffffff;
}

.hidden-file { display: none; }

/* ---------- Checkbox row ---------- */
.check-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-top: 6px;
    padding: 14px;
    background: var(--brand-soft);
    border: 1px solid #dbeafe;
    border-radius: 8px;
}

.check-row input {
    width: 20px;
    height: 20px;
    margin-top: 1px;
    accent-color: var(--brand);
    cursor: pointer;
}

label {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
}

/* ---------- Signature canvas ---------- */
.signature {
    width: 100%;
    height: 200px;
    background: var(--line-soft);
    border: 2px dashed var(--line);
    border-radius: 10px;
    touch-action: none;
    cursor: crosshair;
}

/* Barra de acción del canvas: pill de estado a la izquierda, botón "Limpiar firma" a la derecha */
.sig-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
    width: 100%;
}

.sig-actions .status {
    margin-top: 0;
    margin-right: auto;
}

.sig-actions #clearSig {
    margin-left: auto;
}

/* ---------- Status / Pills ---------- */
.status {
    margin-top: 12px;
    font-size: 13px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: .1px;
}

.pill-ok {
    background: var(--ok-bg);
    color: var(--ok);
    border-color: #bbf7d0;
}

.pill-warn {
    background: var(--warn-bg);
    color: var(--warn);
    border-color: #fde68a;
}

.pill-err {
    background: var(--err-bg);
    color: var(--err);
    border-color: #fecaca;
}

/* ---------- Footer actions ---------- */
.footer-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    align-items: center;
    flex-wrap: wrap;
}

@media (min-width: 480px) {
    .footer-actions { justify-content: flex-start; }
}

/* ---------- SweetAlert overrides ---------- */
.swal2-popup {
    background: var(--card) !important;
    border: 1px solid var(--line) !important;
    border-radius: 14px !important;
    color: var(--text) !important;
    box-shadow: 0 20px 50px rgba(15,23,42,.15) !important;
    font-family: inherit !important;
}

.swal2-title {
    color: var(--text-strong) !important;
    font-weight: 700 !important;
}

.swal2-content,
.swal2-html-container {
    color: var(--muted) !important;
}

.swal2-confirm {
    background: var(--brand) !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 10px 20px !important;
    font-weight: 600 !important;
    box-shadow: 0 1px 2px rgba(37,99,235,.2) !important;
}

.swal2-confirm:hover {
    background: var(--brand-dark) !important;
}

.swal2-cancel {
    background: #ffffff !important;
    border: 1px solid var(--line) !important;
    border-radius: 8px !important;
    color: var(--text) !important;
    padding: 10px 20px !important;
    font-weight: 600 !important;
}

.swal2-cancel:hover {
    border-color: var(--brand) !important;
    color: var(--brand) !important;
}

.swal2-backdrop {
    background: rgba(15,23,42,.4) !important;
    backdrop-filter: blur(4px) !important;
}

/* Spinner del modal "Procesando firma..." */
.firma-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--line);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: firmaSpin 0.9s linear infinite;
    display: inline-block;
}

@keyframes firmaSpin {
    to { transform: rotate(360deg); }
}

/* Ocultar el spinner nativo de SweetAlert para evitar doble spinner */
.swal2-popup .swal2-loader {
    display: none !important;
}

/* Popup del resumen pre-firma: más ancho y con scroll vertical si la lista de docs es larga */
.swal-resumen-popup {
    max-width: 95vw !important;
}

.swal-resumen-popup .swal2-html-container {
    max-height: 60vh;
    overflow-y: auto;
    text-align: left !important;
    padding: 0 8px !important;
    margin: 0 !important;
}

.swal-resumen-popup .swal2-title {
    font-size: 18px !important;
    text-align: left !important;
    padding: 8px 8px 12px !important;
    margin: 0 !important;
}
