/* ==========================================================================
   DISEÑO DE ESTILOS PREMIUM - SISTEMA DE FIRMAS DIGITALES
   ========================================================================== */

/* Variables de diseño */
:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --paper-bg: #fafaf9;
    --paper-text: #1c1917;
    --shadow-premium: 0 20px 25px -5px rgb(0 0 0 / 0.3), 0 8px 10px -6px rgb(0 0 0 / 0.3);
    --font-sans: 'Inter', sans-serif;
    --font-serif: 'Playfair Display', Georgia, serif;
}

/* Reset y Estilos Globales */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 20px;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 760px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Encabezado */
.main-header {
    text-align: center;
    padding: 20px 10px;
}

.logo {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 60px;
    height: 60px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 50%;
    font-size: 24px;
    color: #818cf8;
    margin-bottom: 15px;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.main-header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 8px;
    background: linear-gradient(to right, #ffffff, #c7d2fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.5;
}

/* Sección de la Nota Reclamo (Efecto Papel Físico) */
.document-section {
    perspective: 1000px;
}

.paper-sheet {
    background-color: var(--paper-bg);
    color: var(--paper-text);
    border-radius: 12px;
    padding: 40px 35px;
    box-shadow: var(--shadow-premium), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Efecto de línea roja lateral de los folios legales */
.paper-sheet::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 28px;
    width: 1px;
    background-color: rgba(239, 68, 68, 0.25);
}

.paper-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding-bottom: 15px;
    margin-bottom: 25px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #78716c;
}

.document-body {
    font-family: var(--font-sans);
    line-height: 1.7;
    font-size: 1rem;
    padding-left: 15px;
}

.destination {
    font-weight: 700;
    margin-bottom: 20px;
}

.presenter {
    margin-bottom: 20px;
}

.editable-content {
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.02);
    border-left: 3px solid #78716c;
    padding: 15px;
    border-radius: 4px;
}

.editable-content p {
    margin-bottom: 12px;
}

.editable-content p:last-child {
    margin-bottom: 0;
}

.closing {
    margin-top: 25px;
    font-style: italic;
}

/* Sección de Formulario con Glassmorphism */
.form-section {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow-premium);
}

.form-section h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.form-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 25px;
}

form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 500px) {
    .input-grid {
        grid-template-columns: 1fr;
    }
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 6px;
}

input[type="text"],
input[type="password"] {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
    background: rgba(15, 23, 42, 0.8);
}

/* Área del Lienzo de la Firma (Canvas) */
.signature-pad-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.canvas-wrapper {
    background: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    width: 100%;
    height: 180px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none; /* Previene el scroll de la pantalla al firmar en móvil */
}

.canvas-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.pad-status {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Botones */
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-sans);
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    font-size: 0.8rem;
    padding: 8px 12px;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-block {
    width: 100%;
}

/* Pie de Página */
.main-footer {
    text-align: center;
    padding: 20px 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-link {
    background: none;
    border: none;
    color: #6366f1;
    cursor: pointer;
    font-size: 0.8rem;
    transition: color 0.2s ease;
}

.admin-link:hover {
    color: #818cf8;
    text-decoration: underline;
}

/* Modales y Superposiciones */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-premium);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.75rem;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover {
    color: white;
}

.modal-body {
    padding: 24px;
}

/* Éxito de Firma */
.success-card {
    max-width: 400px;
    text-align: center;
    padding: 35px 24px;
}

.success-icon {
    font-size: 50px;
    color: var(--success);
    margin-bottom: 15px;
}

.success-card h2 {
    margin-bottom: 10px;
    color: white;
}

.success-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 25px;
    line-height: 1.5;
}

/* Panel de Administración Interno */
.hidden {
    display: none !important;
}

.error-msg {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 10px;
    display: none;
}

.admin-stats {
    margin-bottom: 20px;
}

.stat-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.stat-num {
    display: block;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-actions {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.admin-actions .btn {
    flex: 1;
}

/* Tabla de Firmas en Panel Admin */
.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

th, td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

th {
    background: rgba(15, 23, 42, 0.6);
    color: white;
    font-weight: 600;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.sig-image-preview {
    max-height: 30px;
    max-width: 80px;
    filter: invert(1) contrast(200%); /* Hace que la firma negra resalte sobre el fondo oscuro del admin */
}

/* Sección de la Evidencia Fotográfica */
.evidence-section {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow-premium);
}

.evidence-section h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.section-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 25px;
}

.evidence-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 700px) {
    .evidence-grid {
        grid-template-columns: 1fr;
    }
}

