/* =========================================
   1. ESTILOS GENERALES Y CONTENEDORES
   ========================================= */

.wl-container, .wl-user-dashboard, .wl-frontend {
    max-width: 900px;
    margin: 30px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid #e1e4e8;
    box-sizing: border-box;
}

/* Login Wrapper */
.wl-login-wrapper {
    max-width: 400px;
    margin: 50px auto;
    padding: 30px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    text-align: center;
}

/* =========================================
   2. HEADER Y NAVEGACIÓN (DASHBOARD)
   ========================================= */

.wl-header {
    padding: 0 0 20px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wl-user-info {
    color: #333;
    font-size: 1.1em;
}

.wl-btn-logout {
    background: none;
    border: 1px solid #d63638;
    color: #d63638;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.wl-btn-logout:hover {
    background: #d63638;
    color: #fff;
}

/* Tabs de Navegación */
.wl-tabs-nav {
    display: flex;
    background: #fff;
    border-bottom: 1px solid #e1e4e8;
    margin-bottom: 25px;
    gap: 10px;
}

.wl-tab-link {
    background: none;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    font-weight: 600;
    color: #646970;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wl-tab-link:hover {
    color: #2271b1;
    background: #f0f6fc;
}

.wl-tab-link.active {
    color: #2271b1;
    border-bottom: 3px solid #2271b1;
}

.wl-tab-content {
    /* El JS maneja el display:block/none */
    animation: fadeIn 0.3s ease-in-out;
}

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

/* =========================================
   3. FORMULARIOS Y BOTONES
   ========================================= */

.wl-toolbar {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
}

.wl-search-form {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 500px;
}

.wl-form-box {
    background: #f9f9f9;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #eee;
}

.wl-form-box h4 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #2c3338;
}

.wl-form-group {
    margin-bottom: 20px;
}

.wl-form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.wl-form-group input[type="text"],
.wl-form-group input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 1em;
}

/* Botones Principales */
.wl-btn {
    background: #2271b1;
    color: #fff !important;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 1em;
    display: inline-block;
    transition: background 0.2s;
}

.wl-btn:hover {
    background: #135e96;
}

.wl-btn-secondary {
    background: #f6f7f7;
    color: #2271b1 !important;
    border: 1px solid #2271b1;
    padding: 9px 18px;
    border-radius: 4px;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
}

.wl-btn-secondary:hover {
    background: #f0f0f1;
}

/* =========================================
   4. TABLAS Y PAGINACIÓN
   ========================================= */

.wl-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    border: 1px solid #e1e4e8;
}

.wl-table th {
    text-align: left;
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 2px solid #e1e4e8;
    color: #555;
    font-weight: 600;
}

.wl-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    color: #333;
    vertical-align: middle;
}

.wl-table tr:last-child td {
    border-bottom: none;
}

.wl-table tr:hover {
    background-color: #fafafa;
}

/* Fila activa (editando) */
.wl-editing-row {
    background-color: #e6f7ff !important;
}

.wl-badge {
    background: #e5e5e5;
    color: #333;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 700;
}

/* Acciones en Tabla */
.wl-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.wl-icon-btn {
    text-decoration: none;
    font-size: 1.2em;
    padding: 4px;
    border-radius: 4px;
}

.wl-icon-btn:hover {
    background-color: #f0f0f1;
}

.wl-icon-btn-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    padding: 4px;
    color: #d63638;
}

.wl-icon-btn-delete:hover {
    background-color: #fbeaea;
    border-radius: 4px;
}

/* Paginación */
.wl-pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
    align-items: center;
}

.wl-btn-page {
    background: #f0f0f1;
    border: 1px solid #ccc;
    padding: 6px 12px;
    text-decoration: none;
    border-radius: 4px;
    color: #333;
    font-size: 0.9em;
}

.wl-btn-page:hover {
    background: #e5e5e5;
}

/* =========================================
   5. ESTADÍSTICAS Y GRÁFICOS
   ========================================= */

.wl-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.wl-stat-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #e1e4e8;
}

