/* =====================================================================
   AUTENTICADOR - Estilos base (mobile-first)
   Breakpoints: base = móvil, 768px = tablet, 1024px = escritorio
   ===================================================================== */

:root {
    --color-primary: #1a4d8f;
    --color-primary-dark: #123863;
    --color-bg: #f4f6f9;
    --color-text: #1f2933;
    --color-border: #d6dbe1;
    --color-error-bg: #fdecea;
    --color-error-text: #9b1c1c;
    --color-success-bg: #e6f4ea;
    --color-success-text: #276749;
    --gold:#d1a400;
    --gold-dark: #a87b00;
    --radius: 10px;
    --spacing: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 16px;
    line-height: 1.5;
}

/* ---------- Auth (login / recuperar contraseña) ---------- */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: var(--radius);
    padding: 32px 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    text-align: center;
}

.auth-title {
    margin: 0 0 4px;
    font-size: 24px;
    color: var(--gold-dark);
}

.auth-subtitle {
    margin: 0 0 24px;
    color: #6b7280;
    font-size: 14px;
}

.auth-form {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-form label {
    font-size: 14px;
    font-weight: 600;
    margin-top: 12px;
}

.auth-form input {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px; /* evita zoom automático en iOS */
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.auth-link {
    display: inline-block;
    margin-top: 16px;
    font-size: 14px;
    color: var(--color-primary);
    text-decoration: none;
}

/* ---------- Botones ---------- */
.btn {
    display: inline-block;
    border: none;
    border-radius: var(--radius);
    padding: 14px 18px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px; /* área táctil mínima recomendada */
}

.btn-primary {
    background: linear-gradient(135deg, #E0B400 0%, #B08200 100%);
    color: #fff;
    width: 100%;
    margin-top: 20px;
}

.btn-primary:active {
    background: var(--gold-dark);
}

.btn-link {
    background: none;
    color: var(--gold-dark);
    padding: 8px 12px;
}

/* ---------- Alertas ---------- */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 12px;
    text-align: left;
}

.alert-error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

/* ---------- App shell (dashboards) ---------- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 12px var(--spacing);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
}

.app-header-title {
    font-weight: 700;
    color: var(--gold-dark);
}

.app-content {
    padding: var(--spacing);
    max-width: 720px;
    margin: 0 auto;
}

/* ---------- Tablet ---------- */
@media (min-width: 768px) {
    .auth-card {
        padding: 40px;
    }
}

/* ---------- Desktop ---------- */
@media (min-width: 1024px) {
    .app-content {
        max-width: 960px;
    }
}

/* =====================================================================
   Módulo 2 - Administración de abogados
   ===================================================================== */

.text-muted {
    color: #6b7280;
}

.admin-nav {
    display: flex;
    gap: 8px;
    margin: 16px 0 20px;
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
}

.admin-nav-link {
    display: inline-block;
    padding: 10px 4px;
    margin-right: 16px;
    text-decoration: none;
    color: #6b7280;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.admin-nav-link.is-active {
    color: var(--gold-dark);
    border-bottom-color: var(--gold-dark);
}

.page-heading {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.page-heading h1 {
    margin: 0;
}

.btn-inline {
    width: auto;
    margin-top: 0;
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 12px;
    margin: 16px 0 24px;
}

.kpi-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-left: 4px solid var(--gold-dark);
}

.kpi-card-success {
    border-left-color: #276749;
}

.kpi-card-muted {
    border-left-color: #9ca3af;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-primary-dark);
}

.kpi-label {
    font-size: 13px;
    color: #6b7280;
    margin-top: 4px;
}

.section-title {
    font-size: 18px;
    margin: 24px 0 12px;
}

.table-wrap {
    overflow-x: auto;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 480px;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.data-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.actions-cell form {
    display: inline-flex;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.badge-muted {
    background: #f3f4f6;
    color: #6b7280;
}

.form-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    max-width: 480px;
}

.form-card label {
    font-size: 14px;
    font-weight: 600;
    margin-top: 14px;
}

.form-card input {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-top: 6px;
}

.form-hint {
    font-size: 13px;
    color: #6b7280;
    margin-top: 14px;
}

.field-error {
    color: var(--color-error-text);
    font-size: 13px;
    margin-top: 4px;
    display: block;
}

.btn-text {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    padding: 8px 6px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
}

.btn-text-danger {
    color: #9b1c1c;
}

.temp-password {
    display: inline-block;
    background: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 16px;
    letter-spacing: 1px;
    margin: 4px 0;
}

/* Tablet / Desktop: KPIs en fila */
@media (min-width: 640px) {
    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .page-heading {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* =====================================================================
   Módulo 3 - Plantillas y variables dinámicas
   ===================================================================== */

.variable-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 14px;
}

.pill-btn {
    background: #eef2ff;
    color: var(--color-primary-dark);
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    font-family: monospace;
    cursor: pointer;
}

.pill-btn:active {
    background: #e0e7ff;
}

.form-card textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    font-family: monospace;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    resize: vertical;
    min-height: 220px;
}

.preview-document {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    max-width: 720px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    line-height: 1.7;
}

.preview-document mark {
    background: #fef3c7;
    padding: 1px 4px;
    border-radius: 4px;
}

/* =====================================================================
   Módulo 4 - Procesos
   ===================================================================== */

.wizard-step-title {
    font-size: 16px;
    margin: 24px 0 4px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
    color: var(--gold-dark);
}

.wizard-step-title:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.form-card select {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-top: 6px;
    background: #fff;
}

.involved-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px;
    background: #f9fafb;
    border-radius: 8px;
}

.involved-row input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 16px;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 16px 0 24px;
}

.detail-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.plain-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.plain-list li {
    padding: 6px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 14px;
}

.plain-list li:last-child {
    border-bottom: none;
}

.pending-variable {
    background: #fef3c7;
    padding: 1px 5px;
    border-radius: 4px;
    color: #92400e;
    font-weight: 600;
}

.timeline {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.timeline li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-border);
    font-size: 14px;
}