.evidence-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.evidence-card:hover {
    transform: translateY(-4px);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.img-container {
    height: 140px;
    position: relative;
    overflow: hidden;
    background: #000;
}

.img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.evidence-card:hover .img-container img {
    transform: scale(1.08);
}

.img-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.evidence-card:hover .img-overlay {
    opacity: 1;
}

.img-overlay span {
    background: rgba(99, 102, 241, 0.9);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    color: white;
    display: flex;
    align-items: center;
    gap: 6px;
    transform: translateY(10px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.evidence-card:hover .img-overlay span {
    transform: translateY(0);
}

.card-caption {
    padding: 15px;
}

.card-caption h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: white;
}

.card-caption p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Lightbox Modal de Imágenes */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 40px 20px;
}

.lightbox.active {
    opacity: 1;
    pointer-events: auto;
}

.lightbox img {
    max-width: 90%;
    max-height: 75vh;
    border-radius: 8px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    object-fit: contain;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.lightbox.active img {
    transform: scale(1);
}

.close-lightbox {
    position: absolute;
    top: 25px;
    right: 35px;
    color: #cbd5e1;
    font-size: 40px;
    font-weight: 300;
    cursor: pointer;
    transition: color 0.2s ease;
    user-select: none;
}

.close-lightbox:hover {
    color: white;
}

.lightbox-caption {
    margin-top: 20px;
    color: #cbd5e1;
    font-size: 0.95rem;
    text-align: center;
    max-width: 600px;
    line-height: 1.5;
}

/* Animaciones */
.animate-fade-in {
    animation: fadeIn 0.6s ease forwards;
}

.animate-slide-up {
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

.animate-scale-up {
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.delay-1 {
    animation-delay: 0.15s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes scaleUp {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==========================================================================
   ESTILOS DE IMPRESIÓN OFICIAL (EXPORTACIÓN A PDF)
   ========================================================================== */
@media print {
    /* Configuración de la página física */
    @page {
        size: A4;
        margin: 20mm;
    }

    body, html {
        background: #ffffff !important;
        color: #000000 !important;
        font-family: 'Inter', sans-serif;
        margin: 0;
        padding: 0;
        width: 100%;
        height: auto;
    }

    /* Ocultar elementos interactivos y de pantalla */
    .main-header,
    .evidence-section,
    .form-section,
    .main-footer,
    .lightbox,
    .canvas-controls,
    #adminLoginBtn,
    .close-modal,
    .admin-actions,
    #adminAuthSection,
    .stat-card {
        display: none !important;
    }

    /* Contenedor principal de impresión */
    .app-container {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        gap: 30px !important;
    }

    /* Primera Página: La Nota de Reclamo */
    .document-section {
        display: block !important;
        page-break-after: always; /* Fuerza salto de página después de la carta */
        margin-bottom: 0 !important;
    }

    .paper-sheet {
        background: #ffffff !important;
        color: #000000 !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
    }

    .paper-sheet::before {
        display: none !important; /* Oculta la línea roja lateral */
    }

    .paper-header {
        color: #000000 !important;
        border-bottom: 2px solid #000000 !important;
        padding-bottom: 10px !important;
    }

    .document-body {
        font-size: 11pt !important;
        line-height: 1.6 !important;
        padding-left: 0 !important;
    }

    /* Páginas Siguientes: Tabla de Firmas Colectivas */
    .modal-overlay {
        position: relative !important;
        background: #ffffff !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        display: block !important;
        padding: 0 !important;
        z-index: auto !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
    }

    .modal-card {
        background: #ffffff !important;
        border: none !important;
        box-shadow: none !important;
        max-width: 100% !important;
        width: 100% !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .modal-header {
        display: block !important;
        border-bottom: 2px solid #000000 !important;
        padding: 0 0 10px 0 !important;
        margin-bottom: 20px !important;
    }

    .modal-header h2 {
        color: #000000 !important;
        font-size: 14pt !important;
    }

    .modal-body {
        padding: 0 !important;
    }

    #adminContentSection {
        display: block !important;
    }

    .table-wrapper {
        border: none !important;
        overflow: visible !important;
    }

    table {
        width: 100% !important;
        border-collapse: collapse !important;
        page-break-inside: auto;
    }

    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    th, td {
        color: #000000 !important;
        border-bottom: 1px solid #dddddd !important;
        padding: 10px 8px !important;
        background: #ffffff !important;
        font-size: 10pt !important;
    }

    th {
        border-bottom: 2px solid #000000 !important;
        font-weight: 700 !important;
    }

    /* Imagen de las firmas nítidas y oscuras para impresión */
    .sig-image-preview {
        max-height: 35px !important;
        max-width: 90px !important;
        filter: none !important; /* Muestra el trazo negro sobre papel blanco */
    }
}