.wl-stat-card h5 {
    margin: 0;
    color: #646970;
    font-weight: normal;
    font-size: 1em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wl-stat-card h2 {
    margin: 10px 0 0;
    color: #2271b1;
    font-size: 2.5em;
    font-weight: 700;
}

.wl-chart-container {
    background: #fff;
    padding: 20px;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
}

/* =========================================
   6. VISOR PDF PERSONALIZADO (FRONTEND)
   ========================================= */

.wl-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.wl-btn-text {
    text-decoration: none;
    color: #666;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 5px;
}

.wl-btn-text:hover {
    color: #2271b1;
}

/* Contenedor Oscuro del Visor */
#wl-pdf-wrapper {
    position: relative;
    width: 100%;
    min-height: 500px; /* Altura mínima cómoda */
    background: #333;  /* Gris oscuro profesional */
    border-radius: 8px;
    padding: 20px 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden; /* Evita que el canvas se salga antes de redimensionar */
}

/* Canvas del PDF (El documento en sí) */
#wl-pdf-render {
    display: none; /* Oculto hasta que cargue JS para evitar parpadeos */
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    margin-top: 15px;
    max-width: 100%; /* CLAVE: Para que el canvas de alta resolución no se salga del móvil */
    height: auto;    /* Mantiene la proporción */
}

/* Barra de Herramientas Flotante */
.wl-pdf-toolbar {
    display: none; /* Oculto hasta que cargue JS */
    background: rgba(0, 0, 0, 0.85); /* Negro semi-transparente */
    backdrop-filter: blur(5px);
    color: #fff;
    padding: 10px 25px;
    border-radius: 30px;
    gap: 20px;
    align-items: center;
    position: sticky;
    top: 10px;
    z-index: 100;
    margin-bottom: 10px;
    font-size: 0.9em;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* Botones de la Toolbar */
.wl-tool-btn {
    background: #555;
    border: 1px solid #666;
    color: #fff;
    padding: 6px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
    font-weight: 500;
}

.wl-tool-btn:hover {
    background: #777;
    border-color: #888;
}

.wl-btn-download {
    text-decoration: none;
    background: #2271b1; /* Azul WordPress */
    border-color: #2271b1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.2em;
}

.wl-btn-download:hover {
    background: #135e96;
}

/* Loader de Carga */
#wl-loader {
    display: block; /* Visible por defecto */
    color: #fff;
    margin-top: 100px;
    font-size: 1.2em;
    font-weight: 300;
    letter-spacing: 1px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* =========================================
   7. RESPONSIVE (MÓVIL)
   ========================================= */

@media (max-width: 600px) {
    .wl-container, .wl-frontend {
        padding: 15px;
        margin: 10px;
    }
    
    /* Tabs en columna o scroll en móvil */
    .wl-tabs-nav {
        flex-wrap: wrap;
    }
    
    .wl-tab-link {
        flex: 1 1 auto;
        justify-content: center;
        padding: 10px;
        font-size: 0.9em;
    }

    /* Tablas responsivas (Scroll horizontal) */
    .wl-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Stats en columna */
    .wl-stats-grid {
        grid-template-columns: 1fr;
    }

    /* Visor PDF Móvil */
    .wl-pdf-toolbar {
        width: 90%;
        padding: 8px 15px;
        gap: 10px;
        justify-content: space-between;
    }

    .wl-tool-btn {
        padding: 5px 10px;
        font-size: 0.8em;
    }
    
    #wl-page-count, #wl-page-num {
        font-size: 0.9em;
    }
}
/* ... Tus estilos anteriores ... */

#wl-pdf-wrapper {
    position: relative;
    width: 100%;
    min-height: 400px; /* IMPORTANTE: Altura mínima para que IntersectionObserver funcione */
    background: #333;
    border-radius: 8px;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#wl-pdf-render {
    display: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    margin-top: 10px;
}

.wl-pdf-toolbar {
    display: none; /* JS lo activa */
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 20px;
    border-radius: 30px;
    gap: 15px;
    color: white;
    position: sticky;
    top: 10px;
    z-index: 50;
    margin-bottom: 15px;
}

/* Spinner de Carga */
.wl-spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid #fff;
    width: 40px;
    height: 40px;
    margin: 0 auto 15px;
    -webkit-animation: spin 1s linear infinite; /* Safari */
    animation: spin 1s linear infinite;
}

#wl-loader {
    color: white;
    text-align: center;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}