.timeline li:last-child {
    border-bottom: none;
}

.timeline-date {
    font-size: 12px;
    color: #6b7280;
}

.timeline-event {
    font-weight: 600;
}

@media (min-width: 640px) {
    .detail-grid {
        grid-template-columns: 1fr 1fr;
    }

    .involved-row {
        flex-direction: row;
        background: none;
        padding: 0;
    }
}

/* =====================================================================
   Módulo 6 - Portal del firmante
   ===================================================================== */

.signer-progress {
    display: flex;
    justify-content: space-between;
    margin: 0 0 24px;
    gap: 4px;
}

.signer-progress-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    opacity: 0.5;
}

.signer-progress-step.is-done {
    opacity: 1;
}

.signer-progress-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #d6dbe1;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}

.signer-progress-step.is-done .signer-progress-dot {
    background: var(--gold);
}

.signer-progress-step.is-current .signer-progress-dot {
    background: var(--gold-dark);
}

.signer-progress-label {
    font-size: 11px;
    color: #6b7280;
}

.camera-preview {
    width: 100%;
    max-width: 320px;
    border-radius: var(--radius);
    background: #000;
    display: block;
    margin: 0 auto;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    font-weight: 400;
    margin-top: 14px;
    line-height: 1.4;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

/* =====================================================================
   Módulo 7 - Firma manuscrita
   ===================================================================== */

.signature-pad-wrap {
    background: #fff;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.signature-canvas {
    width: 100%;
    height: 260px;
    display: block;
    touch-action: none;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    max-width: 380px;
    width: 100%;
}

/* =====================================================================
   Módulo adicional - Editor de texto enriquecido (Quill) para plantillas
   ===================================================================== */

#quill-toolbar {
    border: 1px solid var(--color-border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    background: #f9fafb;
    display: flex;
    flex-wrap: wrap;
    row-gap: 4px;
}

#quill-toolbar .ql-formats {
    margin-right: 8px;
}

#quill-editor {
    min-height: 260px;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 0 0 var(--radius) var(--radius);
    font-size: 16px;
    line-height: 1.6;
}

#quill-editor .ql-editor {
    min-height: 260px;
}

/* Los botones/selects de Quill son pequeños por defecto; se agranda
   un poco el área táctil para uso cómodo desde el celular. */
#quill-toolbar button,
#quill-toolbar .ql-picker-label {
    padding: 4px;
    min-width: 32px;
    min-height: 32px;
}

@media (max-width: 480px) {
    #quill-toolbar .ql-formats {
        margin-right: 4px;
    }
}

/* =====================================================================
   Módulo adicional - Selector de fuente del documento (plantilla / PDF subido)
   ===================================================================== */

.source-toggle {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 8px 0 16px;
}

.source-toggle-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 500;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
}

.source-toggle-option input[type="radio"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.source-section {
    margin-bottom: 12px;
}

@media (min-width: 480px) {
    .source-toggle {
        flex-direction: row;
    }

    .source-toggle-option {
        flex: 1;
    }
}

/* =====================================================================
   Módulo adicional - Revisión de PDF fuente embebido en el portal del firmante
   ===================================================================== */

.pdf-embed-wrap {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #f3f4f6;
}

.pdf-embed {
    width: 100%;
    height: 60vh;
    min-height: 320px;
    border: none;
    display: block;
}
.auth-logo {
    display: block;
    width: 100%;
    max-width: 280px;
    height: auto;
    margin: 0 auto 20px;
}

.dashboard-logo {
    display: block;
    width: 100%;
    max-width: 200px;
    height: 50%;
}